Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Chia-liang Kao
committed
Aug 6, 2008
0 parents
commit 7558126
Showing
15 changed files
with
1,123 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
html/Callbacks/OpenID/autohandler/Auth | ||
html/Callbacks/OpenID/Elements/Login/Default | ||
inc/Module/Install.pm | ||
inc/Module/Install/Base.pm | ||
inc/Module/Install/Can.pm | ||
inc/Module/Install/Fetch.pm | ||
inc/Module/Install/Makefile.pm | ||
inc/Module/Install/Metadata.pm | ||
inc/Module/Install/RTx.pm | ||
inc/Module/Install/Win32.pm | ||
inc/Module/Install/WriteAll.pm | ||
lib/RT/Authen/OpenID.pm | ||
Makefile.PL | ||
MANIFEST This list of files | ||
META.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: RT-Authen-OpenID | ||
version: 0.01 | ||
abstract: Allows RT to do authentication via a service which supports the OpenID API | ||
author: Artur Bergman <abergman@sixapart.com> | ||
license: GPL version 2 | ||
distribution_type: module | ||
requires: | ||
Net::OpenID::Consumer: 0 | ||
no_index: | ||
directory: | ||
- html | ||
- inc | ||
generated_by: Module::Install version 0.34 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use inc::Module::Install; | ||
|
||
RTx('RT-Authen-OpenID'); | ||
|
||
name ('RT-Authen-OpenID'); | ||
abstract ('Allows RT to do authentication via a service which supports the OpenID API'); | ||
author ('Artur Bergman <sky@crucially.net> and Jesse Vincent <jesse@bestpractical.com>'); | ||
version_from ('lib/RT/Authen/OpenID.pm'); | ||
license ('GPL version 2'); | ||
|
||
requires ('Net::OpenID::Consumer'); | ||
requires ('LWPx::ParanoidAgent'); | ||
requires ('Cache::FileCache'); | ||
|
||
&WriteAll; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<%init> | ||
return unless ($RT::EnableOpenId); | ||
</%init> | ||
<div class="input-row"> | ||
<h3><&|/l&>Have an OpenID? Log in with it and have a look around.</&></h3> | ||
</div> | ||
<span class="label"><&|/l&>OpenID</&>:</span> | ||
<span class="input"><input name="openid" /></span> | ||
</div> | ||
|
||
<div class="button-row"> | ||
<span class="input"><input type="submit" class="button" value="<&|/l&>Login with OpenID</&>" /></span> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<%INIT> | ||
return unless ($RT::EnableOpenId); | ||
use Net::OpenID::Consumer; | ||
use LWPx::ParanoidAgent; | ||
use Cache::FileCache; | ||
|
||
my $openid_url = ref( $ARGS{openid} ) ? $ARGS{openid}->[0] : $ARGS{openid}; | ||
my $user; | ||
my $check_url; | ||
|
||
# Livejournal misencodes responses... | ||
if ($ARGS{'openid.sig'}) { | ||
my $sig = $m->cgi_object->param('openid.sig') ||''; | ||
$sig =~ s/ /+/g; | ||
$m->cgi_object->param( 'openid.sig' => $sig ); | ||
} | ||
|
||
|
||
my $root_user = RT::User->new($RT::SystemUser); | ||
my $csr = Net::OpenID::Consumer->new( | ||
ua => LWPx::ParanoidAgent->new, | ||
args => \%ARGS, | ||
cache => Cache::FileCache->new, | ||
consumer_secret => $RT::DatabasePassword, | ||
required_root => $RT::WebURL, | ||
); | ||
|
||
|
||
if ($openid_url) { | ||
if ( my $claimed_identity = $csr->claimed_identity("$openid_url")) { | ||
$check_url = $claimed_identity->check_url( | ||
return_to => $RT::WebURL, | ||
delayed_return => 1, | ||
trust_root => $RT::WebURL, | ||
); | ||
RT::Interface::Web::Redirect($check_url); | ||
} else { | ||
$RT::Logger->error("OpenID login failure for $openid_url code $csr->{last_errcode} error $csr->{last_errtext}"); | ||
# we should end up skipping the rest now | ||
} | ||
} | ||
if ( $ARGS{"openid.mode"} ) { | ||
if ( my $setup_url = $csr->user_setup_url ) { | ||
|
||
# redirect/link/popup user to $setup_url | ||
RT::Interface::Web::Redirect($setup_url); | ||
} elsif ( $csr->user_cancel ) { | ||
} elsif ( my $vident = $csr->verified_identity ) { | ||
$user = $vident->url; | ||
} else { | ||
die ( "Error validating identity: " . $csr->err ); | ||
} | ||
} | ||
|
||
# if the user isn't logged in and we got credentials from OpenID, load them | ||
if ( ( !$session{'CurrentUser'} ) && ($user) ) { | ||
|
||
# set a global user so we know elsewhere we're using OpenID for auth | ||
$session{'OpenID'} = $user; | ||
|
||
# OpenID has verified that the user has control of this e-mail address, | ||
# so it's okay to use it to get a valid RT user | ||
|
||
# we've got a valid user, so try to load | ||
$session{'CurrentUser'} = RT::CurrentUser->new(); | ||
$session{'CurrentUser'}->LoadByCols( Name => $user ); | ||
$session{'CurrentUser'}->{'OpenID'} = 1; | ||
if ( $session{'CurrentUser'}->id ) { | ||
$RT::Logger->info($session{'CurrentUser'}->Name ." logged in with openid"); | ||
} else { | ||
my $UserObj = RT::User->new($RT::SystemUser); | ||
my ( $id, $msg ) = $UserObj->Create( | ||
Name => $user, | ||
|
||
#RealName => $user->{'name'}, | ||
#EmailAddress => $user->{'email'}, | ||
Privileged => 0, | ||
); | ||
$RT::Logger->info($user ." attempted an account creation with OpenID: $msg"); | ||
if ( $UserObj->id ) { | ||
|
||
# created the user, now load them as the current user | ||
$session{'CurrentUser'}->Load( $UserObj->id ); | ||
$session{'i'}++; | ||
# redirect the user to their preference page to add more info | ||
RT::Interface::Web::Redirect( $RT::WebURL . '/User/Prefs.html' ); | ||
} else { | ||
|
||
# we couldn't create the user. abort abort abort! | ||
delete $session{'CurrentUser'}; | ||
die( loc( "Cannot create user: [_1]", $msg ) ); | ||
} | ||
} | ||
} | ||
</%INIT> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
#line 1 "inc/Module/Install.pm - /usr/share/perl5/Module/Install.pm" | ||
# $File: //depot/cpan/Module-Install/lib/Module/Install.pm $ $Author: autrijus $ | ||
# $Revision: #68 $ $Change: 2285 $ $DateTime: 2004/07/01 03:16:20 $ vim: expandtab shiftwidth=4 | ||
|
||
package Module::Install; | ||
$VERSION = '0.34'; | ||
|
||
die << "." unless $INC{join('/', inc => split(/::/, __PACKAGE__)).'.pm'}; | ||
Please invoke ${\__PACKAGE__} with: | ||
use inc::${\__PACKAGE__}; | ||
not: | ||
use ${\__PACKAGE__}; | ||
. | ||
|
||
use strict 'vars'; | ||
use Cwd (); | ||
use File::Find (); | ||
use File::Path (); | ||
|
||
@inc::Module::Install::ISA = 'Module::Install'; | ||
|
||
#line 131 | ||
|
||
sub import { | ||
my $class = shift; | ||
my $self = $class->new(@_); | ||
|
||
if (not -f $self->{file}) { | ||
require "$self->{path}/$self->{dispatch}.pm"; | ||
File::Path::mkpath("$self->{prefix}/$self->{author}"); | ||
$self->{admin} = | ||
"$self->{name}::$self->{dispatch}"->new(_top => $self); | ||
$self->{admin}->init; | ||
@_ = ($class, _self => $self); | ||
goto &{"$self->{name}::import"}; | ||
} | ||
|
||
*{caller(0) . "::AUTOLOAD"} = $self->autoload; | ||
|
||
# Unregister loader and worker packages so subdirs can use them again | ||
delete $INC{"$self->{file}"}; | ||
delete $INC{"$self->{path}.pm"}; | ||
} | ||
|
||
#line 158 | ||
|
||
sub autoload { | ||
my $self = shift; | ||
my $caller = caller; | ||
|
||
my $cwd = Cwd::cwd(); | ||
my $sym = "$caller\::AUTOLOAD"; | ||
|
||
$sym->{$cwd} = sub { | ||
my $pwd = Cwd::cwd(); | ||
if (my $code = $sym->{$pwd}) { | ||
goto &$code unless $cwd eq $pwd; # delegate back to parent dirs | ||
} | ||
$$sym =~ /([^:]+)$/ or die "Cannot autoload $caller"; | ||
unshift @_, ($self, $1); | ||
goto &{$self->can('call')} unless uc($1) eq $1; | ||
}; | ||
} | ||
|
||
#line 183 | ||
|
||
sub new { | ||
my ($class, %args) = @_; | ||
|
||
return $args{_self} if $args{_self}; | ||
|
||
$args{dispatch} ||= 'Admin'; | ||
$args{prefix} ||= 'inc'; | ||
$args{author} ||= '.author'; | ||
$args{bundle} ||= 'inc/BUNDLES'; | ||
|
||
$class =~ s/^\Q$args{prefix}\E:://; | ||
$args{name} ||= $class; | ||
$args{version} ||= $class->VERSION; | ||
|
||
unless ($args{path}) { | ||
$args{path} = $args{name}; | ||
$args{path} =~ s!::!/!g; | ||
} | ||
$args{file} ||= "$args{prefix}/$args{path}.pm"; | ||
|
||
bless(\%args, $class); | ||
} | ||
|
||
#line 212 | ||
|
||
sub call { | ||
my $self = shift; | ||
my $method = shift; | ||
my $obj = $self->load($method) or return; | ||
|
||
unshift @_, $obj; | ||
goto &{$obj->can($method)}; | ||
} | ||
|
||
#line 227 | ||
|
||
sub load { | ||
my ($self, $method) = @_; | ||
|
||
$self->load_extensions( | ||
"$self->{prefix}/$self->{path}", $self | ||
) unless $self->{extensions}; | ||
|
||
foreach my $obj (@{$self->{extensions}}) { | ||
return $obj if $obj->can($method); | ||
} | ||
|
||
my $admin = $self->{admin} or die << "END"; | ||
The '$method' method does not exist in the '$self->{prefix}' path! | ||
Please remove the '$self->{prefix}' directory and run $0 again to load it. | ||
END | ||
|
||
my $obj = $admin->load($method, 1); | ||
push @{$self->{extensions}}, $obj; | ||
|
||
$obj; | ||
} | ||
|
||
#line 257 | ||
|
||
sub load_extensions { | ||
my ($self, $path, $top_obj) = @_; | ||
|
||
unshift @INC, $self->{prefix} | ||
unless grep { $_ eq $self->{prefix} } @INC; | ||
|
||
local @INC = ($path, @INC); | ||
foreach my $rv ($self->find_extensions($path)) { | ||
my ($file, $pkg) = @{$rv}; | ||
next if $self->{pathnames}{$pkg}; | ||
|
||
eval { require $file; 1 } or (warn($@), next); | ||
$self->{pathnames}{$pkg} = delete $INC{$file}; | ||
push @{$self->{extensions}}, $pkg->new( _top => $top_obj ); | ||
} | ||
} | ||
|
||
#line 281 | ||
|
||
sub find_extensions { | ||
my ($self, $path) = @_; | ||
my @found; | ||
|
||
File::Find::find(sub { | ||
my $file = $File::Find::name; | ||
return unless $file =~ m!^\Q$path\E/(.+)\.pm\Z!is; | ||
return if $1 eq $self->{dispatch}; | ||
|
||
$file = "$self->{path}/$1.pm"; | ||
my $pkg = "$self->{name}::$1"; $pkg =~ s!/!::!g; | ||
push @found, [$file, $pkg]; | ||
}, $path) if -d $path; | ||
|
||
@found; | ||
} | ||
|
||
1; | ||
|
||
__END__ | ||
#line 619 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#line 1 "inc/Module/Install/Base.pm - /usr/share/perl5/Module/Install/Base.pm" | ||
# $File: //depot/cpan/Module-Install/lib/Module/Install/Base.pm $ $Author: autrijus $ | ||
# $Revision: #10 $ $Change: 1847 $ $DateTime: 2003/12/31 23:14:54 $ vim: expandtab shiftwidth=4 | ||
|
||
package Module::Install::Base; | ||
|
||
#line 31 | ||
|
||
sub new { | ||
my ($class, %args) = @_; | ||
|
||
foreach my $method (qw(call load)) { | ||
*{"$class\::$method"} = sub { | ||
+shift->_top->$method(@_); | ||
} unless defined &{"$class\::$method"}; | ||
} | ||
|
||
bless(\%args, $class); | ||
} | ||
|
||
#line 49 | ||
|
||
sub AUTOLOAD { | ||
my $self = shift; | ||
goto &{$self->_top->autoload}; | ||
} | ||
|
||
#line 60 | ||
|
||
sub _top { $_[0]->{_top} } | ||
|
||
#line 71 | ||
|
||
sub admin { | ||
my $self = shift; | ||
$self->_top->{admin} or Module::Install::Base::FakeAdmin->new; | ||
} | ||
|
||
sub is_admin { | ||
my $self = shift; | ||
$self->admin->VERSION; | ||
} | ||
|
||
sub DESTROY {} | ||
|
||
package Module::Install::Base::FakeAdmin; | ||
|
||
my $Fake; | ||
sub new { $Fake ||= bless(\@_, $_[0]) } | ||
sub AUTOLOAD {} | ||
sub DESTROY {} | ||
|
||
1; | ||
|
||
__END__ | ||
#line 115 |
Oops, something went wrong.