[Catalyst] "no role configuration found" -- authorization: dbic and
DBI::Schema::Loader
Ashley Pond V
apv at sedition.com
Fri Dec 14 21:08:16 GMT 2007
I can't get roles to work with an dynamic (Schema::Loader) set of
models. I am doing all the config in YAML, none in the App.pms.
Authentication *is* working. Authorization is throwing this:
Caught exception in MyApp::Controller::Thingy->add "user->roles
+ accessed, but no role configuration found at
+ /usr/lib/perl5/site_perl/5.8.8/Catalyst/Plugin/Authorization/Roles
+ .pm line 109"
What am I doing wrong (yml and tables below)? Anything obvious? I
have played around with the config quite a bit (fully qualified model
names, not, combinations of vars). I have no "map_user_role" b/c it's
dynamic Schema::Loader. Do I have to have it? I really want (need for
the short term) to do Schema::Loader dynamically.
Thanks!
-Ashley
Config ---------------------
authentication:
default_realm: users
realms:
users:
credential:
class: Password
password_field: password
password_type: hashed
password_hash_type: SHA-1
store:
class: DBIx::Class
user_class: User
id_field: username
authorization:
dbic:
role_class: Role
user_class: User
role_field: name
role_rel: UserRole
user_role_user_field: user
user_role_role_field: role
Tables -------------------
CREATE TABLE user (
`id` int unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
`username` varchar(50) NOT NULL UNIQUE,
`password` varchar(50) NOT NULL
);
-- Add some users...
CREATE TABLE `role` (
`id` int unsigned NOT NULL auto_increment,
`name` VARCHAR(80) NOT NULL UNIQUE,
`description` TEXT NULL,
`created` datetime NOT NULL,
`updated` timestamp NOT NULL default CURRENT_TIMESTAMP on update
CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `role` VALUES (NULL, "admin", "", NOW(), NULL);
INSERT INTO `role` VALUES (NULL, "tracker_admin", "", NOW(), NULL);
INSERT INTO `role` VALUES (NULL, "employee", "", NOW(), NULL);
INSERT INTO `role` VALUES (NULL, "student", "", NOW(), NULL);
INSERT INTO `role` VALUES (NULL, "test", "", NOW(), NULL);
CREATE TABLE `user_role` (
`id` int unsigned NOT NULL auto_increment,
`user` int unsigned NOT NULL,
`role` int unsigned NOT NULL,
`created` datetime NOT NULL,
`updated` timestamp NOT NULL default CURRENT_TIMESTAMP on update
CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
FOREIGN KEY (`user`) REFERENCES user(id),
FOREIGN KEY (`role`) REFERENCES role(id)
) ENGINE=InnoDB;
-- add some user_roles...
More information about the Catalyst
mailing list