Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Got "make test" to pass, and converted OpenID to C::A::Credential::Op…

…enID.

Many changes:

1. Fixed a typo in Makefile.PL - "requries".

2. moved away cpanhq.conf to cpanhq.conf.old due to a Config::General
bug. We're now using cpanhq.yml.

3. New file - cpanhq.yml.

4. Converted the authentication logic to
Catalyst::Authentication::Credential::OpenID.
  • Loading branch information...
commit dabc8f837f6830fe42c5bb3e01502556c7150969 1 parent c5f87d9
@shlomif shlomif authored
View
2  Makefile.PL
@@ -21,7 +21,7 @@ requires 'DBIx::Class';
requires 'DBIx::Class::TimeStamp';
requires 'File::Spec';
requires 'File::Temp';
-requries 'Graph::Easy';
+requires 'Graph::Easy';
requires 'List::Util';
requires 'LWPx::ParanoidAgent';
requires 'Net::OpenID::Consumer';
View
8 cpanhq.conf
@@ -1,8 +0,0 @@
-name CPANHQ
-<Model::DB>
- connect_info dbi:SQLite:dbname=__HOME__/cpanhq.db
- connect_info undef
-</Model::DB>
-<Controller::Distribution>
- graph_path __HOME__/root/dist/graph/
-</Controller::Distribution>
View
32 cpanhq.conf.old
@@ -0,0 +1,32 @@
+name CPANHQ
+<Model::DB>
+ connect_info dbi:SQLite:dbname=__HOME__/cpanhq.db
+ connect_info undef
+</Model::DB>
+<Controller::Distribution>
+ graph_path __HOME__/root/dist/graph/
+</Controller::Distribution>
+<Plugin::Authentication>
+ use_session 1
+ default_realm openid
+ <realms>
+ <openid>
+ <credential>
+ class OpenID
+ <extensions>
+ "http://openid.net/extensions/sreg/1.1" 1
+ </extensions>
+ extension_args = "http://openid.net/extensions/sreg/1.1"
+ extension_args = required
+ #<extension_args>
+ # required "email,timezone"
+ # optional "fullname,nickname,timezone"
+ #</extension_args>
+ ua_class LWPx::ParanoidAgent
+ </credential>
+ <store>
+ class Null
+ </store>
+ </openid>
+ </realms>
+</Plugin::Authentication>
View
24 cpanhq.yml
@@ -0,0 +1,24 @@
+---
+Controller::Distribution:
+ graph_path: __HOME__/root/dist/graph/
+Model::DB:
+ connect_info:
+ - dbi:SQLite:dbname=__HOME__/cpanhq.db
+ - undef
+Plugin::Authentication:
+ default_realm: openid
+ realms:
+ openid:
+ credential:
+ class: OpenID
+ extension_args:
+ - http://openid.net/extensions/sreg/1.1
+ - required: "email,timezone"
+ optional: "fullname,nickname,timezone"
+ extensions:
+ 'http://openid.net/extensions/sreg/1.1': '1'
+ ua_class: LWPx::ParanoidAgent
+ store:
+ class: Null
+ use_session: '1'
+name: CPANHQ
View
45 lib/CPANHQ/Controller/Authenticate.pm
@@ -28,8 +28,12 @@ Login using OpenID.
sub login : Path('/login') Args(0) {
my ( $self, $c ) = @_;
my $form = $c->form( 'Login' );
+ $form->action($c->uri_for('/authenticate/openid'));
$c->stash( form => $form, title => 'Login' );
+ return;
+
+=begin Hello
return unless $form->was_submitted && $form->is_valid;
my $consumer = Net::OpenID::Consumer->new(
@@ -46,6 +50,10 @@ sub login : Path('/login') Args(0) {
);
$c->res->redirect( $url );
+=end Hello
+
+=cut
+
}
=head2 $self->openid($c)
@@ -57,30 +65,23 @@ Login using OpenID.
sub openid : Path('openid') Args(0) {
my( $self, $c ) = @_;
- if( !$c->req->params->{ 'openid.identity' } ) {
- $c->res->redirect( $c->uri_for( '/login' ) );
- return;
- }
-
- my $consumer = Net::OpenID::Consumer->new(
- ua => LWPx::ParanoidAgent->new,
- args => $c->req->params,
- consumer_secret => sub { $_[0] },
- );
-
- if ( my $setup = $consumer->user_setup_url ) {
- $c->res->redirect( $setup );
- }
- elsif ($consumer->user_cancel) {
- $c->res->redirect( $c->uri_for( '/login' ) );
- }
- elsif ( my $identity = $consumer->verified_identity ) {
- $c->authenticate( { enabled => 1, openid => $identity->url }, 'openid' );
- $c->res->redirect( $c->uri_for( '/' ) );
+ if ($c->authenticate({}, "openid"))
+ {
+ $c->persist_user();
+ $c->flash(message => "You signed in with OpenID!");
+ $c->res->redirect( $c->uri_for('/') );
}
- else {
- Catalyst::Exception->throw('Error validating identity: ' . $consumer->errtext);
+ else
+ {
+ $c->flash(message => "Could not authenticate with OpenID");
+ $c->response->body( "Could not authenticate with OpenID" );
+ # $c->flash(message => "Could not authenticate with OpenID");
+ # $c->response->body( "Could not authenticate with OpenID" );
+ # Catalyst::Exception->throw(
+ # 'Error validating identity: '
+ # );
}
+ return;
}
=head2 $self->logout($c)
View
4 lib/CPANHQ/Form/Login.pm
@@ -30,8 +30,8 @@ Builds the form.
sub build_form {
my $self = shift;
- $self->add_fields( claimed_uri => { type => 'text', size => 40, required => 1 }, submit => { type => 'submit', value => 'Login' } );
- $self->method( 'post' );
+ $self->add_fields( openid_identifier => { type => 'text', size => 40, required => 1 }, submit => { type => 'submit', value => 'Login' } );
+ $self->method( 'get' );
return $self;
}
View
3  root/wrapper.tt
@@ -1,4 +1,5 @@
<!DOCTYPE HTML>
+[%- USE HTML -%]
<html lang=en>
<head>
<meta charset=utf-8>
@@ -27,7 +28,7 @@ on all pages
</ul>
<p class="login">
[% IF c.user_exists %]
-Logged in as [% c.user.display_name %] (<a href="[% c.uri_for('/logout') %]">Logout</a>)
+Logged in as [% HTML.escape(c.user.display) %] (<a href="[% c.uri_for('/logout') %]">Logout</a>)
[% ELSE %]
Not logged in (<a href="[% c.uri_for('/login') %]">Login</a>)
[% END %]
Please sign in to comment.
Something went wrong with that request. Please try again.