diff options
author | Jozef Kutej <jozef@kutej.net> | 2008-12-01 21:43:10 +0100 |
---|---|---|
committer | Jozef Kutej <jozef@kutej.net> | 2008-12-01 21:43:10 +0100 |
commit | 39e96169b2ec888e26ab80eb187db375be6a7585 (patch) | |
tree | a2a5539489fff54c75fe3a76ead074a53a55e187 /lib | |
parent | login test (diff) | |
parent | Merge branch 'master' of git@git.useperl.at:PAUSE-OpenID (diff) | |
download | Simple-OpenID-39e96169b2ec888e26ab80eb187db375be6a7585.tar.gz Simple-OpenID-39e96169b2ec888e26ab80eb187db375be6a7585.tar.bz2 Simple-OpenID-39e96169b2ec888e26ab80eb187db375be6a7585.zip |
Merge branch 'master' of git@git.useperl.at:PAUSE-OpenID
Diffstat (limited to 'lib')
-rw-r--r-- | lib/PAUSE/OpenID/Controller/OpenID.pm | 53 | ||||
-rw-r--r-- | lib/PAUSE/OpenID/View/XSLT.pm | 50 |
2 files changed, 103 insertions, 0 deletions
diff --git a/lib/PAUSE/OpenID/Controller/OpenID.pm b/lib/PAUSE/OpenID/Controller/OpenID.pm new file mode 100644 index 0000000..1082c20 --- /dev/null +++ b/lib/PAUSE/OpenID/Controller/OpenID.pm @@ -0,0 +1,53 @@ +package PAUSE::OpenID::Controller::OpenID; + +use strict; +use warnings; +use parent 'Catalyst::Controller'; +use Net::OpenID::Server; + + +# taken straight from Net::OpenID::Server +# http://search.cpan.org/src/MART/Net-OpenID-Server-1.02/doc/catalyst_sample +sub index : Local { + my ( $self, $c ) = @_; + + my $server = Net::OpenID::Server->new( + post_args => $c->req->params, + get_args => $c->req->params, + endpoint_url => $c->uri_for('/server'), + setup_url => $c->uri_for('/login'), + get_user => sub { + return $c->user_exists ? $c->user : undef; + }, + get_identity => sub { + my ( $u, $identity ) = @_; + return $identity unless $u; + return $c->uri_for( sprintf( '/user/%s', $u->username ) ); + }, + is_identity => sub { + my ( $u, $identity ) = @_; + return $u && $u->username eq ( split '/', $identity )[-1]; + }, + is_trusted => sub { + my ( $u, $trust_root, $is_identity ) = @_; + return $is_identity; + } + ); + + my ( $type, $data ) = $server->handle_page(); + + if ( $type eq 'redirect' ) { + return $c->res->redirect($data); + } + elsif ( $type eq 'setup' ) { + my $uri = $c->uri_for( '/login', $data ); + return $c->res->redirect($uri); + } + else { + $c->res->content_type($type); + $c->res->body($data); + } + +} + +1; diff --git a/lib/PAUSE/OpenID/View/XSLT.pm b/lib/PAUSE/OpenID/View/XSLT.pm new file mode 100644 index 0000000..4e2ab2a --- /dev/null +++ b/lib/PAUSE/OpenID/View/XSLT.pm @@ -0,0 +1,50 @@ +package PAUSE::OpenID::View::XSLT; + +use strict; +use base 'Catalyst::View::XSLT'; + +# example configuration + +__PACKAGE__->config( + # relative paths to the directories with templates + INCLUDE_PATH => [ + MyApp->path_to( 'root', 'xslt' ), + MyApp->path_to( 'templates', 'xsl' ), + ], + TEMPLATE_EXTENSION => '.xsl', # default extension when getting template name from the current action + DUMP_CONFIG => 1, # use for Debug. Will dump the final (merged) configuration for XSLT view + #LibXSLT => { # XML::LibXSLT specific parameters + # register_function => [ + # { + # uri => 'urn:catalyst', + # name => 'Hello', + # subref => sub { return $_[0] }, + # } + # ], + #}, +); + +=head1 NAME + +PAUSE::OpenID::View::XSLT - XSLT View Component + +=head1 SYNOPSIS + + See L<PAUSE::OpenID> + +=head1 DESCRIPTION + +Catalyst XSLT View. + +=head1 AUTHOR + +Michael Kr�ll,,, + +=head1 LICENSE + +This library is free software . You can redistribute it and/or modify it under +the same terms as perl itself. + +=cut + +1; |