[cgiapp] Saving Data From Authentication Phase
adam at spatialsystems.org
adam at spatialsystems.org
Tue Jan 8 14:32:50 EST 2008
When I try that in the login coderef passed to the CGI::Application::Plugin::Authentication, I get an error about $self not being an explicit package name. They only thing that gets passed to the coderef is the username and password, not $self. I don't see a way to save the AD data to the session from within the \&my_login coderef.
Is there a way to store this into the session without modifying CGI::Application::Plugin::Authorization::Driver::Generic to get $self into the auth coderef?
sub setup {
# setup authentication
$self->authen->config(
# here we send coderef \&my_login for login
DRIVER => [ 'Generic', \&my_login ],
STORE => 'Session',
LOGIN_RUNMODE => 'login',
POST_LOGIN_RUNMODE => 'main',
LOGOUT_RUNMODE => 'login',
);
}
sub my_login {
my ($username, $password) = @_;
my $ad_auth = MyCompany::ActiveDirectory->new('WINDOWS');
return 0 if not $ad_auth->login( $username, $password );
# how do I store this info in the hash ref so I always have it???
$users_hash_ref = $ad_auth->getUserInfo;
# if I try to store it here using the session, $self doesn't exist
# and I don' see a way to get it to exist unless I modify
# CGI::Application::Plugin::Authorization::Driver::Generic.
# I'm wondering if there's a differnt way to do this without
# modifying the driver
# doesn't work, $self not here.
#$self->session->param( ad_auth_userinfo => $ad_auth->getUserInfo );
return 1;
}
>-------- Original Message --------
>Subject: Re: [cgiapp] Saving Data From Authentication Phase
>From: Rhesa Rozendaal <perl at rhesa.com>
>Date: Tue, January 08, 2008 12:42 pm
>To: CGI Application <cgiapp at lists.openlib.org>
>
>adam at spatialsystems.org wrote:
>> How can I save this hashref ( $users_hash_ref = $ad_auth->getUserInfo ) of user info and keep it in my Session for all requests where the user is logged in?
>
>Isn't that the usual:
>
># store it inside &my_login
>$self->session->param( ad_auth_userinfo => $ad_auth->getUserInfo );
>
># use it elsewhere
>my $userinfo = $self->session->param( 'ad_auth_userinfo' );
>
>
>> Here is some of my code:
>>
>> sub setup {
>>
>> # setup authentication
>> $self->authen->config(
>> DRIVER => [ 'Generic', \&my_login ],
>> STORE => 'Session',
>> LOGIN_RUNMODE => 'login',
>> POST_LOGIN_RUNMODE => 'main',
>> LOGOUT_RUNMODE => 'login',
>> );
>>
>> }
>
>CAP::Authentication also has a authen->username method that you might be able
>to use. It won't have all your AD info, of course, but it might be enough for
>your application.
>
>HTH,
>Rhesa
>
More information about the cgiapp
mailing list