1 package Catalyst::Plugin::Authentication::Credential::TypeKey;
18 sub authenticate_typekey {
19 my ( $c, $email, $name, $nick, $ts, $sig, $options ) = @_;
21 unless ( @_ == 6 || ( @_ == 7 && ref($options) eq 'HASH' ) ) {
22 Carp::croak('usage: $c->authenticate_typekey( $email, $name, $nick, $ts, $sig [, \%options ] )');
29 my $config = $c->config->{authenticate}->{typekey};
31 my $token = $options->{token} || $config->{token} || undef;
32 my $expires = $options->{expires} || $config->{expires} || 0;
33 my $version = $options->{version} || $config->{version} || 1.1;
34 my $cache = $options->{cache} || $config->{cache} || File::Spec->catfile( File::Spec->tmpdir, 'regkeys.txt' );
35 my $keys = $options->{keys} || $config->{keys} || 'http://www.typekey.com/extras/regkeys.txt';
37 my $typekey = Authen::TypeKey->new;
38 $typekey->expires($expires);
39 $typekey->key_cache($cache);
40 $typekey->key_url($keys);
41 $typekey->token($token);
42 $typekey->version($version);
52 unless ( $typekey->verify($parameters) ) {
53 my $error = $typekey->errstr;
54 $c->log->debug(qq/Failed to authenticate user '$name'. Reason: '$error'/);
58 $c->log->debug( qq/Successfully authenticated user '$name'./);
68 Catalyst::Plugin::Authentication::Credential::TypeKey - TypeKey Authentication
72 use Catalyst qw[Authentication::Credential::TypeKey];
74 MyApp->config->{authenticate}->{typekey} = {
75 token => 'xxxxxxxxxxxxxxxxxxxx'
78 if ( $c->authenticate_typekey( $email, $name, $nick, $ts, $sig ) ) {
79 # successful autentication
84 TypeKey Authentication.
88 L<Authen::TypeKey>, L<Catalyst>.
92 Christian Hansen, C<ch@ngmedia.com>
96 This library is free software . You can redistribute it and/or modify it under
97 the same terms as perl itself.