Lemonldap::Handlers::AuthorizationHeader - Plugin for Lemonldap sso system


Lemonldap-Handlers-Generic documentation Contained in the Lemonldap-Handlers-Generic distribution.

Index


Code Index:

NAME

Top

    Lemonldap::Handlers::AuthorizationHeader  - Plugin  for Lemonldap sso system

DESCRIPTION

Top

 AuthorizationHeader is the default header builder  manager  of lemonldap  websso framework .

 


 see http://lemonldap.sf.net for more infos .

Overlay

If you want use your own header method you must use PLUGINHEADER parameter like this : in httpd.conf : perlsetvar lemonldappluginheader MyModule

 Your module must accept  3 parameters : config (all the hash of config ) , dn and sting of role (profil) .

 Your module must provide the 'get' and 'forge'  methods .

 Those methods work with SENDHEADER parameter which tells what will be the  header (NONE value for no header)   

SEE ALSO

Top

Lemonldap(3), Lemonldap::Portal::Standard

http://lemonldap.sourceforge.net/

"Writing Apache Modules with Perl and C" by Lincoln Stein & Doug MacEachern - O'REILLY

Eric German, <germanlinux@yahoo.fr>
Isabelle Serre, <isabelle.serre@justice.gouv.fr>

COPYRIGHT AND LICENSE

Top


Lemonldap-Handlers-Generic documentation Contained in the Lemonldap-Handlers-Generic distribution.

package Lemonldap::Handlers::AuthorizationHeader;
use strict;
use MIME::Base64;
our ( @ISA, $VERSION, @EXPORTS );
$VERSION = '2.00';
our $VERSION_LEMONLDAP = "2.0";
our $VERSION_INTERNAL  = "2.0";

sub get {
    my $class  = shift;
    my %_param = @_;
    my $profil = $_param{profil};
    my $dn     = $_param{dn};
    my $header = $_param{config}->{SENDHEADER} || 'Authorization';
    my $self;
    my $ligne_h;
    if ( $profil eq '_ALLOW_' ) { $profil = ""; }

    if ( $profil =~ /^uid/ ) {
        $ligne_h = $profil;
    }
    else {
        $ligne_h = $dn;
        if ( defined($profil) ) {
            $ligne_h .= ":$profil";
        }
    }
    $self->{decoded} = "Basic %b64%$ligne_h%b64%";
    $self->{clair}   = "Basic $ligne_h";
    bless $self, $class;
    return $self;
}

sub forge {
    my $class  = shift;
    my %_param = @_;
    my $line   = $_param{line};
    my $self;
    $self->{decoded} = $line;
    my ($user) = $line =~ /(uid.+?),/;
    $self->{user} = $user;
    my $header = $_param{config}->{SENDHEADER} || 'Authorization';
    return 0 if ( $header eq 'NONE' );

    ( my $b, my $e ) = $line =~ /(.+)%b64%(.+)%b64%/;
    if ($e) {
        $e = encode_base64( $e, '' );
        $line =~ s/%b64%.+%b64%/$e/;
    }
    else {

        # for previous version
        ( my $b, my $e ) = $line =~ /(.+?)\s(.+)/;
        $e = encode_base64( $e, '' );
        $line =~ s/ (.+)$/ $e/;
    }

    $self->{content} = $line;
    $self->{header}  = $header;
    bless $self, $class;
    return $self;
}
1;