[Catalyst] Need some help with Authorization setup
kakimoto at tpg.com.au
kakimoto at tpg.com.au
Tue May 12 03:08:45 GMT 2009
hi, guys,
I got some concerns about the Autorization modules for Catalyst.
What I have checked:
====================
1) Looked at the tutes for Authentication and Authorization:
http://search.cpan.org/~hkclark/Catalyst-Manual-5.7021/lib/Catalyst/Manual/Tutorial/Authentication.pod
http://search.cpan.org/~hkclark/Catalyst-Manual-5.7021/lib/Catalyst/Manual/Tutorial/Authorization.pod
2) looked at the cookbook:
http://search.cpan.org/~hkclark/Catalyst-Manual-5.7021/lib/Catalyst/Manual/Cookbook.pod#___top
3) Looked at the perldoc for
Catalyst::Authentication::Store::DBIx::Class
http://search.cpan.org/~jayk/Catalyst-Authentication-Store-DBIx-Class-0.1082/lib/Catalyst/Authentication/Store/DBIx/Class.pm
Any calls made to 'check_user_roles' doesn't work in my application. I
followed the tute with some minor changes
Questions:
==========
Referring to the perldoc for
Catalyst::Authentication::Store::DBIx::Class
*) 'user_role_user_field' => 'user'
That doesn't come with any description. Is that meant for a
authentication &
authorisation similar to the tute (as in there are 3 database
tables: User,
Role and UserRole ) ?
Referring to the cookbook on 'Role-based Authorization
(configuration section)
-----------------Extract from configuration section - START
----------------------
__PACKAGE__->config->{authentication} =
{
default_realm => 'members',
realms => {
members => {
credential => {
# ...
},
store => {
class => 'DBIx::Class',
user_model => 'MyApp::User',
role_relation => 'roles',
role_field => 'rolename',
ignore_fields_in_find => [
'remote_name' ],
use_userdata_from_session => 1,
}
}
}
};
-----------------Extract from configuration section - END
----------------------
Assuming the following databases, I find myself lost.
Database table: Users
=====================
Table "public.users"
Column | Type |
Modifiers
--------------------+-----------------------------+----------------------------------------------------
id | integer | not null
default nextval('users_id_seq'::regclass)
password | text | not null
first_name | text |
last_name | text |
active | integer |
main_contact_id | integer |
company_name | text |
billing_details_id | integer |
billing_address_id | integer |
created_by | character varying(12) |
updated_by | character varying(12) |
created_on | timestamp without time zone |
updated_on | timestamp without time zone |
login_id | character varying(20) | not null
abn | text |
Indexes:
"users_pkey" PRIMARY KEY, btree (id)
"unique_login_id" UNIQUE, btree (login_id)
Relationships:
==============
__PACKAGE__->has_many( 'map_user_role' =>
'myApp::Schema::UserRoles', 'user_id');
Database table: user_roles
==========================
Table "public.user_roles"
Column | Type | Modifiers
---------+---------+-----------
user_id | integer | not null
role_id | integer | not null
Indexes:
"user_roles_pkey" PRIMARY KEY, btree (user_id, role_id)
Relationships:
==============
__PACKAGE__->belongs_to( 'user' => 'myApp::Schema::Users',
'user_id');
__PACKAGE__->belongs_to( 'role' => 'myApp::Schema::Roles',
'role_id');
Database table: roles
=======================
Table "public.roles"
Column | Type | Modifiers
--------+---------+----------------------------------------------------
id | integer | not null default
nextval('roles_id_seq'::regclass)
role | text |
Indexes:
"roles_pkey" PRIMARY KEY, btree (id)
Relationships:
==============
__PACKAGE__->has_many(map_user_role =>
'myApp::Schema::UserRoles', 'role_id');
Notes:
-------
My model files are stored in 'projects/myApp/lib/myApp/Schema' and
hence their package names start with 'myApp::Schema'.
Here's what I set and the where I am stuck. Need your help :)
*) user_model - I would set this to 'myApp::Schema::Users'.
*) role_column - My role information is not stored in the
same database
table as the source of User information. I
am leaving
this blank.
*) role_relation - Now, following the Catalyst Authentication
tute,
there are 3 tables. I would set this to
point to
the 'user_roles' database table hence it
will be
'map_user_roles'.
*) role_field - I would set this to 'role' but the question is,
how does Catalyst know that the 'Roles'
database
table stores all the roles? Is it implied
via the
relationships set up in the model/schema files?
Thank you.
K. akimoto
More information about the Catalyst
mailing list