1 package Catalyst::Plugin::Authenticate::TypeKey;
10 sub authenticate_typekey {
11 my ( $c, $email, $name, $nick, $ts, $sig, $options ) = @_;
13 unless ( @_ == 6 || ( @_ == 7 && ref($options) eq 'HASH' ) ) {
14 Carp::croak('usage: $c->authenticate_typekey( $email, $name, $nick, $ts, $sig [, \%options ] )');
21 my $config = $c->config->{authenticate}->{typekey};
23 my $token = $options->{token} || $config->{token} || undef;
24 my $expires = $options->{expires} || $config->{expires} || 0;
25 my $version = $options->{version} || $config->{version} || 1.1;
26 my $cache = $options->{cache} || $config->{cache} || File::Spec->catfile( File::Spec->tmpdir, 'regkeys.txt' );
27 my $keys = $options->{keys} || $config->{keys} || 'http://www.typekey.com/extras/regkeys.txt';
29 my $typekey = Authen::TypeKey->new;
30 $typekey->expires($expires);
31 $typekey->key_cache($cache);
32 $typekey->key_url($keys);
33 $typekey->token($token);
34 $typekey->version($version);
44 unless ( $typekey->verify($parameters) ) {
45 my $error = $typekey->errstr;
46 $c->log->debug(qq/Failed to authenticate user '$name'. Reason: '$error'/);
50 $c->log->debug( qq/Successfully authenticated user '$name'./);
60 Catalyst::Plugin::Authenticate::TypeKey - TypeKey Authentication
64 use Catalyst qw[Authenticate::TypeKey];
66 MyApp->config->{authenticate}->{typekey} = {
67 token => 'xxxxxxxxxxxxxxxxxxxx'
70 if ( $c->authenticate_typekey( $email, $name, $nick, $ts, $sig ) ) {
71 # successful autentication
76 TypeKey Authentication.
80 L<Authen::TypeKey>, L<Catalyst>.
84 Christian Hansen, C<ch@ngmedia.com>
88 This library is free software . You can redistribute it and/or modify it under
89 the same terms as perl itself.