summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJozef Kutej <jozef@kutej.net>2008-12-01 22:59:48 +0100
committerJozef Kutej <jozef@kutej.net>2008-12-01 22:59:48 +0100
commitab8b9fcd0f9b11e414a9bafad34bb6dc1b85b9ad (patch)
tree5ba30f06cf007698a035f0b52fb97adbe172b532
parentworking login/password check in login (diff)
parentMerge branch 'master' of git@git.useperl.at:PAUSE-OpenID (diff)
downloadSimple-OpenID-ab8b9fcd0f9b11e414a9bafad34bb6dc1b85b9ad.tar.gz
Simple-OpenID-ab8b9fcd0f9b11e414a9bafad34bb6dc1b85b9ad.tar.bz2
Simple-OpenID-ab8b9fcd0f9b11e414a9bafad34bb6dc1b85b9ad.zip
Merge branch 'master' of git@git.useperl.at:PAUSE-OpenID
-rw-r--r--lib/PAUSE/OpenID/Controller/Root.pm20
-rw-r--r--root/templates/error.xsl29
-rw-r--r--root/templates/index.xsl12
-rw-r--r--script/client.pl60
4 files changed, 114 insertions, 7 deletions
diff --git a/lib/PAUSE/OpenID/Controller/Root.pm b/lib/PAUSE/OpenID/Controller/Root.pm
index 33c8884..b3f2f4c 100644
--- a/lib/PAUSE/OpenID/Controller/Root.pm
+++ b/lib/PAUSE/OpenID/Controller/Root.pm
@@ -31,11 +31,27 @@ PAUSE::OpenID::Controller::Root - Root Controller for PAUSE::OpenID
sub index :Path :Args(0) {
my ( $self, $c ) = @_;
+ if ( not $c->req->param('openid.return_url') ) {
+ #$c->flash->{xml} = '<document><error_message>Missing parameter</error_message></document>';
+ $c->res->redirect($c->uri_for('/error'));
+ }
+
$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');
+}
+
+sub error :Local {
+ my ( $self, $c ) = @_;
+ #$c->stash->{xml} = $c->flash->{xml};
+ $c->stash->{xml} = '<document/>';
$c->forward('PAUSE::OpenID::View::XSLT');
}
@@ -52,7 +68,7 @@ sub login :Local {
my $username = $c->req->param('username');
my $password = $c->req->param('password');
- $c->log->debug('username "'.$username.'" login attemp');
+ $c->log->debug('username "'.$username.'" login attempt');
my $ua = LWP::UserAgent->new;
$ua->credentials('pause.perl.org:443', 'PAUSE', $username, $password);
diff --git a/root/templates/error.xsl b/root/templates/error.xsl
new file mode 100644
index 0000000..3aa236e
--- /dev/null
+++ b/root/templates/error.xsl
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
+ xmlns:xhtml="http://www.w3.org/1999/xhtml"
+ xmlns="http://www.w3.org/1999/xhtml">
+
+ <xsl:output encoding="UTF-8" method="xml" omit-xml-declaration="yes" media-type="text/html"
+ doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
+ doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" indent="no"/>
+
+ <xsl:template match="/document">
+ <html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>Error</title>
+ <style type="text/css">
+ @import "default.css";
+ </style>
+ </head>
+
+ <body>
+ <p>An error occured.</p>
+ <xsl:if test="error_message != ''">
+ <p id="error_message">
+ <xsl:value-of select="error_message"/>
+ </p>
+ </xsl:if>
+ </body>
+ </html>
+ </xsl:template>
+</xsl:stylesheet>
diff --git a/root/templates/index.xsl b/root/templates/index.xsl
index 0135613..9dc5bd4 100644
--- a/root/templates/index.xsl
+++ b/root/templates/index.xsl
@@ -7,25 +7,27 @@
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">
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Sign in with OpenID</title>
+ <link rel="openid.server" href="https://localhost/openid" />
<style type="text/css">
@import "default.css";
</style>
</head>
-
+
<body>
- <p>The website '<xsl:value-of select="$origin_website"/>' wants to verify your PAUSE identity.</p>
+ <h1>PAUSE OpenID login service</h1>
+ <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" />
<label for="password">Password:</label>
-
+
<input name="password" id="password" type="password" />
<input type="submit" />
</div>
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);
+ },
+ );
+
+