summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Dɪᴇᴄᴋᴏᴡ <daxim@cpan.org>2008-12-01 22:53:03 +0100
committerLars Dɪᴇᴄᴋᴏᴡ <daxim@cpan.org>2008-12-01 22:53:03 +0100
commitb48e0d5095895e720a36d1514b6d846cbd2aa1a5 (patch)
treeb206550f42330273180bc46afa90829a1980563a
parentcorrect server endpoint (diff)
parentMerge branch 'master' of git@git.useperl.at:PAUSE-OpenID (diff)
downloadSimple-OpenID-b48e0d5095895e720a36d1514b6d846cbd2aa1a5.tar.gz
Simple-OpenID-b48e0d5095895e720a36d1514b6d846cbd2aa1a5.tar.bz2
Simple-OpenID-b48e0d5095895e720a36d1514b6d846cbd2aa1a5.zip
Merge branch 'master' of git@git.useperl.at:PAUSE-OpenID
Conflicts: root/templates/index.xsl
-rw-r--r--lib/PAUSE/OpenID/Controller/Root.pm30
-rw-r--r--root/templates/index.xsl6
-rw-r--r--script/client.pl60
3 files changed, 93 insertions, 3 deletions
diff --git a/lib/PAUSE/OpenID/Controller/Root.pm b/lib/PAUSE/OpenID/Controller/Root.pm
index c37b2c2..129f3a4 100644
--- a/lib/PAUSE/OpenID/Controller/Root.pm
+++ b/lib/PAUSE/OpenID/Controller/Root.pm
@@ -32,6 +32,11 @@ sub index :Path :Args(0) {
$c->stash->{xml} =<<XML;
<document/>
XML
+
+ # Pass through parameters (unchecked for now)
+ foreach my $key ( keys %{$c->req->params} ) {
+ $c->stash->{$key} = $c->req->param($key);
+ }
# Hello World
$c->forward('PAUSE::OpenID::View::XSLT');
@@ -44,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 1f3c43c..9dc5bd4 100644
--- a/root/templates/index.xsl
+++ b/root/templates/index.xsl
@@ -7,7 +7,7 @@
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" indent="no"/>
- <xsl:param name="origin_website"/>
+ <xsl:param name="openid.return_to"/>
<xsl:template match="/document">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
@@ -21,8 +21,8 @@
<body>
<h1>PAUSE OpenID login service</h1>
- <p>The website '<xsl:value-of select="$origin_website"/>' wants to verify your <a href="https://pause.perl.org/">PAUSE</a> identity.</p>
- <form method="post" action="/" id="login_form">
+ <p>The website '<xsl:value-of select="$openid.return_to"/>' wants to verify your <a href="https://pause.perl.org/">PAUSE</a> identity.</p>
+ <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);
+ },
+ );
+
+