Default values for Portal all managed in Common (#686)

This commit is contained in:
Clément Oudot 2014-02-14 09:00:12 +00:00
parent 2630d09d72
commit 18b337723d
5 changed files with 121 additions and 54 deletions

View File

@ -44,6 +44,27 @@ has 'authentication' => (
## C
has 'captcha_login_enabled' => (
is => 'rw',
isa => 'Bool',
default => '0',
documentation => 'Captcha on login page',
);
has 'captcha_mail_enabled' => (
is => 'rw',
isa => 'Bool',
default => '0',
documentation => 'Captcha on password reset page',
);
has 'captcha_size' => (
is => 'rw',
isa => 'Int',
default => '6',
documentation => 'Captcha size',
);
has 'casAccessControlPolicy' => (
is => 'rw',
isa => 'Str',
@ -58,6 +79,13 @@ has 'CAS_authnLevel' => (
documentation => 'CAS authentication level',
);
has 'checkXSS' => (
is => 'rw',
isa => 'Bool',
default => '1',
documentation => 'Check XSS',
);
has 'confirmFormMethod' => (
is => 'rw',
isa => 'Str',
@ -99,6 +127,13 @@ has 'facebookAuthnLevel' => (
documentation => 'Facebook authentication level',
);
has 'failedLoginNumber' => (
is => 'rw',
isa => 'Int',
default => '5',
documentation => 'Number of failures stored in login history',
);
## G
has 'globalStorage' => (
@ -222,6 +257,34 @@ has 'ldapGroupRecursive' => (
documentation => 'LDAP recursive search in groups',
);
has 'ldapPasswordResetAttribute' => (
is => 'rw',
isa => 'Str',
default => 'pwdReset',
documentation => 'LDAP password reset attribute',
);
has 'ldapPasswordResetAttributeValue' => (
is => 'rw',
isa => 'Str',
default => 'TRUE',
documentation => 'LDAP password reset value',
);
has 'ldapUsePasswordResetAttribute' => (
is => 'rw',
isa => 'Bool',
default => '1',
documentation => 'LDAP store reset flag in an attribute',
);
has 'loginHistoryEnabled' => (
is => 'rw',
isa => 'Bool',
default => '1',
documentation => 'Enable login history',
);
has 'logoutServices' => (
is => 'rw',
isa => 'HashRef',
@ -256,6 +319,13 @@ has 'mailSessionKey' => (
documentation => 'Session parameter where mail is stored',
);
has 'mailOnPasswordChange' => (
is => 'rw',
isa => 'Bool',
default => '0',
documentation => 'Send a mail when password is changed',
);
has 'mailSubject' => (
is => 'rw',
isa => 'Str',
@ -283,6 +353,13 @@ has 'multiValuesSeparator' => (
## N
has 'notificationWildcard' => (
is => 'rw',
isa => 'Str',
default => 'allusers',
documentation => 'Notification string to match all users',
);
has 'nullAuthnLevel' => (
is => 'rw',
isa => 'Int',
@ -322,6 +399,13 @@ has 'portalAutocomplete' => (
documentation => 'Allow autocompletion of login input in portal',
);
has 'portalCheckLogins' => (
is => 'rw',
isa => 'Bool',
default => '1',
documentation => 'Display login history checkbox in portal',
);
has 'portalDisplayAppslist' => (
is => 'rw',
isa => 'Str',
@ -508,6 +592,13 @@ has 'SSLAuthnLevel' => (
documentation => 'SSL authentication level',
);
has 'successLoginNumber' => (
is => 'rw',
isa => 'Int',
default => '5',
documentation => 'Number of success stored in login history',
);
## T
has 'twitterAuthnLevel' => (
@ -519,6 +610,13 @@ has 'twitterAuthnLevel' => (
## U
has 'userControl' => (
is => 'rw',
isa => 'Str',
default => '^[\w\.\-@]+$',
documentation => 'Regular expression to validate login',
);
has 'userDB' => (
is => 'rw',
isa => 'Str',
@ -526,6 +624,13 @@ has 'userDB' => (
documentation => 'User module',
);
has 'useSafeJail' => (
is => 'rw',
isa => 'Bool',
default => '1',
documentation => 'Activate Safe jail',
);
## V
## W

View File

@ -271,8 +271,17 @@ sub new {
$self->{persistentStorageOptions} = $self->{globalStorageOptions};
}
# Default values
$self->setDefaultValues();
# SAML
$self->{samlStorage} ||= $self->{globalStorage};
if ( !$self->{samlStorageOptions} or !%{ $self->{samlStorageOptions} } ) {
$self->{samlStorageOptions} = $self->{globalStorageOptions};
}
# CAS
$self->{casStorage} ||= $self->{globalStorage};
if ( !$self->{casStorageOptions} or !%{ $self->{casStorageOptions} } ) {
$self->{casStorageOptions} = $self->{globalStorageOptions};
}
# Load other storages if needed
foreach my $otherStorage ( $self->{samlStorage}, $self->{casStorage} ) {
@ -516,55 +525,6 @@ sub getConf {
1;
}
##@method protected void setDefaultValues()
# Set default values.
sub setDefaultValues {
my $self = shift;
# SAML
$self->{samlStorage} ||= $self->{globalStorage};
if ( !$self->{samlStorageOptions} or !%{ $self->{samlStorageOptions} } ) {
$self->{samlStorageOptions} = $self->{globalStorageOptions};
}
# CAS
$self->{casStorage} ||= $self->{globalStorage};
if ( !$self->{casStorageOptions} or !%{ $self->{casStorageOptions} } ) {
$self->{casStorageOptions} = $self->{globalStorageOptions};
}
# Other
$self->{useSafeJail} = 1 unless defined $self->{useSafeJail};
$self->{ldapUsePasswordResetAttribute} = 1
unless ( defined( $self->{ldapUsePasswordResetAttribute} ) );
$self->{ldapPasswordResetAttribute} ||= "pwdReset";
$self->{ldapPasswordResetAttributeValue} ||= "TRUE";
$self->{mailOnPasswordChange} ||= 0;
# Captcha parameters
$self->{captcha_login_enabled} = 0
unless defined $self->{captcha_login_enabled};
$self->{captcha_mail_enabled} = 0
unless defined $self->{captcha_mail_enabled};
$self->{captcha_size} = 6 unless defined $self->{captcha_size};
# Notification
$self->{notificationWildcard} ||= "allusers";
# Login History
$self->{loginHistoryEnabled} = 1
unless defined $self->{loginHistoryEnabled};
$self->{successLoginNumber} = 5 unless defined $self->{successLoginNumber};
$self->{failedLoginNumber} = 5 unless defined $self->{failedLoginNumber};
$self->{portalCheckLogins} = 1
unless defined $self->{portalCheckLogins};
# XSS
$self->{checkXSS} = 1 unless defined $self->{checkXSS};
$self->{userControl} ||= '^[\w\.\-@]+$';
}
## @method protected void setHiddenFormValue(string fieldname, string value, string prefix, boolean base64)
# Add element into $self->{portalHiddenFormValues}, those values could be
# used to hide values into HTML form.

View File

@ -136,6 +136,7 @@ ok(
passwordDB => 'Null',
domain => 'example.com',
trustedDomains => '.example2.com example3.com',
checkXSS => 1,
}
),
'Portal object'

View File

@ -25,6 +25,7 @@ ok(
authentication => 'Null',
userDB => 'Null',
passwordDB => 'Null',
useSafeJail => 1,
}
),
'Portal object with Safe jail'

View File

@ -22,9 +22,9 @@ my $p = Lemonldap::NG::Portal::Simple->new(
'^/nok' => '$uid eq "toto"',
},
},
cfgNum => 42,
sessionInfo => { uid => "kharec" },
cfgNum => 42,
sessionInfo => { uid => "kharec" },
captcha_size => 6,
}
);