The web in a box - a next generation web framework for the Perl programming language

IRC log for #mojo, 2017-08-05

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary

All times shown according to UTC.

Time Nick Message
00:33 yukikimoto joined #mojo
02:13 Grinnz mr robot s2 on amazon prime now, yay
02:17 noganex_ joined #mojo
02:31 Ptolemarch joined #mojo
03:45 arcanez Grinnz: I stopped watching after season 1. is it still good?
04:00 Grinnz it's a different kind of interesting, so far
04:05 bryan joined #mojo
04:33 go|dfish joined #mojo
05:21 arcanez it was just a bit too weird for me.
05:32 karjala joined #mojo
05:58 yukikimoto joined #mojo
06:05 trone joined #mojo
06:08 android joined #mojo
07:23 bianca joined #mojo
08:09 Lee[home] joined #mojo
08:33 Lee[home] joined #mojo
08:45 Vandal joined #mojo
09:07 bianca joined #mojo
09:38 VVelox joined #mojo
09:45 karjala joined #mojo
11:13 Lee[home] joined #mojo
11:28 petru joined #mojo
11:51 petru joined #mojo
12:57 bianca joined #mojo
13:36 elik joined #mojo
13:37 karjala Is there no way in postgresql to create a user and allow him to access a database programmatically, without editing the file /etc/postgresql/9.5/main/pg_hba.conf ?
13:38 karjala s/him/them/
13:40 pink_mist sure there is, why would you need to edit that conf file for every user?
13:53 Grinnz depends on what type of auth you're using in pg_hba.conf
13:54 Grinnz you can allow access to "all" for a certain auth type and host
13:55 Grinnz only users that exist will still be able to use it
14:18 karjala_ joined #mojo
14:34 PryMar56 joined #mojo
14:56 itaipu joined #mojo
15:32 stryx` joined #mojo
15:39 elik joined #mojo
16:21 karjala you're right, pink_mist, I'm sorry. I didn't read the default configuration file  carefully
16:22 karjala Ideally, I'd like to allow user A to login from host A, user B to only login from host B, etc
16:22 karjala Is that possible in postgres without editing the config file for each one user I add?
16:33 karjala btc is 3200
16:33 karjala :D
16:33 pink_mist I think you'd do better asking in a postgres-related channel =)
16:34 karjala yes, I'll do that. thanks
16:42 spicyjack karjala: you would use roles; assign a "group" role to the database, then assign normal postgres "user" roles to the "group" roles
16:43 spicyjack karjala: the docs have a whole section on this
16:43 spicyjack karjala: https://www.postgresql.org/docs/9.6/static/user-manag.html
16:43 karjala what would be the benefit of doing that?
16:44 spicyjack karjala: you don't have to modify pg_hba.conf to add new users
16:44 karjala how woould that help me to restrict each user to a single & different hostname?
16:44 spicyjack just add the user to the database, then add them to whatever "group" you want them to access
16:44 spicyjack oh, single hostname? you need pg_hba.conf for that
16:44 karjala ok thanks
16:46 spicyjack but if you use user/group roles, and remove all users from the 'public' (default) schema, anyone with valid credentials would be able to log in, but only users with credentials for a given database (in a "group" role assigned to that database) would be able to use that database
16:46 spicyjack karjala: so no need to monkey with pg_hba.conf
16:47 spicyjack karjala: if you have access to the firewall rules of the host, you can modify those dynamically without having to ask the database to reload configs after making changes
16:48 stryx` joined #mojo
16:48 spicyjack karjala: in Engerish we have an expression, "Six of one, half dozen of another"
16:48 spicyjack karjala: or if you're a Perl fan, TMTOWTDI
17:05 bianca joined #mojo
17:23 Grinnz any objection to plugin/helper/stash key names? https://github.com/Grinnz/Future-Mojo/blob/master/lib/Mojolicious/Plugin/Future.pm
17:33 kes joined #mojo
17:51 bianca joined #mojo
18:45 bianca Hey, any ideas on how I can render different templates depending on whether or not the session variables are set (you are logged in)? Like facebook does it, when I'm logged in it shows the home page and otherwise there's the login page. The way I'm doing it now seems a bit counterintuitive
18:46 pink_mist an under which checks if you're logged in could do it
18:46 bianca The way I am doing it now is I have a route $if_logged_in->get('/')->name('home')->to('example#welcome'); which passes through a helper function (is_logged_in) in controller to check if the session variables are set. In case they are, it goes on to render the welcome page and if not I am rendering a different template from that helper function is_logged_in
18:47 bianca pink_mist I have that but I'm not sure how I can render the 2 different ones except from the is_logged_in function
18:48 pink_mist just render the login form in the under and return undef if the user is not logged in
18:48 pink_mist if the user is logged in, return 1
18:48 pink_mist and don't render
18:51 bianca pink_mist when you say in the under, you mean in the function that checks for login? I have this code here http://ideone.com/CXhEpT
18:52 bianca I also want to show some other template if you're trying to get to /some/other/link when not logged in
18:52 bianca the 'permission/not_logged_in' one
18:52 pink_mist https://metacpan.org/pod/Mojolicious::Guides::Routing#Under
18:57 tommybutler joined #mojo
18:58 tommybutler google's not helping.  looking to create restful api using mojo lite.  working very well except for when errors are thrown...
18:58 tommybutler then html gets returned.  i only ever want it to return json.  the hack would be to modify the mojo classes themselves, edit the templates, etc.
18:59 tommybutler is there an actual recommended best practice for this kind of requirement?
18:59 bianca pink_mist I was wondering if there was a way to have 2 different statements in the dispatcher for the same route under different conditions. Something like $if_login->get('/')->to('home');
18:59 bianca $r->get('/')->to('landing');
18:59 pink_mist tommybutler: just provide your own error template
19:00 bianca when $if_login is defined as $r->under('/')->to('user#is_logged_in');
19:00 tommybutler how can I make sure that in addition to that, only content type headers for json get returned instead of text/html...
19:02 pink_mist tommybutler: actually ... what kind of errors are getting thrown? perhaps you should just catch them and render json for it yourself
19:02 tommybutler sorry if this seems like a silly question. this is literally day 2 for me with mojo.  and this isn't covered in the tutorial...
19:03 tommybutler pink_mist: I was using try::tiny for that exact issue.  there are just some errors I don't know how to anticipate.
19:03 pink_mist bianca: $r->under('/' => sub { my $c = shift; $c->render('login') and return undef if not $logged_in; return 1; });
19:04 pink_mist tommybutler: Try::Tiny can catch any error
19:04 pink_mist at least any catchable error
19:04 tommybutler i'm trapping all kinds of issues exactly like that.  I'm concerned once this is released to a broader user base, they will find ways to make it barf and when they do, I only want it to return json and json content type headers
19:08 tommybutler i guess I'll just wrap the whole primary route in a try::tiny block.  i'm using `under` and a catchall route to trap any other bad/invalid api calls.  I figured what I was doing was not best practice
19:09 Grinnz tommybutler: https://metacpan.org/pod/Mojolicious::Guides::Rendering#Rendering-exception-and-not_found-pages
19:09 Grinnz third example
19:09 purl hmmm... third example is just a bit of sugar as you can see, might be more fragile than we want
19:09 tommybutler Grinnz: thx.  I'll take a look and hopefully I won't have to settle on my original plan and modify/override the core mojo exception classes themselves
19:10 Grinnz using that hook you can change what is rendered from any exception, even a call to ->reply->exception
19:10 tommybutler :D
19:11 Grinnz you probably also want to do the same for not_found
19:12 tommybutler this is good stuff.  much more detail than the tutorial.
19:12 tommybutler should have looked here first :-/
19:14 tommybutler pink_mist: thx
19:15 tommybutler Grinnz: thx
19:31 irqq_ joined #mojo
19:37 vinnix joined #mojo
20:00 AirDisa_ joined #mojo
20:05 mishanti1 Currently converting an old(ish) Symfony ( https://symfony.com/ ) project to Mojolicious. The mind boggles at how much boilerplate code and cruft I am removing.
20:05 mishanti1 Much <3 for Mojo atm
22:58 karjala Isn't it a design mistake that DBD::Pg requires you to have installed postgresql the database in your db client machine, before you can install DBD::Pg ?
23:00 preaction is there a client-only library?
23:03 karjala I'm reading https://metacpan.org/source/TURNSTEP/DBD-Pg-3.6.2/README now to see if there's a better way to install it. This document says it wants Postgres itself installed. I don't know anything else (yet)
23:06 karjala oh, the libpg-dev package (of ubuntu) was enough for the module to get installed. No reason for postgres after all.
23:34 stryx` joined #mojo
23:59 AirDisa joined #mojo

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary