2019-11-08 18:31:50 +01:00
|
|
|
# This module implements all the methods that responds to '/api/*' requests
|
|
|
|
package Lemonldap::NG::Manager::Api;
|
|
|
|
|
|
|
|
use 5.10.0;
|
|
|
|
use utf8;
|
|
|
|
use Mouse;
|
|
|
|
|
2020-01-27 18:32:59 +01:00
|
|
|
extends 'Lemonldap::NG::Manager::Plugin',
|
|
|
|
'Lemonldap::NG::Common::Conf::RESTServer',
|
2019-12-19 16:52:51 +01:00
|
|
|
'Lemonldap::NG::Common::Session::REST';
|
2019-11-08 18:31:50 +01:00
|
|
|
|
|
|
|
use Lemonldap::NG::Manager::Api::2F;
|
2019-12-17 09:56:59 +01:00
|
|
|
use Lemonldap::NG::Manager::Api::Providers::OidcRp;
|
|
|
|
use Lemonldap::NG::Manager::Api::Providers::SamlSp;
|
2019-11-08 18:31:50 +01:00
|
|
|
|
2020-02-20 23:24:22 +01:00
|
|
|
our $VERSION = '2.0.8';
|
2019-11-08 18:31:50 +01:00
|
|
|
|
|
|
|
#############################
|
|
|
|
# I. INITIALIZATION METHODS #
|
|
|
|
#############################
|
|
|
|
|
|
|
|
use constant defaultRoute => 'api.html';
|
|
|
|
|
2020-01-27 18:32:59 +01:00
|
|
|
sub init {
|
2019-11-08 18:31:50 +01:00
|
|
|
my ( $self, $conf ) = @_;
|
|
|
|
|
|
|
|
# HTML template
|
|
|
|
$self->addRoute( 'api.html', undef, ['GET'] )
|
|
|
|
|
2019-12-04 17:50:41 +01:00
|
|
|
->addRoute(
|
2019-12-18 16:45:42 +01:00
|
|
|
api => {
|
|
|
|
v1 => {
|
|
|
|
providers => {
|
|
|
|
oidc => {
|
|
|
|
rp => {
|
|
|
|
findByConfKey => {
|
|
|
|
':uPattern' => 'findOidcRpByConfKey'
|
|
|
|
},
|
|
|
|
findByClientId => {
|
|
|
|
':uClientId' => 'findOidcRpByClientId'
|
|
|
|
},
|
|
|
|
':confKey' => 'getOidcRpByConfKey'
|
2019-12-05 15:59:53 +01:00
|
|
|
},
|
2019-12-05 15:06:33 +01:00
|
|
|
},
|
2019-12-18 16:45:42 +01:00
|
|
|
saml => {
|
|
|
|
sp => {
|
|
|
|
findByConfKey => {
|
|
|
|
':uPattern' => 'findSamlSpByConfKey'
|
|
|
|
},
|
|
|
|
findByEntityId => {
|
|
|
|
':uEntityId' => 'findSamlSpByEntityId'
|
|
|
|
},
|
|
|
|
':confKey' => 'getSamlSpByConfKey'
|
2019-12-05 15:06:33 +01:00
|
|
|
},
|
|
|
|
},
|
2019-12-05 12:40:03 +01:00
|
|
|
},
|
2019-12-19 16:52:51 +01:00
|
|
|
secondFactor => {
|
|
|
|
':uid' => {
|
|
|
|
id => {
|
|
|
|
':id' => 'getSecondFactorsById'
|
|
|
|
},
|
|
|
|
type => {
|
|
|
|
':type' => 'getSecondFactorsByType'
|
|
|
|
},
|
|
|
|
'*' => 'getSecondFactors'
|
|
|
|
},
|
|
|
|
},
|
2019-12-04 17:50:41 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
['GET']
|
2019-12-06 11:38:02 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
->addRoute(
|
2019-12-18 16:45:42 +01:00
|
|
|
api => {
|
|
|
|
v1 => {
|
|
|
|
providers => {
|
|
|
|
oidc => {
|
|
|
|
rp => 'addOidcRp'
|
|
|
|
},
|
|
|
|
saml => {
|
|
|
|
sp => 'addSamlSp'
|
|
|
|
},
|
2019-12-06 11:38:02 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
['POST']
|
2019-12-09 09:16:21 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
->addRoute(
|
2019-12-18 16:45:42 +01:00
|
|
|
api => {
|
|
|
|
v1 => {
|
|
|
|
providers => {
|
|
|
|
oidc => {
|
2019-12-20 11:13:15 +01:00
|
|
|
rp => { ':confKey' => 'replaceOidcRp' }
|
2019-12-18 16:45:42 +01:00
|
|
|
},
|
|
|
|
saml => {
|
2019-12-20 11:13:15 +01:00
|
|
|
sp => { ':confKey' => 'replaceSamlSp' }
|
2019-12-18 16:45:42 +01:00
|
|
|
},
|
2019-12-09 09:16:21 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
['PUT']
|
|
|
|
)
|
|
|
|
|
|
|
|
->addRoute(
|
2019-12-18 16:45:42 +01:00
|
|
|
api => {
|
|
|
|
v1 => {
|
|
|
|
providers => {
|
|
|
|
oidc => {
|
2019-12-20 11:13:15 +01:00
|
|
|
rp => { ':confKey' => 'updateOidcRp' }
|
2019-12-18 16:45:42 +01:00
|
|
|
},
|
|
|
|
saml => {
|
2019-12-20 11:13:15 +01:00
|
|
|
sp => { ':confKey' => 'updateSamlSp' }
|
2019-12-18 16:45:42 +01:00
|
|
|
},
|
2019-12-09 09:16:21 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
['PATCH']
|
2019-12-09 20:32:54 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
->addRoute(
|
2019-12-18 16:45:42 +01:00
|
|
|
api => {
|
|
|
|
v1 => {
|
|
|
|
providers => {
|
|
|
|
oidc => {
|
2019-12-20 11:13:15 +01:00
|
|
|
rp => { ':confKey' => 'deleteOidcRp' }
|
2019-12-18 16:45:42 +01:00
|
|
|
},
|
|
|
|
saml => {
|
2019-12-20 11:13:15 +01:00
|
|
|
sp => { ':confKey' => 'deleteSamlSp' }
|
2019-12-18 16:45:42 +01:00
|
|
|
},
|
2019-12-09 20:32:54 +01:00
|
|
|
},
|
2019-12-19 16:52:51 +01:00
|
|
|
secondFactor => {
|
|
|
|
':uid' => {
|
|
|
|
id => {
|
|
|
|
':id' => 'deleteSecondFactorsById'
|
|
|
|
},
|
|
|
|
type => {
|
|
|
|
':type' => 'deleteSecondFactorsByType'
|
|
|
|
},
|
|
|
|
'*' => 'deleteSecondFactors'
|
|
|
|
},
|
|
|
|
},
|
2019-12-09 20:32:54 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
['DELETE']
|
2019-11-08 18:31:50 +01:00
|
|
|
);
|
2019-12-19 16:52:51 +01:00
|
|
|
|
2019-12-20 11:13:15 +01:00
|
|
|
$self->setTypes($conf);
|
|
|
|
$self->{multiValuesSeparator} ||= '; ';
|
|
|
|
$self->{hiddenAttributes} //= "_password";
|
|
|
|
$self->{TOTPCheck} = $self->{U2FCheck} = $self->{UBKCheck} = '1';
|
2020-01-27 18:32:59 +01:00
|
|
|
return 1;
|
2019-12-04 17:50:41 +01:00
|
|
|
}
|
2019-11-08 18:31:50 +01:00
|
|
|
|
|
|
|
1;
|