Changeset 515 for trunk/openid-server
- Timestamp:
- 02/29/08 12:25:48 (21 months ago)
- Location:
- trunk/openid-server/plugins/openid-server
- Files:
-
- 2 added
- 2 removed
- 1 modified
-
OpenIDServer.pl (deleted)
-
config.yaml (added)
-
lib/OpenIDServer/App.pm (modified) (7 diffs)
-
lib/OpenIDServer/Tags.pm (added)
-
server.cgi (deleted)
Legend:
- Unmodified
- Added
- Removed
-
trunk/openid-server/plugins/openid-server/lib/OpenIDServer/App.pm
r514 r515 2 2 3 3 use strict; 4 use MT;5 use MT::App;6 use MT::Util;7 4 use Net::OpenID::Server; 8 use File::Spec;9 use vars qw(@ISA);10 @ISA = 'MT::App';11 12 sub uri {13 my $app = shift;14 my $path = $app->app_path;15 $path .= '/' unless $path =~ m{/$};16 $path .= 'plugins/openid-server/server.cgi';17 }18 19 sub init {20 my $app = shift;21 $app->SUPER::init(@_) or return;22 $app->add_methods(23 openid => \&openid,24 trust => \&trust,25 );26 $app->{default_mode} = 'openid';27 my $mode = $app->{query}->param('__mode');28 $app->{requires_login} = 1 if $mode && $mode eq 'trust';29 $app;30 }31 5 32 6 sub trust { 33 7 my $app = shift; 34 my $q = $app-> {query};8 my $q = $app->param; 35 9 my %param; 36 10 37 11 ## We're logged in, so just redirect, until we have actual trusting. 38 12 my @params = grep { !/__mode/ && !/username/ && !/password/ && !/submit/ } $q->param; 39 my $uri = $app->uri . '? openid.mode=checkid_setup&openid.identity=';13 my $uri = $app->uri . '?__mode=openid&openid.mode=checkid_setup&openid.identity='; 40 14 $uri .= MT::Util::encode_url($q->param('identity')); 41 15 $uri .= '&openid.return_to='; … … 48 22 49 23 sub is_identity { 50 my ($app, $u, $identity_url) = @_; 24 my $app = shift; 25 my ( $u, $identity_url ) = @_; 51 26 return 0 unless $u; 52 27 my $ident; … … 58 33 59 34 sub is_trusted { 60 my ($app, $u, $trust_root, $is_identity) = @_; 35 my $app = shift; 36 my ( $u, $trust_root, $is_identity ) = @_; 61 37 ## TODO: use saved trust too 62 38 return 0 unless defined($u) && $is_identity; … … 76 52 get_args => $app->{query}, 77 53 post_args => $app->{query}, 78 server_secret => sub { $app->make_secret($_[0]) },54 server_secret => sub { &make_secret($app, $_[0]) }, 79 55 get_user => sub { ($app->{author}) = $app->login; $app->{author} }, 80 is_identity => sub { $app->is_identity(@_) },81 is_trusted => sub { $app->is_trusted(@_) },56 is_identity => sub { &is_identity($app, @_) }, 57 is_trusted => sub { &is_trusted($app, @_) }, 82 58 setup_url => ($path . '?__mode=trust'), 83 59 ); … … 87 63 sub openid { 88 64 my $app = shift; 89 my $nos = $app->_build_nos; 65 my $plugin = $app->component('openidserver'); 66 my $nos = &_build_nos($app); 90 67 my ($type, $data) = $nos->handle_page; 91 68 if ($type eq "redirect") { … … 93 70 } elsif($type eq 'setup') { 94 71 ## Was it an identity or trust failure? Cancel. 95 return $app->error('Your account is not authorized to assert the requested identity.') 96 if $app->{author}; 72 return $app->error( 73 $plugin->translate('Your account is not authorized to assert the requested identity.')) 74 if $app->user; 97 75 98 76 my $url = $nos->setup_url; … … 102 80 } else { 103 81 $app->response_content_type($type); 104 return $data || "This is Movable Type's OpenID server endpoint, not a human-readable resource. For more information, see <a href='http://openid.net/'>http://openid.net/</a>.<br /><br />Get <a href='?openid.mode=getpubkey'>public key</a>.";82 return $data || $plugin->translate("This is Movable Type's OpenID server endpoint, not a human-readable resource. For more information, see <a href='http://openid.net/'>http://openid.net/</a>.<br /><br />Get <a href='?openid.mode=getpubkey'>public key</a>."); 105 83 } 106 84 }
