[Catalyst] Dynamic Authentication::Credential::? usage.
Bryan Allen
bda at mirrorshades.net
Thu Jan 5 10:21:44 CET 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Has anyone tried dynamically loading credentials with the new auth
plugins?
The app I'm writing has some local administrative users which won't
exist in our (global-ish) LDAP database (or in our AD, etc). It also
allows users to set local (application) passwords if they don't like
the idea of single sign-on. Application admin users have their
passwords set locally, and need to auth against using
Credential::Password. Everyone else needs to use _check_password from
Credential::LdapBindPassword.
_create_local_account() checks to see if a user has an account in one
of these external databases (which I only want to use for password
checking), and if so it creates them a local account in which to
store their preferences, history, etc.
I'm guessing either some NEXT magicks are required (but a few minutes
of fiddling didn't avail me much) in Credential::*Password or what I
really want is a _check_ldap_password() in C::Password ($c->login
(mech=>'ldap'))?
Some squiggly code to detail what I'd like to do with what's available:
package MyApp::Controller::Auth;
sub login : Local {
my ( $self, $c ) = @_;
if ($c->req->param('username') && $c->req->param('password')) {
my $local_account = $self->_create_local_account($c);
if ($local_account) {
if ($local_account->password) {
$c->log->debug("[login] Checking local password.");
# somehow use
Catalyst::Plugin::Authentication::Credential::Password
}
else {
$c->log->debug("[login] Checking LDAP password.");
# somehow use
Catalyst::Plugin::Authentication::Credential::LdapBindPassword
}
$c->login( $c->req->param('username'), $c->req->param
('password') )
or
$c->stash->{msg} = 'Could not log you in.';
}
else {
$c->stash->{msg} = "You don't appear to have an account.";
}
}
if ($c->user_exists) {
$c->res->redirect($c->req->base);
}
}
- --
Bryan Allen
bda at mirrorshades.net
http://bda.mirrorshades.net
Cyberpunk is dead. Long live cyberpunk.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)
iD8DBQFDvOUt8DRlpnH/NmoRArAdAKCUqu9yuaLX74oStZsBZGL/o+VKjACgg4GS
kK9VYiP13SSWvNbNtBf3Iog=
=zlKd
-----END PGP SIGNATURE-----
More information about the Catalyst
mailing list