Changeset 1207 for trunk


Ignore:
Timestamp:
12/28/12 15:05:24 (11 years ago)
Author:
nanardon
Message:

back to application side authentication to allow a working logout

Location:
trunk/LATMOS-Accounts-Web/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/LATMOS-Accounts-Web/lib/Catalyst/Authentication/Credential/La.pm

    r895 r1207  
    9999sub _login_auth { 
    100100    my ($self, $c, $realm, $authinfo) = @_; 
    101     my $authheader = $c->req->headers->header('Authorization') 
    102         or do { 
    103         $c->log->debug('No Authorization header found');    
    104         return; 
    105     }; 
    106     # TODO check auth type 
    107     my ($type, $base64) = $authheader =~ /(\w+) (\S+)/; 
    108     ($authinfo->{username}, $authinfo->{password}) 
    109         = decode_base64($base64) =~ /^([^:]+):(.*)/; 
     101    if (!$authinfo) { 
     102        my $authheader = $c->req->headers->header('Authorization') 
     103            or do { 
     104            $c->log->debug('No Authorization header found');    
     105            return; 
     106        }; 
     107        # TODO check auth type 
     108        my ($type, $base64) = $authheader =~ /(\w+) (\S+)/; 
     109        ($authinfo->{username}, $authinfo->{password}) 
     110            = decode_base64($base64) =~ /^([^:]+):(.*)/; 
     111    } 
    110112     
    111113    if($c->model('Accounts')->db->connect( 
  • trunk/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Controller/Root.pm

    r1148 r1207  
    2525sub auth_required : Private { 
    2626    my ( $self, $c ) = @_; 
    27     $c->res->status(401); 
    28     $c->res->content_type('text/plain'); 
    29     $c->res->body('Authorization required.'); 
    30     $c->res->headers->push_header( 
    31         'WWW-Authenticate' => 'Basic realm="Link::Accounts"' 
    32     ); 
     27    $c->forward('login'); 
    3328} 
    3429 
     
    4742    } else { 
    4843        # No need to login for About section 
    49         if (!$c->authenticate({}, 'la')) { 
     44        if (!$c->authenticate({ username => $c->req->param('login'), password => 
     45                    $c->req->param('password') }, 'la')) { 
    5046            $c->forward('auth_required'); 
    5147            return; 
Note: See TracChangeset for help on using the changeset viewer.