File: MockOpenID.pm

package info (click to toggle)
libcatalystx-simplelogin-perl 0.21-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 464 kB
  • sloc: perl: 3,134; makefile: 2
file content (34 lines) | stat: -rw-r--r-- 961 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package Catalyst::Authentication::Credential::MockOpenID;
use strict;
use warnings;
use base qw/Catalyst::Authentication::Credential::OpenID/;

sub authenticate {
    my ( $self, $c, $realm, $authinfo ) = @_;
    my $claimed_uri = $authinfo->{ 'openid_identifier' };
    if ( $claimed_uri ) {
        if( $claimed_uri eq 'aaa' ){
            return;
        }
        if( $claimed_uri eq 'http://mock.open.id.server' ){
            $c->res->redirect( 'http://localhost/login?openid-check=1' );
            $c->detach();
        }
    }
    elsif ( $c->req->params->{'openid-check'} ){
        my $user = {
            url => 'http://mock.open.id.server' ,
            display => 'mocked_user' ,
            rss => '',
            atom => '',
            foaf => '',
            declared_rss => '',
            declared_atom => '',
            declared_foaf => '',
            foafmaker => '',
        };
        return $realm->find_user($user, $c);
    }
}

1;