2019-03-12 16:33:09 +01:00
|
|
|
# This module implements all the methods that responds to '/confs/*' requests
|
|
|
|
# It contains 2 sections:
|
|
|
|
# - initialization methods
|
|
|
|
# - upload method
|
|
|
|
#
|
|
|
|
# Read methods are inherited from Lemonldap::NG::Common::Conf::RESTServer
|
|
|
|
package Lemonldap::NG::Manager::Viewer;
|
|
|
|
|
|
|
|
use 5.10.0;
|
|
|
|
use utf8;
|
|
|
|
use Mouse;
|
|
|
|
use Lemonldap::NG::Common::Conf::Constants;
|
|
|
|
use Lemonldap::NG::Common::UserAgent;
|
|
|
|
use URI::URL;
|
|
|
|
|
|
|
|
use feature 'state';
|
|
|
|
|
2019-03-14 16:39:49 +01:00
|
|
|
extends 'Lemonldap::NG::Manager::Conf';
|
2019-03-12 16:33:09 +01:00
|
|
|
|
2019-03-13 22:56:16 +01:00
|
|
|
our $VERSION = '2.0.3';
|
2019-03-12 16:33:09 +01:00
|
|
|
|
|
|
|
#############################
|
|
|
|
# I. INITIALIZATION METHODS #
|
|
|
|
#############################
|
|
|
|
|
|
|
|
use constant defaultRoute => 'viewer.html';
|
|
|
|
|
|
|
|
has ua => ( is => 'rw' );
|
|
|
|
|
|
|
|
sub addRoutes {
|
|
|
|
my ( $self, $conf ) = @_;
|
|
|
|
$self->ua( Lemonldap::NG::Common::UserAgent->new($conf) );
|
|
|
|
|
2019-03-13 22:56:16 +01:00
|
|
|
my @enabledPK = ();
|
|
|
|
my @keys = qw(virtualHosts samlIDPMetaDataNodes samlSPMetaDataNodes
|
|
|
|
applicationList oidcOPMetaDataNodes oidcRPMetaDataNodes
|
|
|
|
casSrvMetaDataNodes casAppMetaDataNodes
|
|
|
|
authChoiceModules grantSessionRules combModules
|
|
|
|
openIdIDPList);
|
|
|
|
|
|
|
|
foreach (@keys) {
|
|
|
|
|
|
|
|
# Ignore hidden ConfTree Primary Keys
|
|
|
|
push @enabledPK, $_
|
2019-03-19 17:56:23 +01:00
|
|
|
unless ( $self->{viewerHiddenPK} =~ /\b$_\b/ );
|
2019-03-13 22:56:16 +01:00
|
|
|
}
|
|
|
|
|
2019-03-12 16:33:09 +01:00
|
|
|
# HTML template
|
|
|
|
$self->addRoute( 'viewer.html', undef, ['GET'] )
|
|
|
|
|
|
|
|
# READ
|
|
|
|
# Special keys
|
|
|
|
->addRoute(
|
2019-03-12 22:59:15 +01:00
|
|
|
view => {
|
2019-03-13 22:56:16 +01:00
|
|
|
':cfgNum' => \@enabledPK
|
2019-03-12 16:33:09 +01:00
|
|
|
},
|
|
|
|
['GET']
|
2019-03-19 17:56:23 +01:00
|
|
|
);
|
2019-03-12 16:33:09 +01:00
|
|
|
|
2019-03-19 17:56:23 +01:00
|
|
|
foreach ( split /\s+/, $self->{viewerHiddenPK} ) {
|
|
|
|
$self->addRoute(
|
|
|
|
view => { ':cfgNum' => { $_ => 'rejectKey' } },
|
|
|
|
['GET']
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
# Other keys
|
|
|
|
$self->addRoute( view => { ':cfgNum' => { '*' => 'getKey' } }, ['GET'] )
|
2019-03-12 16:33:09 +01:00
|
|
|
|
2019-03-15 15:39:41 +01:00
|
|
|
# Difference between confs
|
|
|
|
->addRoute( diff => { ':conf1' => { ':conf2' => 'diff' } } )
|
|
|
|
->addRoute( 'diff.html', undef, ['GET'] );
|
2019-03-12 16:33:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sub getConfByNum {
|
|
|
|
my ( $self, $cfgNum, @args ) = @_;
|
2019-03-14 16:39:49 +01:00
|
|
|
$self->SUPER::getConfByNum( $cfgNum, @args );
|
2019-03-12 16:33:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sub diff {
|
|
|
|
my ( $self, $req, @path ) = @_;
|
2019-03-14 16:39:49 +01:00
|
|
|
$self->SUPER::diff( $req, @path );
|
2019-03-12 16:33:09 +01:00
|
|
|
}
|
|
|
|
|
2019-03-19 17:56:23 +01:00
|
|
|
sub rejectKey {
|
|
|
|
my ( $self, $req ) = @_;
|
|
|
|
return $self->sendJSONresponse( $req, { 'value' => '_Hidden_' } );
|
|
|
|
}
|
|
|
|
|
2019-03-12 16:33:09 +01:00
|
|
|
1;
|