Changeset 2517

Show
Ignore:
Timestamp:
06/06/08 03:06:26 (20 months ago)
Author:
fumiakiy
Message:

Trust_root now include CommentScript. BugId:80052

Trust_root, return_to and other parameters for check_url can be modified by creating a new authentication module and overriding the check_url_params method.

Removed _get_root and consolidated the genearation of trust_root and return_to to one method because it does not make sense to create trust_root and return_to individually per spec.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/release-39/lib/MT/Auth/OpenID.pm

    r2365 r2517  
    4141    } 
    4242 
    43     my $root = $class->_get_root($blog); 
    44     my $return_to = $app->base . $app->uri . '?__mode=handle_sign_in' 
    45         . '&blog_id=' . $q->param('blog_id') 
    46         . '&static=' . $q->param('static') 
    47         . '&key=' . $q->param('key'); 
    48     $return_to .= '&entry_id=' . $q->param('entry_id') if $q->param('entry_id'); 
     43    my %params = $class->check_url_params( $app, $blog ); 
    4944 
    5045    my $check_url = $claimed_identity->check_url( 
    51         return_to => $return_to, 
    52         trust_root => $root, 
     46        %params 
    5347    ); 
    5448 
     
    379373} 
    380374 
    381 sub _get_root { 
     375sub check_url_params { 
    382376    my $class = shift; 
    383     my ($blog) = @_; 
     377    my ( $app, $blog ) = @_; 
     378    my $q = $app->{query}; 
     379 
    384380    my $path = MT->config->CGIPath; 
    385381    if ($path =~ m!^/!) { 
     
    389385    } 
    390386    $path .= '/' unless $path =~ m!/$!; 
    391     $path; 
     387    $path .= MT->config->CommentScript; 
     388 
     389    my $return_to = $path . '?__mode=handle_sign_in' 
     390        . '&blog_id=' . $q->param('blog_id') 
     391        . '&static=' . $q->param('static') 
     392        . '&key=' . $q->param('key'); 
     393    $return_to .= '&entry_id=' . $q->param('entry_id') if $q->param('entry_id'); 
     394    ( trust_root => $path, return_to => $return_to ); 
    392395} 
    393396 
    3943971; 
     398 
     399__END__ 
     400 
     401=head1 NAME 
     402 
     403MT::Auth::OpenID 
     404 
     405Movable Type commenter authentication module via OpenID 
     406 
     407=head1 METHODS 
     408 
     409=head2 login 
     410 
     411This method is called from MT::App::Comments::login_external, 
     412to initiate process of logging in to a website other than  
     413Movable Type itself.  You should not have to modify the 
     414behavior of this method. 
     415 
     416=head2 handle_sign_in 
     417 
     418This method is called from MT::App::Comments::handle_sign_in 
     419to accept the result of logging in to an external website. 
     420You should not have to modify the behavior of this method. 
     421 
     422=head2 url_for_userid 
     423 
     424This method is called in login method when it needs to construct 
     425OpenID for the login request.  By default the module accepts 
     426the identifier entered by the user as OpenID, thus does nothing 
     427in this method. 
     428 
     429You can inherit this class, create your own authentication 
     430module and override this method to generate OpenID out of 
     431what user entered in the login form, so it can provide more 
     432user friendly way of specifying their OpenID.  See MT::Auth::Vox 
     433and MT::Auth::LiveJournal for examples. 
     434 
     435=head2 get_nickname 
     436 
     437This method is called in handle_sign_in method, in which it 
     438tries to grab the user's nickname.  By default, a user who 
     439is authenticated via OpenID has his/her nickname as the OpenID 
     440(thus, URL).  It tends to get ugly when it is displayed. 
     441 
     442By default, this class tries to load FOAF or Atom from the 
     443verified OpenID to see if it is able to get more semantic information. 
     444If it was able to load the semantic info from one of them, 
     445it uses the information as the user's nickname. 
     446 
     447You can inherit this class, create your own authentication 
     448module and override this method to generate more user friendly 
     449nickname for a user from the OpenID that does not support 
     450FOAF or Atom retrieval from the URL. 
     451 
     452=head2 get_userpic_asset 
     453 
     454This method is called in handle_sign_in method, in which it 
     455tries to retrieve the user's userpic or avatar.  By default, 
     456the method sees if the FOAF retrieved from OpenID has the URL 
     457for userpic.  If it does, the method downloads the userpic and 
     458saves it as an userpic asset for the user. 
     459 
     460You can inherit this class, create your own authentication 
     461module and override this method to associate a userpic to the user. 
     462 
     463=head2 check_url_params 
     464 
     465This method is called in login method.  This method must return 
     466a hash which is passed to I<Net::OpenID::ClaimedIdentity>::check_url. 
     467Consult I<Net::OpenID::ClaimedIdentity> about what can be specified. 
     468By default, the class specifies trust_root and return_to parameters. 
     469 
     470You can inherit this class, create your own authentication 
     471module and override this method to specify more parameters, or 
     472change how to construct trust_root and return_to arguments. 
     473 
     474=head1 AUTHOR & COPYRIGHT 
     475 
     476Please see L<MT/AUTHOR & COPYRIGHT>. 
     477 
     478=cut