Hi,

I have implemented such an authentication sheme. I'm rather new to catalyst
so I do not pretend it si the best way.
Anyway what I've done is :

1) add the session and authentication plugins to catalyst app:

use Catalyst qw/...
Authentication
Session
Session::Store::FastMmap
Session:State::Cookie
...

2) write a custom Authentication plugin, the your specific code is in
_authenticate_against_SGDB

package Serono::Gecko::Business::CredentialVerifier;

use Catalyst::Plugin::Authentication::User::Hash;

sub authenticate {
    my ( $self, $c, $realm, $authinfo ) = @_;

    my $schema = $c->model('DB') or confess "unable to get schema";
    my $username = $authinfo->{username} || "";
    my $password = $authinfo->{password} || "";

    my $user = $self->_authenticate_against_SGDB($schema, $username,
$password );
    if ($user) {
        $c->log->debug( "authentication successful in  " . __PACKAGE__ );
        my $user_store = Catalyst::Plugin::Authentication::User::Hash->new(
id => $user->user_id, username => $username,
             password => $password);
        return $user_store;
    }

    $c->log->debug(
        "Unable to locate user matching user info provided in " .
__PACKAGE__ );
    return;
}


3) configure it through the catalyst config file

<authentication>
        default_realm dbic
    <realms>
        <dbic>
            <credential>
                    class +Serono::Gecko::Business::CredentialVerifier
            </credential>
            <store>
                    class DBIx::Class
                    user_class DB::GeckoUserInfo
            </store>
        </dbic>
    </realms>
</authentication>

4) I use Root::auto to implement pass-through login and DB reconnection on
authenticated user if needed.

The only problem is that I encountered a bug with DBD::Oracle (I think),
that do not allow me to disconnect then reconnect, even DBI->connect (see my
previous post on this list).


On Wed, Mar 18, 2009 at 4:51 PM, Adam Witney <[email protected]> wrote:

>
> Hi,
>
> Our database uses actual database users rather than a table containing
> usernames and password. How would I authenticate against the database
> itself? The examples I have come across in the Tutorial and various
> Catalyst::Authentication::* modules all seem to require the presence of a
> table containing username and password fields.
>
> I guess I could write my own authenticate method that performed a manual
> dbh connection somehow... but I was wondering if there was a more
> standard/recommended way to do this?
>
> thanks for any help
>
> adam
>
> _______________________________________________
> List: [email protected]
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/[email protected]/
> Dev site: http://dev.catalyst.perl.org/
>
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to