[Maypole] Maypole Auth Oddity
Dave Howorth
Dave.Howorth@acm.org
Sun, 27 Feb 2005 22:28:59 +0000
Christopher Hicks wrote:
> 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.
Sorry, I just meant that when anything causes a fatal error, that's the
place to start looking for the problem, and most often the source of the
problem is in its preconditions that are set up just before.
>> 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?
No, why? You're using UserSessionCookie to do authentication and
authentication is failing because you haven't configured it.
Authentication does not depend on Authorization in any way.
I have to admit that one of the problems of component-based software
from multiple sources is the need to understand each of the components.
And Maypole has lots of components.
>> 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.
It's documented in the Authentication module, which is where your error
occurred. I'll add a pointer to it for the next release of the
Authorization, though, thanks.
<snip>
> 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.
You need to configure it BEFORE you use it :) Specifically, the call to
get_user calls check_credentials which is what's failing (this should be
showing up in the rest of the error log that you've snipped) and your
config setting is after that, so it isn't set when get_user is called.
You should put:
FINI::FiniLever::Maypole->config->auth({
user_class => 'FINI::FiniLever::Maypole::Users'
});
as static code in your driver class, not in the authenticate sub. Put it
in the same place as your uri_base, template_root, rows_per_page etc
config statements.
Cheers, Dave
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 266.5.0 - Release Date: 25/02/05