diff options
author | Michael Kröll <pepl@cpan.org> | 2008-12-01 22:21:42 +0100 |
---|---|---|
committer | Michael Kröll <pepl@cpan.org> | 2008-12-01 22:21:42 +0100 |
commit | b038af84df08edfd44fb0b545a8db34567e6ccac (patch) | |
tree | 29299148afe1a23ee805c4bd4d4fb18f2bb01a66 | |
parent | Pass through params to stylesheet (diff) | |
parent | Merge branch 'master' of git@git.useperl.at:PAUSE-OpenID (diff) | |
download | Simple-OpenID-b038af84df08edfd44fb0b545a8db34567e6ccac.tar.gz Simple-OpenID-b038af84df08edfd44fb0b545a8db34567e6ccac.tar.bz2 Simple-OpenID-b038af84df08edfd44fb0b545a8db34567e6ccac.zip |
Merge branch 'master' of git@git.useperl.at:PAUSE-OpenID
Conflicts:
root/templates/index.xsl
-rw-r--r-- | lib/PAUSE/OpenID/Controller/Root.pm | 25 | ||||
-rw-r--r-- | root/templates/index.xsl | 2 | ||||
-rw-r--r-- | script/client.pl | 60 |
3 files changed, 86 insertions, 1 deletions
diff --git a/lib/PAUSE/OpenID/Controller/Root.pm b/lib/PAUSE/OpenID/Controller/Root.pm index ba6db5d..129f3a4 100644 --- a/lib/PAUSE/OpenID/Controller/Root.pm +++ b/lib/PAUSE/OpenID/Controller/Root.pm @@ -49,6 +49,31 @@ sub default :Path { } +sub login :Local { + my ( $self, $c ) = @_; + + my $username = $c->req->param('username'); + my $password = $c->req->param('password'); + + $c->log->debug('username "'.$username.'" login attemp'); + + $c->res->redirect($c->uri_for('/login_failed')); +} + +sub login_pass { + my ( $self, $c ) = @_; + + $c->res->content_type('text/plain'); + $c->res->body('login pass'); +} + +sub login_failed { + my ( $self, $c ) = @_; + + $c->res->content_type('text/plain'); + $c->res->body('login fail'); +} + =head2 end Attempt to render a view, if needed. diff --git a/root/templates/index.xsl b/root/templates/index.xsl index c471513..30aa90f 100644 --- a/root/templates/index.xsl +++ b/root/templates/index.xsl @@ -20,7 +20,7 @@ <body> <p>The website '<xsl:value-of select="$openid.return_to"/>' wants to verify your PAUSE identity.</p> - <form method="post" action="signin" id="login_form"> + <form method="post" action="login" id="login_form"> <div> <label for="username"><abbr title="Perl Authors Upload Server">PAUSE</abbr> ID:</label> <input name="username" id="username" type="text" /> diff --git a/script/client.pl b/script/client.pl new file mode 100644 index 0000000..90e3fe1 --- /dev/null +++ b/script/client.pl @@ -0,0 +1,60 @@ +#!/usr/bin/perl +use strict; +use warnings; + +use Net::OpenID::Consumer; +use LWPx::ParanoidAgent; + +my $csr = Net::OpenID::Consumer->new( + ua => LWPx::ParanoidAgent->new, + #cache => Some::Cache->new, + #args => $cgi, + consumer_secret => 'foo', + required_root => "http://localhost:3000", + ); + + # a user entered, say, "bradfitz.com" as their identity. The first + # step is to fetch that page, parse it, and get a + # Net::OpenID::ClaimedIdentity object: + + my $claimed_identity = $csr->claimed_identity("http://localhost:3000") || die $csr->err; + + # now your app has to send them at their identity server's endpoint + # to get redirected to either a positive assertion that they own + # that identity, or where they need to go to login/setup trust/etc. + + my $check_url = $claimed_identity->check_url( + return_to => "http://localhost:3000/openid-check.app?yourarg=val", + trust_root => "http://localhost:3000/", + ); + + # so you send the user off there, and then they come back to + # openid-check.app, then you see what the identity server said. + + # Either use callback-based API (recommended)... + $csr->handle_server_response( + not_openid => sub { + die "Not an OpenID message"; + }, + setup_required => sub { + my $setup_url = shift; + print "setup_required $setup_url\n"; + # Redirect the user to $setup_url + }, + cancelled => sub { + print "cancelled\n"; + # Do something appropriate when the user hits "cancel" at + # the OP + }, + verified => sub { + my $vident = shift; + print "verified $vident\n"; + # Do something with the VerifiedIdentity object $vident + }, + error => sub { + my $err = shift; + die($err); + }, + ); + + |