Changeset 1263 for lang/perl/Apache2-AuthenOpenID
- Timestamp:
- 11/10/07 12:31:02 (13 months ago)
- Location:
- lang/perl/Apache2-AuthenOpenID/trunk
- Files:
-
- 3 modified
-
Changes (modified) (1 diff)
-
Makefile.PL (modified) (1 diff)
-
lib/Apache2/AuthenOpenID.pm (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/Apache2-AuthenOpenID/trunk/Changes
r1196 r1263 1 1 Revision history for Perl extension Apache2::AuthenOpenID. 2 3 0.04 Sat Nov 10 12:21:00 JST 2007 4 - made inheritable 2 5 3 6 0.03 Mon Oct 16 09:30:00 2007 -
lang/perl/Apache2-AuthenOpenID/trunk/Makefile.PL
r476 r1263 9 9 mod_perl2 => 2.000001, 10 10 CGI => 0, 11 Net::OpenID::Consumer => 0.14, ,11 Net::OpenID::Consumer => 0.14, 12 12 Digest::HMAC_SHA1 => 1.01, 13 13 LWPx::ParanoidAgent => 1.03, 14 Class::Data::Inheritable => 0, 14 15 }, # e.g., Module::Name => 1.1 15 16 ($] >= 5.005 ? ## Add these new keywords supported since 5.005 -
lang/perl/Apache2-AuthenOpenID/trunk/lib/Apache2/AuthenOpenID.pm
r1196 r1263 16 16 use Digest::HMAC_SHA1; 17 17 use LWPx::ParanoidAgent; 18 19 our $VERSION = '0.03'; 20 21 my @directives = ( 22 { 23 name => 'AuthType', 24 func => __PACKAGE__ . '::AuthType', 25 req_override => Apache2::Const::OR_AUTHCFG, 26 args_how => Apache2::Const::TAKE1, 27 }, 28 { 29 name => 'return_to', 30 func => __PACKAGE__ . '::return_to', 31 req_override => Apache2::Const::OR_AUTHCFG, 32 args_how => Apache2::Const::TAKE1, 33 errmsg => 'return_to http://sample.com/trust_root/callback', 34 }, 35 { 36 name => 'trust_root', 37 func => __PACKAGE__ . '::trust_root', 38 req_override => Apache2::Const::OR_AUTHCFG, 39 args_how => Apache2::Const::TAKE1, 40 errmsg => 'return_to http://sample.com/trust_root/', 41 }, 42 { 43 name => 'consumer_secret', 44 func => __PACKAGE__ . '::consumer_secret', 45 req_override => Apache2::Const::OR_AUTHCFG, 46 args_how => Apache2::Const::TAKE1, 47 errmsg => 'consumer_secret "Your consumer secret goes here"', 48 }, 49 ); 50 51 eval { Apache2::Module::add(__PACKAGE__, \@directives); }; 18 use base qw( Class::Data::Inheritable ); 19 20 our $VERSION = '0.04'; 21 22 __PACKAGE__->mk_classdata( auth_type => 'openid' ); 23 __PACKAGE__->init; 24 25 26 sub init { 27 my $self = shift; 28 29 my @directives = ( 30 { 31 name => 'AuthType', 32 req_override => Apache2::Const::OR_AUTHCFG, 33 args_how => Apache2::Const::TAKE1, 34 }, 35 { 36 name => 'return_to', 37 req_override => Apache2::Const::OR_AUTHCFG, 38 args_how => Apache2::Const::TAKE1, 39 errmsg => 'return_to http://sample.com/trust_root/callback', 40 }, 41 { 42 name => 'trust_root', 43 req_override => Apache2::Const::OR_AUTHCFG, 44 args_how => Apache2::Const::TAKE1, 45 errmsg => 'return_to http://sample.com/trust_root/', 46 }, 47 { 48 name => 'consumer_secret', 49 req_override => Apache2::Const::OR_AUTHCFG, 50 args_how => Apache2::Const::TAKE1, 51 errmsg => 'consumer_secret "Your consumer secret goes here"', 52 }, 53 ); 54 55 eval { 56 Apache2::Module::add($self, \@directives); 57 }; 58 } 52 59 53 60 sub AuthType { 54 my ($i, $params, $arg) = @_; 55 if ($arg =~ /^OpenID$/i) { 61 my ($self, $params, $arg) = @_; 62 my $class = ref $self; 63 if (lc $arg eq lc $self->auth_type) { 56 64 Apache2::ServerUtil->server->push_handlers( 57 PerlAuthenHandler => __PACKAGE__,65 PerlAuthenHandler => $class, 58 66 ); 59 67 } … … 61 69 62 70 sub return_to { 63 my ($i, $params, $arg) = @_; 64 $i = Apache2::Module::get_config(__PACKAGE__, $params->server); 71 my ($self, $params, $arg) = @_; 72 my $class = ref $self; 73 my $i = Apache2::Module::get_config($class, $params->server); 65 74 $i->{'return_to'} = $arg; 66 75 } 67 76 68 77 sub trust_root { 69 my ($i, $params, $arg) = @_; 70 $i = Apache2::Module::get_config(__PACKAGE__, $params->server); 78 my ($self, $params, $arg) = @_; 79 my $class = ref $self; 80 my $i = Apache2::Module::get_config($class, $params->server); 71 81 $i->{'trust_root'} = $arg; 72 82 } 73 83 74 84 sub consumer_secret { 75 my ($i, $params, $arg) = @_; 76 $i = Apache2::Module::get_config(__PACKAGE__, $params->server); 85 my ($self, $params, $arg) = @_; 86 my $class = ref $self; 87 my $i = Apache2::Module::get_config($class, $params->server); 77 88 $i->{'consumer_secret'} = $arg; 78 89 } … … 80 91 sub handler : method { 81 92 my ($self, $r) = @_; 82 warn $self; 83 warn __PACKAGE__; 84 $r->auth_type =~ m{^OpenID$}i or return Apache2::Const::DECLINED; 85 86 my $cf = Apache2::Module::get_config(__PACKAGE__, $r->server); 93 lc $r->auth_type eq lc $self->auth_type or return Apache2::Const::DECLINED; 94 my $cf = Apache2::Module::get_config($self, $r->server); 87 95 unless ($cf->{'trust_root'} && $cf->{'return_to'} && $cf->{'consumer_secret'}) { 88 96 $r->log_error("You need to specify trust_root, return_to, and consumer_secret."); 89 97 die; 90 98 } 91 92 (my $cookie_name = __PACKAGE__."-".$r->auth_name) =~ s/(::|\s+)/-/g; 99 (my $cookie_name = $self."-".$r->auth_name) =~ s/(::|\s+)/-/g; 93 100 my $cookie_dest_name = $cookie_name.'-destination'; 94 101 $self->set_custom_response($r); … … 172 179 173 180 sub set_custom_response { 174 my $self = shift; 175 my $r = shift; 176 my $cf = Apache2::Module::get_config(__PACKAGE__, $r->server); 181 my ($self, $r) = @_; 182 my $cf = Apache2::Module::get_config($self, $r->server); 177 183 my $auth_name = $r->auth_name; 178 184 my $html = <<END; … … 220 226 221 227 sub calc_token { 222 my ($ url, $time, $consumer_secret) = @_;228 my ($self, $url, $time, $consumer_secret) = @_; 223 229 my $context = Digest::HMAC_SHA1->new($consumer_secret); 224 230 $context->add($url);
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)