diff --git a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/_Struct.pm b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/_Struct.pm index 3a0fed342..ccaa0f32b 100644 --- a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/_Struct.pm +++ b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/_Struct.pm @@ -1458,7 +1458,7 @@ sub testStruct { exportedVars => { keyTest => qr/^!?[a-zA-Z][\w-]*$/, keyMsgFail => 'Bad variable name', - test => qr/^[a-zA-Z][\w-]*$/, + test => qr/^[a-zA-Z][\w:\-]*$/, msgFail => 'Bad attribute name', }, failedLoginNumber => $integer, diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/AuthWebID.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/AuthWebID.pm index d0b7a4d58..6351ae9fc 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/AuthWebID.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/AuthWebID.pm @@ -80,8 +80,8 @@ sub extractFormInfo { # 3. Verify that certificate is WebID compliant # NB: WebID URI is used as user field eval { - $self->{webid} = Web::ID->new( certificate => $ENV{SSL_CLIENT_CERT} ) - and $self->{user} = $self->{webid}->uri->as_string; + $self->{_webid} = Web::ID->new( certificate => $ENV{SSL_CLIENT_CERT} ) + and $self->{user} = $self->{_webid}->uri->as_string; }; return PE_BADCERTIFICATE if ( $@ or not( $self->{user} ) ); @@ -89,7 +89,7 @@ sub extractFormInfo { return PE_BADPARTNER unless ( $self->{user} =~ $reWebIDWhitelist ); # 5. Verify FOAF document - return PE_BADCREDENTIALS unless ( $self->{webid}->valid() ); + return PE_BADCREDENTIALS unless ( $self->{_webid}->valid() ); # 6. OK, access granted return PE_OK; diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/UserDBWebID.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/UserDBWebID.pm index de44362de..434cc6120 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/UserDBWebID.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/UserDBWebID.pm @@ -40,7 +40,24 @@ sub getUser { sub setSessionInfo { my $self = shift; - # TODO + unless ( $self->{_webid} ) { + $self->lmLog( 'No webid object found', 'error' ); + return PE_ERROR; + } + + while ( my ( $k, $v ) = each %{ $self->{exportedVars} } ) { + my $attr = $k; + my $req; + $attr =~ s/^!// and $req = 1; + eval { $self->{sessionInfo}->{$attr} = $self->{_webid}->get($v) }; + $self->lmLog( "Unable to get $v from FOAF document: $@", 'error' ) + if ($@); + if ( $req and not $self->{sessionInfo}->{$attr} ) { + $self->_sub( 'userNotice', + "Required attribute $v is missing (user: $self->{user})" ); + return PE_MISSINGREQATTR; + } + } PE_OK; }