Disable compactConf by default & Update unit tests (#2046)

This commit is contained in:
Christophe Maudoux 2019-12-22 13:05:15 +01:00
parent cabdec6092
commit 2954ea2abc
25 changed files with 71 additions and 41 deletions

View File

@ -4,12 +4,12 @@ use strict;
use Mouse;
use Lemonldap::NG::Common::Conf::ReConstants;
our $VERSION = '2.0.7';
our $VERSION = '2.0.8';
sub compactConf {
my ( $self, $conf ) = @_;
return $conf if ( $conf->{'dontCompactConf'} );
return $conf unless ( $conf->{'compactConf'} );
# Remove unused auth parameters
my %keep;

View File

@ -5,7 +5,7 @@ use strict;
use Exporter 'import';
use base qw(Exporter);
our $VERSION = '2.0.7';
our $VERSION = '2.0.8';
# CONSTANTS
@ -24,7 +24,7 @@ use constant MANAGERSECTION => "manager";
use constant SESSIONSEXPLORERSECTION => "sessionsExplorer";
use constant APPLYSECTION => "apply";
our $hashParameters = qr/^(?:(?:l(?:o(?:ca(?:lSessionStorageOption|tionRule)|goutService)|dapExportedVar|wp(?:Ssl)?Opt)|(?:(?:d(?:emo|bi)|facebook|webID)ExportedVa|exported(?:Heade|Va)|issuerDBGetParamete)r|re(?:moteGlobalStorageOption|st2f(?:Verify|Init)Arg|loadUrl)|g(?:r(?:antSessionRule|oup)|lobalStorageOption)|n(?:otificationStorageOption|ginxCustomHandler)|macro)s|o(?:idc(?:S(?:ervice(?:DynamicRegistrationEx(?:portedVar|traClaim)s|MetaDataAuthnContext)|torageOptions)|RPMetaData(?:(?:Option(?:sExtraClaim)?|ExportedVar|Macro)s|Node)|OPMetaData(?:(?:ExportedVar|Option)s|J(?:SON|WKS)|Node))|penIdExportedVars)|s(?:aml(?:S(?:PMetaData(?:(?:ExportedAttribute|Option|Macro)s|Node|XML)|torageOptions)|IDPMetaData(?:(?:ExportedAttribute|Option)s|Node|XML))|essionDataToRemember|laveExportedVars|fExtra)|c(?:as(?:A(?:ppMetaData(?:(?:ExportedVar|Option|Macro)s|Node)|ttributes)|S(?:rvMetaData(?:(?:ExportedVar|Option)s|Node)|torageOptions))|(?:ustom(?:Plugins|Add)Param|ombModule)s)|p(?:ersistentStorageOptions|o(?:rtalSkinRules|st))|a(?:ut(?:hChoiceMod|oSigninR)ules|pplicationList)|v(?:hostOptions|irtualHost)|S(?:MTPTLSOpts|SLVarIf))$/;
our $boolKeys = qr/^(?:s(?:aml(?:IDP(?:MetaDataOptions(?:(?:Check(?:S[LS]OMessageSignatur|Audienc|Tim)|IsPassiv)e|A(?:llow(?:LoginFromIDP|ProxiedAuthn)|daptSessionUtime)|Force(?:Authn|UTF8)|StoreSAMLToken|RelayStateURL)|SSODescriptorWantAuthnRequestsSigned)|S(?:P(?:MetaDataOptions(?:(?:CheckS[LS]OMessageSignatur|OneTimeUs)e|EnableIDPInitiatedURL|ForceUTF8)|SSODescriptor(?:WantAssertion|AuthnRequest)sSigned)|erviceUseCertificateInResponse)|DiscoveryProtocol(?:Activation|IsPassive)|CommonDomainCookieActivation|UseQueryStringSpecific|MetadataForceUTF8)|ingle(?:Session(?:UserByIP)?|(?:UserBy)?IP)|oap(?:Session|Config)Server|t(?:ayConnecte|orePasswor)d|kipRenewConfirmation|fRemovedUseNotif|laveDisplayLogo|howLanguages|slByAjax)|o(?:idc(?:RPMetaDataOptions(?:Re(?:freshToken|quirePKCE)|LogoutSessionRequired|IDTokenForceClaims|BypassConsent|AllowOffline|Public)|ServiceAllow(?:(?:AuthorizationCode|Implicit|Hybrid)Flow|DynamicRegistration)|OPMetaDataOptions(?:(?:CheckJWTSignatur|UseNonc)e|StoreIDToken))|ldNotifFormat)|p(?:ortal(?:Display(?:Re(?:setPassword|gister)|GeneratePassword|PasswordPolicy)|ErrorOn(?:ExpiredSession|MailNotFound)|(?:CheckLogin|Statu)s|OpenLinkInNewWindow|RequireOldPassword|ForceAuthn|AntiFrame)|roxyUseSoap)|c(?:a(?:ptcha_(?:register|login|mail)_enabled|sSrvMetaDataOptions(?:Gateway|Renew))|heck(?:User(?:Display(?:PersistentInfo|EmptyValues))?|State|XSS)|o(?:ntextSwitchingStopWithLogout|rsEnabled)|da)|l(?:dap(?:(?:Group(?:DecodeSearchedValu|Recursiv)|UsePasswordResetAttribut)e|(?:AllowResetExpired|Set)Password|ChangePasswordAsUser|PpolicyControl|ITDS)|oginHistoryEnabled)|i(?:ssuerDB(?:OpenID(?:Connect)?|SAML|CAS|Get)Activation|mpersonationSkipEmptyValues)|no(?:tif(?:ication(?:Server(?:(?:POS|GE)T|DELETE)?)?|y(?:Deleted|Other))|AjaxHook)|to(?:tp2f(?:UserCan(?:Chang|Remov)eKey|DisplayExistingSecret)|kenUseGlobalStorage)|u(?:se(?:RedirectOn(?:Forbidden|Error)|SafeJail)|2fUserCanRemoveKey|pgradeSession)|re(?:st(?:(?:Session|Config)Server|ExportSecretKeys)|freshSessions)|d(?:isablePersistentStorage|biDynamicHashEnabled|ontCompactConf)|(?:mai(?:lOnPasswordChang|ntenanc)|vhostMaintenanc)e|br(?:owsersDontStorePassword|uteForceProtection)|(?:(?:globalLogout|active)Tim|wsdlServ)er|h(?:ideOldPassword|ttpOnly)|yubikey2fUserCanRemoveKey|krb(?:RemoveDomain|ByJs))$/;
our $boolKeys = qr/^(?:s(?:aml(?:IDP(?:MetaDataOptions(?:(?:Check(?:S[LS]OMessageSignatur|Audienc|Tim)|IsPassiv)e|A(?:llow(?:LoginFromIDP|ProxiedAuthn)|daptSessionUtime)|Force(?:Authn|UTF8)|StoreSAMLToken|RelayStateURL)|SSODescriptorWantAuthnRequestsSigned)|S(?:P(?:MetaDataOptions(?:(?:CheckS[LS]OMessageSignatur|OneTimeUs)e|EnableIDPInitiatedURL|ForceUTF8)|SSODescriptor(?:WantAssertion|AuthnRequest)sSigned)|erviceUseCertificateInResponse)|DiscoveryProtocol(?:Activation|IsPassive)|CommonDomainCookieActivation|UseQueryStringSpecific|MetadataForceUTF8)|ingle(?:Session(?:UserByIP)?|(?:UserBy)?IP)|oap(?:Session|Config)Server|t(?:ayConnecte|orePasswor)d|kipRenewConfirmation|fRemovedUseNotif|laveDisplayLogo|howLanguages|slByAjax)|o(?:idc(?:RPMetaDataOptions(?:Re(?:freshToken|quirePKCE)|LogoutSessionRequired|IDTokenForceClaims|BypassConsent|AllowOffline|Public)|ServiceAllow(?:(?:AuthorizationCode|Implicit|Hybrid)Flow|DynamicRegistration)|OPMetaDataOptions(?:(?:CheckJWTSignatur|UseNonc)e|StoreIDToken))|ldNotifFormat)|p(?:ortal(?:Display(?:Re(?:setPassword|gister)|GeneratePassword|PasswordPolicy)|ErrorOn(?:ExpiredSession|MailNotFound)|(?:CheckLogin|Statu)s|OpenLinkInNewWindow|RequireOldPassword|ForceAuthn|AntiFrame)|roxyUseSoap)|c(?:a(?:ptcha_(?:register|login|mail)_enabled|sSrvMetaDataOptions(?:Gateway|Renew))|heck(?:User(?:Display(?:PersistentInfo|EmptyValues))?|State|XSS)|o(?:ntextSwitchingStopWithLogout|mpactConf|rsEnabled)|da)|l(?:dap(?:(?:Group(?:DecodeSearchedValu|Recursiv)|UsePasswordResetAttribut)e|(?:AllowResetExpired|Set)Password|ChangePasswordAsUser|PpolicyControl|ITDS)|oginHistoryEnabled)|i(?:ssuerDB(?:OpenID(?:Connect)?|SAML|CAS|Get)Activation|mpersonationSkipEmptyValues)|no(?:tif(?:ication(?:Server(?:(?:POS|GE)T|DELETE)?)?|y(?:Deleted|Other))|AjaxHook)|to(?:tp2f(?:UserCan(?:Chang|Remov)eKey|DisplayExistingSecret)|kenUseGlobalStorage)|u(?:se(?:RedirectOn(?:Forbidden|Error)|SafeJail)|2fUserCanRemoveKey|pgradeSession)|re(?:st(?:(?:Session|Config)Server|ExportSecretKeys)|freshSessions)|(?:mai(?:lOnPasswordChang|ntenanc)|vhostMaintenanc)e|d(?:isablePersistentStorage|biDynamicHashEnabled)|br(?:owsersDontStorePassword|uteForceProtection)|(?:(?:globalLogout|active)Tim|wsdlServ)er|h(?:ideOldPassword|ttpOnly)|yubikey2fUserCanRemoveKey|krb(?:RemoveDomain|ByJs))$/;
our @sessionTypes = ( 'remoteGlobal', 'global', 'localSession', 'persistent', 'saml', 'oidc', 'cas' );

View File

@ -1,7 +1,7 @@
# This file is generated by Lemonldap::NG::Manager::Build. Don't modify it by hand
package Lemonldap::NG::Common::Conf::DefaultValues;
our $VERSION = '2.0.7';
our $VERSION = '2.0.8';
sub defaultValues {
return {

View File

@ -5,7 +5,7 @@ use strict;
use Exporter 'import';
use base qw(Exporter);
our $VERSION = '2.0.7';
our $VERSION = '2.0.8';
our %EXPORT_TAGS = ( 'all' => [qw($simpleHashKeys $doubleHashKeys $specialNodeKeys $casAppMetaDataNodeKeys $casSrvMetaDataNodeKeys $oidcOPMetaDataNodeKeys $oidcRPMetaDataNodeKeys $samlIDPMetaDataNodeKeys $samlSPMetaDataNodeKeys $virtualHostKeys $specialNodeHash $authParameters $issuerParameters $samlServiceParameters $oidcServiceParameters $casServiceParameters)] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );

View File

@ -4,7 +4,7 @@ package Lemonldap::NG::Handler::Lib::StatusConstants;
use strict;
use Exporter 'import';
our $VERSION = '2.0.7';
our $VERSION = '2.0.8';
sub portalConsts {
return {

View File

@ -1,7 +1,7 @@
# This file is generated by Lemonldap::NG::Manager::Build. Don't modify it by hand
package Lemonldap::NG::Manager::Attributes;
our $VERSION = '2.0.7';
our $VERSION = '2.0.8';
sub perlExpr {
my ( $val, $conf ) = @_;
@ -968,6 +968,10 @@ qr/(?:(?:https?):\/\/(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.]
},
'type' => 'cmbModuleContainer'
},
'compactConf' => {
'default' => 0,
'type' => 'bool'
},
'configStorage' => {
'type' => 'text'
},
@ -1185,10 +1189,6 @@ qr/(?:(?:https?):\/\/(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.]
qr/^(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-zA-Z0-9]*[a-zA-Z0-9]|[a-zA-Z])[.]?))?$/,
'type' => 'text'
},
'dontCompactConf' => {
'default' => 0,
'type' => 'bool'
},
'exportedAttr' => {
'type' => 'text'
},

View File

@ -6,7 +6,7 @@
package Lemonldap::NG::Manager::Build::Attributes;
our $VERSION = '2.0.7';
our $VERSION = '2.0.8';
use strict;
use Regexp::Common qw/URI/;
@ -390,7 +390,7 @@ sub attributes {
msgFail => '__badUrl__',
documentation => 'URL to call on reload',
},
dontCompactConf => {
compactConf => {
type => 'bool',
default => 0,
documentation => 'Don t compact configuration',

View File

@ -17,7 +17,7 @@
package Lemonldap::NG::Manager::Build::Tree;
our $VERSION = '2.0.7';
our $VERSION = '2.0.8';
# TODO: Missing:
# * activeTimer
@ -571,7 +571,7 @@ sub tree {
title => 'reloadParams',
help => 'configlocation.html#configuration_reload',
nodes =>
[ 'reloadUrls', 'reloadTimeout', 'dontCompactConf' ]
[ 'reloadUrls', 'reloadTimeout', 'compactConf' ]
},
{
title => 'plugins',

View File

@ -26,7 +26,7 @@ use JSON 'to_json';
use Lemonldap::NG::Common::Conf::ReConstants;
use Lemonldap::NG::Manager::Attributes;
our $VERSION = '2.0.7';
our $VERSION = '2.0.8';
extends 'Lemonldap::NG::Common::Conf::Compact';
@ -115,19 +115,19 @@ sub check {
$self->message('__confNotChanged__');
return 0;
}
unless ( $self->newConf->{dontCompactConf} ) {
if ( $self->newConf->{compactConf} ) {
foreach ( sort keys %conf ) {
push @removedKeys, $_ unless exists $compactedConf{$_};
}
}
push @{ $self->changes },
(
$self->{newConf}->{dontCompactConf}
? { confCompacted => '0' }
: {
$self->{newConf}->{compactConf}
? {
confCompacted => '1',
removedKeys => join( $separator, @removedKeys )
}
}
: { confCompacted => '0' }
);
return 1;
}
@ -266,7 +266,8 @@ sub _scanNodes {
$leaf->{comment}
? "(?#$leaf->{comment})$leaf->{re}"
: $leaf->{re};
$k .= "(?#AuthnLevel=$leaf->{level})" if $leaf->{level};
$k .= "(?#AuthnLevel=$leaf->{level})"
if $leaf->{level};
$self->set( $target, $key, $k, $leaf->{data} );
}
else {
@ -334,7 +335,9 @@ sub _scanNodes {
hdebug(" SAML data is an array, serializing");
$leaf->{data} = join ';', @{ $leaf->{data} };
}
if ( $target =~ /^saml(?:S|ID)PMetaData(?:ExportedAttributes|Macros)$/ ) {
if ( $target =~
/^saml(?:S|ID)PMetaData(?:ExportedAttributes|Macros)$/ )
{
if ( $leaf->{cnodes} ) {
hdebug(" $target: unopened node");
$self->newConf->{$target}->{$key} =
@ -394,7 +397,9 @@ sub _scanNodes {
hdebug(" $target");
$self->set( $target, $key, $leaf->{data} );
}
elsif ( $target =~ /^oidc(?:O|R)PMetaData(?:ExportedVars|Macros)$/ ) {
elsif (
$target =~ /^oidc(?:O|R)PMetaData(?:ExportedVars|Macros)$/ )
{
hdebug(" $target");
if ( $leaf->{cnodes} ) {
hdebug(' unopened');
@ -463,7 +468,9 @@ sub _scanNodes {
$self->_scanNodes($subNodes);
$self->set( $target, $key, $leaf->{title}, $leaf->{data} );
}
elsif ( $target =~ /^cas(?:App|Srv)MetaData(?:ExportedVars|Macros)$/ ) {
elsif ( $target =~
/^cas(?:App|Srv)MetaData(?:ExportedVars|Macros)$/ )
{
hdebug(" $target");
if ( $leaf->{cnodes} ) {
hdebug(' unopened');

View File

@ -273,7 +273,7 @@
"dateTitle":"تاريخ",
"dn":"دي أن",
"domain":"نطاق",
"dontCompactConf":"Don't compact configuration file",
"compactConf":"Compact configuration file",
"download":"تحميل",
"downloadIt":"نزله",
"duplicate":"مكررة",

View File

@ -273,7 +273,7 @@
"dateTitle":"Dates",
"dn":"DN",
"domain":"Domain",
"dontCompactConf":"Don't compact configuration file",
"compactConf":"Compact configuration file",
"download":"Download",
"downloadIt":"Download it",
"duplicate":"Duplicate",

View File

@ -273,7 +273,7 @@
"dateTitle":"Dates",
"dn":"DN",
"domain":"Domain",
"dontCompactConf":"Don't compact configuration file",
"compactConf":"Compact configuration file",
"download":"Download",
"downloadIt":"Download it",
"duplicate":"Duplicate",

View File

@ -273,7 +273,7 @@
"dateTitle":"Dates",
"dn":"DN",
"domain":"Domaine",
"dontCompactConf":"Ne pas compacter le fichier de configuration",
"compactConf":"Compacter le fichier de configuration",
"download":"Télécharger",
"downloadIt":"Télécharger",
"duplicate":"Dupliquer",

View File

@ -273,7 +273,7 @@
"dateTitle":"Date",
"dn":"DN",
"domain":"Dominio",
"dontCompactConf":"Don't compact configuration file",
"compactConf":"Compact configuration file",
"download":"Scarica",
"downloadIt":"Scaricalo",
"duplicate":"Duplicato",

View File

@ -273,7 +273,7 @@
"dateTitle":"Tarihler",
"dn":"DN",
"domain":"Etki alanı",
"dontCompactConf":"Yapılandırma dosyasını sıkıştırma",
"compactConf":"Compact configuration file",
"download":"İndir",
"downloadIt":"İndir",
"duplicate":"Mükerrer",

View File

@ -273,7 +273,7 @@
"dateTitle":"Ngày",
"dn":"DN",
"domain":"Tên miền",
"dontCompactConf":"Don't compact configuration file",
"compactConf":"Compact configuration file",
"download":"Tải xuống",
"downloadIt":"Tải xuống",
"duplicate":"Sao y",

View File

@ -273,7 +273,7 @@
"dateTitle":"日期",
"dn":"LDAP 唯一名称",
"domain":"域",
"dontCompactConf":"Don't compact configuration file",
"compactConf":"Compact configuration file",
"download":"下载",
"downloadIt":"下载它",
"duplicate":"Duplicate",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -154,6 +154,7 @@
},
"portal": "http://auth.example.com/",
"reloadUrls": {},
"compactConf": 1,
"securedCookie": 0,
"sessionDataToRemember": {},
"timeout": 72000,

View File

@ -1379,6 +1379,12 @@
"title": "reloadUrls",
"type": "keyTextContainer"
}, {
"default": 0,
"id": "compactConf",
"title": "compactConf",
"type": "bool",
"data": 1
}, {
"id": "advancedParams",
"title": "advancedParams",
"nodes": [{

View File

@ -1380,6 +1380,12 @@
"id": "reloadUrls",
"title": "reloadUrls",
"type": "keyTextContainer"
}, {
"default": 0,
"id": "compactConf",
"title": "compactConf",
"type": "bool",
"data": 1
}, {
"id": "advancedParams",
"title": "advancedParams",

View File

@ -1209,10 +1209,19 @@
"id": "sessionParams",
"title": "sessionParams"
}, {
"cnodes": "reloadUrls",
"id": "reloadUrls",
"title": "reloadUrls",
"type": "keyTextContainer"
"_nodes": [{
"cnodes": "reloadUrls",
"id": "reloadUrls",
"title": "reloadUrls",
"type": "keyTextContainer"
}, {
"default": 0,
"id": "compactConf",
"title": "compactConf",
"type": "bool"
}],
"id": "reloadParams",
"title": "reloadParams"
}, {
"_nodes": [{
"id": "customFunctions",

View File

@ -4,7 +4,7 @@ package Lemonldap::NG::Portal::Main::Constants;
use strict;
use Exporter 'import';
our $VERSION = '2.0.7';
our $VERSION = '2.0.8';
use constant HANDLER => 'Lemonldap::NG::Handler::PSGI::Main';
use constant {

View File

@ -150,6 +150,7 @@ sub sp {
portal => 'http://auth.sp.com',
authentication => 'CAS',
userDB => 'CAS',
compactConf => 1,
restSessionServer => 1,
issuerDBCASActivation => 0,
multiValuesSeparator => ';',