[Catalyst] Can't locate Catalyst/Plugin/Authentication/Store/DBIC.pm
PANIC!!! So, the gentoo overlay installation is altered like: dev-perl/Catalyst-Authentication-Store-DBIx-Class !dev-perl/Catalyst-Plugin-Authentication-Store-DBIx-Class !dev-perl/Catalyst-Plugin-Authentication-Store-DBIC Okay... no more 'Plugin' or 'DBIC' anymore, it seems. Then I did find this: http://cpan.uwinnipeg.ca/htdocs/Catalyst-Authentication-Store-DBIx-Class/Catalyst/Authentication/Store/DBIx/Class.html And, I try to change a couple of items in the configs, like so: authentication => { default_realm => 'members', realms => { members => { credential => { class => 'Password', password_field => 'password', password_type => 'clear' }, store => { class => 'DBIx::Class', user_class => 'MyAppDB::Users', id_field => 'user_id', role_relation => 'userroles', role_field => 'role_name', } ... to mimic what is in that doco. Caught exception in BanTrace::Controller::Login->index "The user object Catalyst::Authentication::Store::DBIx::Class::User=HASH(0x9469e70) does not support any known password authentication mechanism.,, ...here: 35: if ($username && $password) { 36: 37: # Attempt to log the user in 38: if ($c->login($username, $password)) { WTF My application is configured exactly like the tutorial... used to be written?? No. It still looks like: Authentication::Store::DBIC And that Plugin:: isn't part of the installation now... this _can't_ be okay, no? Alright, so this is the new 'login' method, 'authenticate'? 37: # Attempt to log the user in 38: # if ($c->login($username, $password)) { 39: if ($c->authenticate($username, $password)) { Caught exception in BanTrace::Controller::Login->index "authenticate called with nonexistant realm: 'MYPASSWORD'? Ouch! Oh, with a hashref, now: # if ($c->login($username, $password)) { if ($c->authenticate({username => $username, password => $password})) So now I'm in... sort of. Other parts are broken... if ($c->check_user_roles('admin')) { ... didn't seem to fly. Now, I'm stuck. That method comes from, I think, ::DBIC ... what's the new way? Fortunately, in this app, if you are not 'admin' you must be a user... but I'd like to have my ROLE back!!! Any help really, really appreciated. '-) Cheers, -- |\ /|| | ~ ~ | \/ ||---| `|` ? ||ichael | |iggins\^ / michael.higgins[at]evolone[dot]org ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Can't locate Catalyst/Plugin/Authentication/Store/DBIC.pm
Hi Michael, Unfortunately the Tutorial is a bit out of date. Please look at this: http://search.cpan.org/~jayk/Catalyst-Plugin-Authentication/lib/Catalyst/Plugin/Authentication.pm and this: http://search.cpan.org/~jayk/Catalyst-Authentication-Store-DBIx-Class/lib/Catalyst/Authentication/Store/DBIx/Class.pm and your issues should be cleared up. Jay On Dec 17, 2007, at 7:07 PM, Michael Higgins wrote: PANIC!!! So, the gentoo overlay installation is altered like: dev-perl/Catalyst-Authentication-Store-DBIx-Class !dev-perl/Catalyst-Plugin-Authentication-Store-DBIx-Class !dev-perl/Catalyst-Plugin-Authentication-Store-DBIC Okay... no more 'Plugin' or 'DBIC' anymore, it seems. Then I did find this: http://cpan.uwinnipeg.ca/htdocs/Catalyst-Authentication-Store-DBIx-Class/Catalyst/Authentication/Store/DBIx/Class.html And, I try to change a couple of items in the configs, like so: authentication => { default_realm => 'members', realms => { members => { credential => { class => 'Password', password_field => 'password', password_type => 'clear' }, store => { class => 'DBIx::Class', user_class => 'MyAppDB::Users', id_field => 'user_id', role_relation => 'userroles', role_field => 'role_name', } ... to mimic what is in that doco. Caught exception in BanTrace::Controller::Login->index "The user object Catalyst::Authentication::Store::DBIx::Class::User=HASH(0x9469e70) does not support any known password authentication mechanism.,, ...here: 35: if ($username && $password) { 36: 37: # Attempt to log the user in 38: if ($c->login($username, $password)) { WTF My application is configured exactly like the tutorial... used to be written?? No. It still looks like: Authentication::Store::DBIC And that Plugin:: isn't part of the installation now... this _can't_ be okay, no? Alright, so this is the new 'login' method, 'authenticate'? 37: # Attempt to log the user in 38: # if ($c->login($username, $password)) { 39: if ($c->authenticate($username, $password)) { Caught exception in BanTrace::Controller::Login->index "authenticate called with nonexistant realm: 'MYPASSWORD'? Ouch! Oh, with a hashref, now: # if ($c->login($username, $password)) { if ($c->authenticate({username => $username, password => $password})) So now I'm in... sort of. Other parts are broken... if ($c->check_user_roles('admin')) { ... didn't seem to fly. Now, I'm stuck. That method comes from, I think, ::DBIC ... what's the new way? Fortunately, in this app, if you are not 'admin' you must be a user... but I'd like to have my ROLE back!!! Any help really, really appreciated. '-) Cheers, -- |\ /|| | ~ ~ | \/ ||---| `|` ? ||ichael | |iggins\^ / michael.higgins[at]evolone[dot]org ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/ Dev site: http://dev.catalyst.perl.org/ --- "Those who can make you believe absurdities can make you commit atrocities." --Voltaire ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Can't locate Catalyst/Plugin/Authentication/Store/DBIC.pm
On Mon, 17 Dec 2007 20:47:20 -0700 Jay K <[EMAIL PROTECTED]> wrote: > Hi Michael, > > Unfortunately the Tutorial is a bit out of date. > > Please look at this: > > http://search.cpan.org/~jayk/Catalyst-Plugin-Authentication/lib/Catalyst/Plugin/Authentication.pm > > and this: > > http://search.cpan.org/~jayk/Catalyst-Authentication-Store-DBIx-Class/lib/Catalyst/Authentication/Store/DBIx/Class.pm > > and your issues should be cleared up. > > Jay Thanks, Jay! Cheers, -- |\ /|| | ~ ~ | \/ ||---| `|` ? ||ichael | |iggins\^ / michael.higgins[at]evolone[dot]org ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Can't locate Catalyst/Plugin/Authentication/Store/DBIC.pm
On Mon, 17 Dec 2007 20:09:23 -0800 Michael Higgins <[EMAIL PROTECTED]> wrote: > On Mon, 17 Dec 2007 20:47:20 -0700 > Jay K <[EMAIL PROTECTED]> wrote: > > > Hi Michael, > > > > Unfortunately the Tutorial is a bit out of date. > > > > Please look at this: > > > > http://search.cpan.org/~jayk/Catalyst-Plugin-Authentication/lib/Catalyst/Plugin/Authentication.pm > > > > and this: > > > > http://search.cpan.org/~jayk/Catalyst-Authentication-Store-DBIx-Class/lib/Catalyst/Authentication/Store/DBIx/Class.pm > > > > and your issues should be cleared up. > > > > Jay > > Thanks, Jay! > > Cheers, > So, the question I'd left off with was, basically, what's up with if ( $c->check_user_roles( 'editor' ) ) { # do editor stuff } I have a feeling that, since my roles are in a separate table, like '1' is user, '2' is admin -- again, from that out of date tutorial -- that this isn't going to work as expected, somehow. from /Catalyst/Authentication/Store/DBIx/Class.pm "If your role information is stored in the same table as the rest of your user information"... Mine is not. Then, it reads about role_field, "This is the name of the field in the role table that contains the string identifying the role". I think that string for me is, like '1', because that is the role_id. But, it looks like this should retrieve the id then return the name of the role for matching... right? +-+---+ | role_id | role_name | +-+---+ | 1 | user | | 2 | admin | | 3 | guest | +-+---+ Maybe I need a different accessor, IDK. What I do know is it 'just worked' and that's why I used Catalyst. Now, I'm wholly out of my depth. I've continued now for another hour or so. It sure does seem like this isn't going to work. Do I need to change my data tables in order to use this now? role_field => 'role_id', ... gives me: SELECT me.user_id, me.username, me.password, me.email_address, me.first_name, me.last_name, me.bill2 FROM users me WHERE ( user_id = ? ): '1' Great, found the 'admin'. SELECT me.role_id FROM user_roles me WHERE ( me.user_id = ? ): '1' Caught exception in BanTrace::Controller::Shipments->list "Missing roles: admin at $c->log->debug($c->assert_user_roles('admin')); [debug] Role granted: 2 [debug] 1 [debug] Role denied: admin Whereas: role_field => 'role_name', Gives me nothing at all. Never tries to check if I've got a role. ACL rules are in effect as well?? What do I need to do to back out of the basic tutorial setup, and get this working again? I have to think that this information would only be helpful to others, no? Or am I the only one who based an application on the tutorial? '-) Do I go about redefining my 'roles' as '1', '2', '3'?? Or do I have to change my database configuration? Or, am I barking up the wrong tree? Cheers, -- |\ /|| | ~ ~ | \/ ||---| `|` ? ||ichael | |iggins\^ / michael.higgins[at]evolone[dot]org ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Can't locate Catalyst/Plugin/Authentication/Store/DBIC.pm
On Mon, 17 Dec 2007 21:03:52 -0800 Michael Higgins <[EMAIL PROTECTED]> wrote: > On Mon, 17 Dec 2007 20:09:23 -0800 > Michael Higgins <[EMAIL PROTECTED]> wrote: > > > On Mon, 17 Dec 2007 20:47:20 -0700 > > Jay K <[EMAIL PROTECTED]> wrote: > > > > > Hi Michael, > > > > > > Unfortunately the Tutorial is a bit out of date. [8<] > Do I go about redefining my 'roles' as '1', '2', '3'?? Or do I have to > change my database configuration? . . . [reply to self again] Okay, it appears as if the join table is no longer needed? (I don't know why it was needed before, but it's part of the tutorial, IIRC.) So, I have a table "users" and "user_roles". First table is user information with a user_id. Second table is user_id and role_name. My role_id column and 'roles' table are probably both superfluous now? __PACKAGE__->belongs_to(user => 'MyAppDB::Users', 'user_id'); __PACKAGE__->has_many(map_user_roles => 'MyAppDB::UserRoles', 'user_id'); Is that _really_ all that's required? Anyway, I -- perhaps prematurely asserted -- think I've figured this out. Cheers, -- |\ /|| | ~ ~ | \/ ||---| `|` ? ||ichael | |iggins\^ / michael.higgins[at]evolone[dot]org ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Can't locate Catalyst/Plugin/Authentication/Store/DBIC.pm
On Dec 18, 2007, at 2:04 AM, Michael Higgins wrote: On Mon, 17 Dec 2007 21:03:52 -0800 Michael Higgins <[EMAIL PROTECTED]> wrote: On Mon, 17 Dec 2007 20:09:23 -0800 Michael Higgins <[EMAIL PROTECTED]> wrote: On Mon, 17 Dec 2007 20:47:20 -0700 Jay K <[EMAIL PROTECTED]> wrote: Hi Michael, Unfortunately the Tutorial is a bit out of date. [8<] Do I go about redefining my 'roles' as '1', '2', '3'?? Or do I have to change my database configuration? . . . [reply to self again] Okay, it appears as if the join table is no longer needed? (I don't know why it was needed before, but it's part of the tutorial, IIRC.) So, I have a table "users" and "user_roles". First table is user information with a user_id. Second table is user_id and role_name. My role_id column and 'roles' table are probably both superfluous now? __PACKAGE__->belongs_to(user => 'MyAppDB::Users', 'user_id'); __PACKAGE__->has_many(map_user_roles => 'MyAppDB::UserRoles', 'user_id'); Is that _really_ all that's required? T he way you had it will still work too, as long as you also have a many_to_many relationship that maps across the join table... package MyAppDB::Role; __PACKAGE__->columns(qw( id name )); package MyAppDB::UserRole; __PACKAGE__->belongs_to( 'user', 'MyAppDB::User', 'user_id' ); __PACKAGE__->belongs_to( 'role', 'MyAppDB::Role', 'role_id' ); package MyAppDB::User; __PACKAGE__->has_many( 'map_user_roles', 'MyAppDB::UserRole', 'user_id' ); __PACKAGE__->many_to_many( 'user_roles', 'map_user_roles', 'role' ); And then in your configuration... authentication: realms: default: store: role_relation: user_roles role_field: name As you can see, role_relation needs to be a relationship that returns MyAppDB::Role objects, if you tell it to use map_user_roles, it is going to get MyAppDB::UserRole objects instead, and role_field is the name of the field in MyAppDB::Role that contains the name of the role. So when you say __PACKAGE__->assert_user_role(qw( admin )); What's happening behind the scenes is something like this: # These actually come from the configuration... my $role_relation = 'user_roles'; my $role_field = 'name'; for my $role ( $c->user->$role_relation() ) { if ( $role->$role_field() eq 'admin' ) { return 1 } } -- Jason Kohles, RHCA RHCDS RHCE [EMAIL PROTECTED] - http://www.jasonkohles.com/ "A witty saying proves nothing." -- Voltaire ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Can't locate Catalyst/Plugin/Authentication/Store/DBIC.pm
On Wed, 19 Dec 2007 16:47:33 -0500 Jason Kohles <[EMAIL PROTECTED]> wrote: > On Dec 18, 2007, at 2:04 AM, Michael Higgins wrote: > > > On Mon, 17 Dec 2007 21:03:52 -0800 > > Michael Higgins <[EMAIL PROTECTED]> wrote: > > > >> On Mon, 17 Dec 2007 20:09:23 -0800 > >> Michael Higgins <[EMAIL PROTECTED]> wrote: > >> > >>> On Mon, 17 Dec 2007 20:47:20 -0700 > >>> Jay K <[EMAIL PROTECTED]> wrote: > >>> > Hi Michael, > > Unfortunately the Tutorial is a bit out of date. > > > > [8<] > > > >> Do I go about redefining my 'roles' as '1', '2', '3'?? Or do I > >> have to > >> change my database configuration? > > > > . . . [reply to self again] > > > > Okay, it appears as if the join table is no longer needed? (I don't > > know why it was needed before, but it's part of the tutorial, IIRC.) > > > > So, I have a table "users" and "user_roles". First table is user > > information with a user_id. Second table is user_id and role_name. > > My role_id column and 'roles' table are probably both superfluous > > now? > > > > __PACKAGE__->belongs_to(user => 'MyAppDB::Users', 'user_id'); > > > > __PACKAGE__->has_many(map_user_roles => 'MyAppDB::UserRoles', > > 'user_id'); > > > > Is that _really_ all that's required? > > > T > he way you had it will still work too, as long as you also have a > many_to_many relationship that maps across the join table... > > package MyAppDB::Role; > __PACKAGE__->columns(qw( id name )); > > package MyAppDB::UserRole; > __PACKAGE__->belongs_to( 'user', 'MyAppDB::User', 'user_id' ); > __PACKAGE__->belongs_to( 'role', 'MyAppDB::Role', 'role_id' ); > > package MyAppDB::User; > __PACKAGE__->has_many( 'map_user_roles', 'MyAppDB::UserRole', > 'user_id' ); > __PACKAGE__->many_to_many( 'user_roles', 'map_user_roles', 'role' ); > > And then in your configuration... > authentication: >realms: > default: >store: > role_relation: user_roles > role_field: name > > As you can see, role_relation needs to be a relationship that > returns MyAppDB::Role objects, if you tell it to use map_user_roles, > it is going to get MyAppDB::UserRole objects instead, and role_field > is the name of the field in MyAppDB::Role that contains the name of > the role. > > So when you say __PACKAGE__->assert_user_role(qw( admin )); > > What's happening behind the scenes is something like this: > > # These actually come from the configuration... > my $role_relation = 'user_roles'; > my $role_field = 'name'; > for my $role ( $c->user->$role_relation() ) { > if ( $role->$role_field() eq 'admin' ) { return 1 } > } > > Wow, thanks for that. There is no way I could have figured that out. I'll keep this and revisit the files, I'm sure. Cheers, -- |\ /|| | ~ ~ | \/ ||---| `|` ? ||ichael | |iggins\^ / michael.higgins[at]evolone[dot]org ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/ Dev site: http://dev.catalyst.perl.org/