Changeset 15866 for lang/perl/Apache2-AuthenOpenID
- Timestamp:
- 07/16/08 00:04:29 (4 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/Apache2-AuthenOpenID/trunk/lib/Apache2/AuthenOpenID.pm
r11424 r15866 60 60 sub return_to { 61 61 my ($self, $params, $arg) = @_; 62 my $class = ref $self; 63 my $i = Apache2::Module::get_config($class, $params->server); 64 $i->{'return_to'} = $arg; 62 $self->{'return_to'} = $arg; 65 63 } 66 64 67 65 sub trust_root { 68 66 my ($self, $params, $arg) = @_; 69 my $class = ref $self; 70 my $i = Apache2::Module::get_config($class, $params->server); 71 $i->{'trust_root'} = $arg; 67 $self->{'trust_root'} = $arg; 72 68 } 73 69 74 70 sub consumer_secret { 75 71 my ($self, $params, $arg) = @_; 76 my $class = ref $self; 77 my $i = Apache2::Module::get_config($class, $params->server); 78 $i->{'consumer_secret'} = $arg; 72 $self->{'consumer_secret'} = $arg; 79 73 } 80 74 … … 82 76 my ($self, $r) = @_; 83 77 lc $r->auth_type eq lc $self->auth_type or return Apache2::Const::DECLINED; 84 my $cf = Apache2::Module::get_config($self, $r->server); 78 79 my $cf = Apache2::Module::get_config($self, $r->server, $r->per_dir_config); 80 $r->log->debug( 81 sprintf "tr=%s rt=%s cs=%s", $cf->{'trust_root'}, $cf->{'return_to'}, $cf->{'consumer_secret'} 82 ); 85 83 unless ($cf->{'trust_root'} && $cf->{'return_to'} && $cf->{'consumer_secret'}) { 86 84 $r->log_error("You need to specify trust_root, return_to, and consumer_secret."); … … 101 99 . $r->uri; 102 100 103 my $q = CGI->new($r);104 101 my %cookie_in = CGI::Cookie->parse($r->headers_in->{Cookie}); 105 102 106 my $csr = Net::OpenID::Consumer->new(107 args => $q,108 ua => LWPx::ParanoidAgent->new,109 consumer_secret => $cf->{'consumer_secret'},110 );111 103 if ($request_url eq $cf->{'return_to'}) { 104 my $q = CGI->new($r); 105 my $csr = Net::OpenID::Consumer->new( 106 args => $q, 107 ua => LWPx::ParanoidAgent->new, 108 consumer_secret => $cf->{'consumer_secret'}, 109 ); 110 111 $r->log->debug("$request_url is return_to"); 112 112 if (my $identity = $q->param('identity')) { 113 113 my $claimed_identity = $csr->claimed_identity($identity) … … 117 117 trust_root => $cf->{'trust_root'}, 118 118 ); 119 $r->log->debug("clamed_identity=$claimed_identity check_url=$check_url"); 119 120 $r->err_headers_out->set(Location => $check_url); 120 121 return Apache2::Const::REDIRECT; 121 122 } elsif (my $setup_url = $csr->user_setup_url) { 123 $r->log->debug("setup_url=$setup_url"); 122 124 $r->err_headers_out->set(Location => $setup_url); 123 125 return Apache2::Const::REDIRECT; 124 126 } elsif ($csr->user_cancel) { 127 $r->log->debug("user_canceled."); 125 128 return Apache2::Const::HTTP_UNAUTHORIZED; 126 129 } elsif (my $vident = $csr->verified_identity) { 130 $r->log->debug('verified_identity'); 127 131 my $url = $vident->url; 128 132 $url =~ s{(^https?://|/$)}{}g; … … 136 140 if (%cookie_in && (my $dest = $cookie_in{$cookie_dest_name})) { 137 141 $r->headers_out->set('Location' => $dest->value); 142 $r->log->debug('return to cookie_dest='. $dest->value); 138 143 } else { 139 144 $r->headers_out->set('Location' => $cf->{'trust_root'}); 145 $r->log->debug('redirect to trust_root'); 140 146 } 141 147 my $cookie_dest_erase = CGI::Cookie->new( … … 148 154 return Apache2::Const::REDIRECT; 149 155 } 156 157 $r->log_error("Error validating identity: " . $csr->err); 150 158 return Apache2::Const::HTTP_UNAUTHORIZED; 151 159 } … … 170 178 sub set_custom_response { 171 179 my ($self, $r) = @_; 172 my $cf = Apache2::Module::get_config($self, $r->server );180 my $cf = Apache2::Module::get_config($self, $r->server, $r->per_dir_config); 173 181 my $auth_name = $r->auth_name; 174 182 my $html = <<END;
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)