AuthWebID skeleton

This commit is contained in:
Xavier Guimard 2013-10-12 11:45:55 +00:00
parent da41295b76
commit 5c1973d225
2 changed files with 53 additions and 0 deletions

View File

@ -69,6 +69,7 @@ sub authInit {
foreach my $arg (qw(facebookAppId facebookAppSecret)) {
$self->abort("Parameter $arg is required") unless ( $self->{$arg} );
}
$initDone++;
}
PE_OK;
}

View File

@ -0,0 +1,52 @@
##@file
# WebID authentication backend file
#############################
### EXPERIMENTAL MODULE ! ###
#############################
##@class
# WebID authentication backend class
package Lemonldap::NG::Portal::AuthWebID;
use strict;
use Lemonldap::NG::Portal::Simple;
use Lemonldap::NG::Portal::AuthSSL;
our $VERSION = '1.3.0';
our @ISA = qw(Lemonldap::NG::Portal::AuthSSL);
our $initDone;
BEGIN {
eval {
require threads::shared;
threads::shared::share($initDone);
};
}
## @apmethod int authInit()
# @return Lemonldap::NG::Portal constant
sub authInit {
my $self = shift;
my $tmp = $self->SUPER::authInit(@_);
return $tmp unless ( $tmp eq PE_OK );
unless ($initDone) {
eval "use Web::ID";
$self->abort( 'Unable to load Web::ID', $@ ) if ($@);
$initDone++;
}
PE_OK;
}
sub extractFormInfo {
my $self = shift;
my $tmp = $self->SUPER::extractFormInfo(@_);
return $tmp unless ( $tmp eq PE_OK );
return PE_CERTIFICATEREQUIRED
unless ( $ENV{SSL_CLIENT_CERT}
and $self->{webid} =
Web::ID->new( certificate => $ENV{SSL_CLIENT_CERT} ) );
return ( $self->{webid}->valid() ? PE_OK : PE_BADCREDENTIALS );
}
1;
__END__