|
|
@ -123,7 +123,7 @@ sub newRSAKey { |
|
|
|
my $keys = { |
|
|
|
my $keys = { |
|
|
|
'private' => $rsa->get_private_key_string(), |
|
|
|
'private' => $rsa->get_private_key_string(), |
|
|
|
'public' => $rsa->get_public_key_x509_string(), |
|
|
|
'public' => $rsa->get_public_key_x509_string(), |
|
|
|
'hash' => md5_base64($rsa->get_public_key_string()), |
|
|
|
'hash' => md5_base64( $rsa->get_public_key_string() ), |
|
|
|
}; |
|
|
|
}; |
|
|
|
if ( $query->{password} ) { |
|
|
|
if ( $query->{password} ) { |
|
|
|
my $pem = Convert::PEM->new( |
|
|
|
my $pem = Convert::PEM->new( |
|
|
@ -345,26 +345,25 @@ sub newConf { |
|
|
|
|
|
|
|
|
|
|
|
# Body must be json |
|
|
|
# Body must be json |
|
|
|
my $new = $req->jsonBodyToObj; |
|
|
|
my $new = $req->jsonBodyToObj; |
|
|
|
unless ( defined($new) ) { |
|
|
|
return $self->sendError( $req, undef, 400 ) unless ( defined $new ); |
|
|
|
return $self->sendError( $req, undef, 400 ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Verify that cfgNum has been asked |
|
|
|
# Verify that cfgNum has been sent |
|
|
|
unless ( defined $req->params('cfgNum') ) { |
|
|
|
return $self->sendError( $req, "Missing configuration number", 400 ) |
|
|
|
return $self->sendError( $req, "Missing configuration number", 400 ); |
|
|
|
unless ( defined $req->params('cfgNum') ); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# # Verify that cfgDate has been sent |
|
|
|
|
|
|
|
# return $self->sendError( $req, "Missing configuration date", 400 ) |
|
|
|
|
|
|
|
# unless ( defined $req->params('cfgDate') ); |
|
|
|
|
|
|
|
|
|
|
|
# Set current conf to cfgNum |
|
|
|
# Set current conf to cfgNum |
|
|
|
unless ( defined $self->getConfByNum( $req->params('cfgNum') ) ) { |
|
|
|
return $self->sendError( |
|
|
|
return $self->sendError( |
|
|
|
$req, |
|
|
|
$req, |
|
|
|
"Configuration " |
|
|
|
"Configuration " |
|
|
|
. $req->params('cfgNum') |
|
|
|
. $req->params('cfgNum') |
|
|
|
. " not available " |
|
|
|
. " not available " |
|
|
|
. $Lemonldap::NG::Common::Conf::msg, |
|
|
|
. $Lemonldap::NG::Common::Conf::msg, |
|
|
|
400 |
|
|
|
400 |
|
|
|
) unless ( defined $self->getConfByNum( $req->params('cfgNum') ) ); |
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Parse new conf |
|
|
|
# Parse new conf |
|
|
|
require Lemonldap::NG::Manager::Conf::Parser; |
|
|
|
require Lemonldap::NG::Manager::Conf::Parser; |
|
|
@ -372,13 +371,20 @@ sub newConf { |
|
|
|
{ tree => $new, refConf => $self->currentConf, req => $req } ); |
|
|
|
{ tree => $new, refConf => $self->currentConf, req => $req } ); |
|
|
|
|
|
|
|
|
|
|
|
# If ref conf isn't last conf, consider conf changed |
|
|
|
# If ref conf isn't last conf, consider conf changed |
|
|
|
my $cfgNum = $self->confAcc->lastCfg; |
|
|
|
my $currentCfgNum = $self->confAcc->lastCfg; |
|
|
|
unless ( defined $cfgNum ) { |
|
|
|
$req->error($Lemonldap::NG::Common::Conf::msg) |
|
|
|
$req->error($Lemonldap::NG::Common::Conf::msg); |
|
|
|
unless ( defined $currentCfgNum ); |
|
|
|
} |
|
|
|
|
|
|
|
return $self->sendError( $req, undef, 400 ) if ( $req->error ); |
|
|
|
return $self->sendError( $req, undef, 400 ) if ( $req->error ); |
|
|
|
|
|
|
|
my $currentConf = |
|
|
|
if ( $cfgNum ne $req->params('cfgNum') ) { $parser->confChanged(1); } |
|
|
|
$self->confAcc->getConf( |
|
|
|
|
|
|
|
{ CfgNum => $currentCfgNum, raw => 1, noCache => 1 } ); |
|
|
|
|
|
|
|
my $currentCfgDate = $currentConf->{cfgDate}; |
|
|
|
|
|
|
|
$self->logger->debug( |
|
|
|
|
|
|
|
"Current CfgNum/cfgDate: $currentCfgNum/$currentCfgDate"); |
|
|
|
|
|
|
|
$parser->confChanged(1) |
|
|
|
|
|
|
|
if ( $currentCfgNum ne $req->params('cfgNum') |
|
|
|
|
|
|
|
|| $req->params('cfgDate') |
|
|
|
|
|
|
|
&& $req->params('cfgDate') ne $currentCfgDate ); |
|
|
|
|
|
|
|
|
|
|
|
my $res = { result => $parser->check( $self->p ) }; |
|
|
|
my $res = { result => $parser->check( $self->p ) }; |
|
|
|
|
|
|
|
|
|
|
@ -402,6 +408,10 @@ sub newConf { |
|
|
|
else { |
|
|
|
else { |
|
|
|
my %args; |
|
|
|
my %args; |
|
|
|
$args{force} = 1 if ( $req->params('force') ); |
|
|
|
$args{force} = 1 if ( $req->params('force') ); |
|
|
|
|
|
|
|
if ( $req->params('cfgDate') ) { |
|
|
|
|
|
|
|
$args{cfgDate} = $req->params('cfgDate'); |
|
|
|
|
|
|
|
$args{currentCfgDate} = $currentCfgDate; |
|
|
|
|
|
|
|
} |
|
|
|
my $s = CONFIG_WAS_CHANGED; |
|
|
|
my $s = CONFIG_WAS_CHANGED; |
|
|
|
$s = $self->confAcc->saveConf( $parser->newConf, %args ) |
|
|
|
$s = $self->confAcc->saveConf( $parser->newConf, %args ) |
|
|
|
unless ( @{ $parser->{needConfirmation} } && !$args{force} ); |
|
|
|
unless ( @{ $parser->{needConfirmation} } && !$args{force} ); |
|
|
|