Apache2::REST::AppAuth::Echo


Apache2-REST documentation Contained in the Apache2-REST distribution.

Index


Code Index:

NAME

Apache2::REST::AppAuth::Echo - A app auth plugin which echoes some property and refuses access.

authorize

Authorize app is X-AppAuth header equals 'please'


Apache2-REST documentation Contained in the Apache2-REST distribution.
package Apache2::REST::AppAuth::Echo;
use warnings ;
use strict ;
use Apache2::Const ;

use base qw/Apache2::REST::AppAuth/ ;

sub authorize{
    my ( $self , $req , $resp ) = @_ ;
    
    my $header = $req->headers_in()->{'X-AppAuth'} || '' ;
    if ( $header eq 'please' ){
        return 1 ;
    }
    
    $resp->status( Apache2::Const::HTTP_UNAUTHORIZED ) ;
    $resp->message("Access denied. X-AppAuth was $header. Be polite") ;
    return 0 ;
}

1;