From cb67ac1e617f54e0cb184469836cfa06532042f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Oudot?= Date: Tue, 18 Feb 2014 15:17:09 +0000 Subject: [PATCH] Manage exported variables for DBI (#636) --- .../lib/Lemonldap/NG/Common/Conf/Attributes.pm | 7 +++++++ .../lib/Lemonldap/NG/Common/Conf/Serializer.pm | 1 + .../lib/Lemonldap/NG/Manager/_Struct.pm | 11 ++++++++--- .../lib/Lemonldap/NG/Manager/_i18n.pm | 2 ++ .../lib/Lemonldap/NG/Portal/UserDBDBI.pm | 12 ++++++------ 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/Attributes.pm b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/Attributes.pm index 2eef2a51f..61278d75a 100644 --- a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/Attributes.pm +++ b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/Attributes.pm @@ -155,6 +155,13 @@ has 'dbiAuthnLevel' => ( documentation => 'DBI authentication level', ); +has 'dbiExportedVars' => ( + is => 'rw', + isa => 'HashRef', + default => sub { return {}; }, + documentation => 'DBI exported variables', +); + has 'demoExportedVars' => ( is => 'rw', isa => 'HashRef', diff --git a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/Serializer.pm b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/Serializer.pm index e7f2892be..6246b5083 100644 --- a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/Serializer.pm +++ b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/Serializer.pm @@ -106,6 +106,7 @@ sub unserialize { |authChoiceModules |CAS_proxiedServices |casStorageOptions + |dbiExportedVars |demoExportedVars |exportedHeaders |exportedVars diff --git a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/_Struct.pm b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/_Struct.pm index 93eda210e..747fd74ae 100644 --- a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/_Struct.pm +++ b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/_Struct.pm @@ -608,10 +608,15 @@ sub struct { # DBI dbiParams => { _nodes => [ - qw(dbiAuthnLevel n:dbiConnection n:dbiSchema n:dbiPassword) + qw(dbiAuthnLevel cn:dbiExportedVars n:dbiConnection n:dbiSchema n:dbiPassword) ], - _help => 'authDBI', - dbiAuthnLevel => 'int:/dbiAuthnLevel:authDBILevel:int', + _help => 'authDBI', + dbiAuthnLevel => 'int:/dbiAuthnLevel:authDBILevel:int', + dbiExportedVars => { + _nodes => ['hash:/dbiExportedVars:vars:btext'], + _js => 'hashRoot', + _help => 'authDBI', + }, dbiConnection => { _nodes => [qw(n:dbiConnectionAuth n:dbiConnectionUser)], dbiConnectionAuth => { diff --git a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/_i18n.pm b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/_i18n.pm index bfd3cea3d..eedea7121 100644 --- a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/_i18n.pm +++ b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/_i18n.pm @@ -95,6 +95,7 @@ sub en { dbiConnection => 'Connection', dbiConnectionAuth => 'Authentication process', dbiConnectionUser => 'User process', + dbiExportedVars => 'Exported variables', dbiParams => 'DBI parameters', dbiPassword => 'Password', dbiPasswordMailCol => 'Mail field name', @@ -577,6 +578,7 @@ sub fr { dbiConnection => 'Connexion', dbiConnectionAuth => 'Authentification', dbiConnectionUser => 'Utilisateurs', + dbiExportedVars => 'Variables exportées', dbiParams => 'Paramètres DBI', dbiPassword => 'Mot de passe', dbiPasswordMailCol => 'Champ mail', diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/UserDBDBI.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/UserDBDBI.pm index 05f236171..c6ea1ae33 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/UserDBDBI.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/UserDBDBI.pm @@ -9,7 +9,7 @@ use strict; use Lemonldap::NG::Portal::Simple; use Lemonldap::NG::Portal::_DBI; #inherits -our $VERSION = '1.2.3'; +our $VERSION = '1.4.0'; ## @apmethod int userDBInit() # Set default values @@ -102,16 +102,16 @@ sub setSessionInfo { # Set _user unless already defined $self->{sessionInfo}->{_user} ||= $self->{user}; - # Return if no data to collect - return PE_OK - unless ( $self->{exportedVars} - and ref( $self->{exportedVars} ) eq 'HASH' ); - while ( my ( $var, $attr ) = each %{ $self->{exportedVars} } ) { $self->{sessionInfo}->{$var} = $self->{entry}->{$attr} if ( defined $self->{entry}->{$attr} ); } + while ( my ( $var, $attr ) = each %{ $self->{dbiExportedVars} } ) { + $self->{sessionInfo}->{$var} = $self->{entry}->{$attr} + if ( defined $self->{entry}->{$attr} ); + } + PE_OK; }