summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJozef Kutej <jozef@kutej.net>2008-12-01 21:43:10 +0100
committerJozef Kutej <jozef@kutej.net>2008-12-01 21:43:10 +0100
commit39e96169b2ec888e26ab80eb187db375be6a7585 (patch)
treea2a5539489fff54c75fe3a76ead074a53a55e187
parentlogin test (diff)
parentMerge branch 'master' of git@git.useperl.at:PAUSE-OpenID (diff)
downloadSimple-OpenID-39e96169b2ec888e26ab80eb187db375be6a7585.tar.gz
Simple-OpenID-39e96169b2ec888e26ab80eb187db375be6a7585.tar.bz2
Simple-OpenID-39e96169b2ec888e26ab80eb187db375be6a7585.zip
Merge branch 'master' of git@git.useperl.at:PAUSE-OpenID
-rw-r--r--.project22
-rw-r--r--Build.PL16
-rw-r--r--lib/PAUSE/OpenID/Controller/OpenID.pm53
-rw-r--r--lib/PAUSE/OpenID/View/XSLT.pm50
-rw-r--r--root/static/css/default.css0
-rw-r--r--root/templates/index.xsl36
-rw-r--r--t/view_XSLT.t6
7 files changed, 175 insertions, 8 deletions
diff --git a/.project b/.project
new file mode 100644
index 0000000..be204ee
--- /dev/null
+++ b/.project
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>PAUSE-OpenID</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
+ <triggers>full,incremental,</triggers>
+ <arguments>
+ <dictionary>
+ <key>LaunchConfigHandle</key>
+ <value>&lt;project&gt;/.externalToolBuilders/org.epic.perleditor.perlbuilder (2).launch</value>
+ </dictionary>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.epic.perleditor.perlnature</nature>
+ </natures>
+</projectDescription>
diff --git a/Build.PL b/Build.PL
index a7c1ff5..7221c81 100644
--- a/Build.PL
+++ b/Build.PL
@@ -6,16 +6,16 @@ use 5.010;
my $builder = Module::Build->new(
module_name => 'PAUSE-OpenID',
license => 'perl',
- dist_author => 'Thomas Klausner',
+ dist_author => 'Vienna.pm',
dist_version_from => 'lib/PAUSE/OpenID.pm',
- build_requires => {
- 'Test::More' => 0,
+ build_requires => { 'Test::More' => 0, },
+ requires => {
+ 'perl' => '5.010',
+ 'Catalyst::Runtime' => '5.7014',
+ 'Net::OpenID::Server' => '1.02',
},
- requires => {
- 'perl' => '5.010',
- },
- add_to_cleanup => ['PAUSE-OpenID-*'],
- create_makefile_pl => 'passthrough',
+ add_to_cleanup => ['PAUSE-OpenID-*'],
+ create_makefile_pl => 'passthrough',
recursive_test_files => 1,
);
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;
diff --git a/root/static/css/default.css b/root/static/css/default.css
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/root/static/css/default.css
diff --git a/root/templates/index.xsl b/root/templates/index.xsl
new file mode 100644
index 0000000..adca9c6
--- /dev/null
+++ b/root/templates/index.xsl
@@ -0,0 +1,36 @@
+<?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:param name="origin_website"/>
+
+ <xsl:template match="/document">
+ <html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>Sign in with OpenID</title>
+ <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>
+ <form method="post" action="signin" 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>
+ </form>
+ </body>
+ </html>
+ </xsl:template>
+</xsl:stylesheet>
diff --git a/t/view_XSLT.t b/t/view_XSLT.t
new file mode 100644
index 0000000..e7802be
--- /dev/null
+++ b/t/view_XSLT.t
@@ -0,0 +1,6 @@
+use strict;
+use warnings;
+use Test::More tests => 1;
+
+BEGIN { use_ok 'PAUSE::OpenID::View::XSLT' }
+