[Maypole] Maypole Auth Oddity
Christopher Hicks
chicks@chicks.net
Sun, 27 Feb 2005 13:26:12 -0500 (EST)
On Sun, 27 Feb 2005, Dave Howorth wrote:
> The most relevant bit of the source code is the line where the error occurred
> and immediately above it.
I've read it a few times and the relevance is still unclear to me.
> M-P-A-UserSessionCookie needs various values in config->auth that match
> your actual configuration.
But shouldn't those be provided my M-P-Authorization?
> The line that failed was trying to invoke CDBI's search method on a
> model class and the name of that model class is fetched from
> config->auth a few lines above.
I understand that..
> So I would guess you haven't set the auth configuration, in particular
> the user_class key.
http://search.cpan.org/~djh/Maypole-Plugin-Authorization-0.05/lib/Maypole/Plugin/Authorization.pm
doesn't mention that.
> There's a Configuration section in the UserSessionCookie doc that
> explains what it needs. M-P-Authorization will use the same user_class
> key to determine a class for its purposes, when your code gets far
> enough to call it.
Alright I added Loader into my use Maypole::Application line and then I
created a model class for the MPA users table:
FINI::FiniLever::Maypole::Users->untaint_columns(
printable => [qw( name UID )],
);
package FINI::FiniLever::Maypole::Users;
sub display_columns {
return qw( name id UID );
}
and then I modified authenticate() to use it:
sub authenticate {
my ($self, $r) = @_;
$r->get_user;
FINI::FiniLever::Maypole->config->auth->{user_class} = 'FINI::FiniLever::Maypole::Users';
if ($self->authorize($r)) {
return OK;
} else {
# take application-specific authorization failure action
$r->{template} = 'login';
return 0;
}
}
and I still get the error:
caught authenticate error: Can't locate object method "search" via package
"FINI::FiniLever::Maypole::User" (perhaps you forgot to load
"FINI::FiniLever::Maypole::User"?) at
/usr/lib/perl5/site_perl/5.8.3/Maypole/Plugin/Authentication/UserSessionCookie.pm
line 147., referer: http://www.finilever.com/cgi/test/frontpage
Why!? I told it that the user class was Users and it still tried to use
User! Grrr.
--
</chris>
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)