Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Catalyst::Plugin::Authorization -- dont have "role_rel" for one table

by madison.sacd (Novice)
on May 09, 2007 at 08:17 UTC ( [id://614320]=perlquestion: print w/replies, xml ) Need Help??

madison.sacd has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

I am trying to use Catalyst::PluginAuthorization modules. However, according to Catalyst tutorial on CPAN, it seems that I must have 2 tables in database, one for user and one for roles.

My question is that I just have one table which contains user accounts, passwords and roles all together. Therefore, I cannot follow the yml file settings in tutorial as below code. Especially the line role_rel: map_user_role which indicates the relationship between user table and role table. Please give me some hints about how should I do to fix the setting. Thanks.
authentication: dbic: user_class: MyappDB::User user_field: username password_field: password password_type: clear authorization: dbic: role_class: MyAppDB::User role_field: role role_rel: map_user_role user_role_user_field: user_id
  • Comment on Catalyst::Plugin::Authorization -- dont have "role_rel" for one table
  • Download Code

Replies are listed 'Best First'.
Re: Catalyst::Plugin::Authorization -- dont have "role_rel" for one table
by Herkum (Parson) on May 09, 2007 at 11:37 UTC
    While Catalyst is written using Perl it is a very specific set of software. You would probably be better off asking your question on the Catalyst Mailing Lists rather than here.

Re: Catalyst::Plugin::Authorization -- dont have "role_rel" for one table
by jasonk (Parson) on May 09, 2007 at 16:06 UTC

    As I see it you have several options

    In the end though, you can't simply change the configuration and expect it to work, the module you are trying to use expects a specific table structure which you don't have. You could just not use it and do the role checking manually though...

    package MyApp; sub check_role { my ( $c, $role ) = @_; return 1 if ( $user && $c->user->obj->role eq $role ); return 0; } sub assert_role { my ( $c, $role ) = @_; if ( ! $c->check_role( $role ) ) { $c->detach( '/access_denied' ); } } package MyApp::Controller::Root; sub auto : Private { my ( $self, $c ) = @_; $c->stash->{ 'is_admin' } = $c->check_role( 'Admin' ); return 1; } package MyApp::Controller::Admin; sub auto : Private { my ( $self, $c ) = @_; $c->assert_role( 'Admin' ); return 1; }

    We're not surrounded, we're in a target-rich environment!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://614320]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2025-11-12 00:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (68 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.