Start OIDC RP API (#2034)

lowercase-endpoints
Clément OUDOT 6 years ago
parent 0c11dedc44
commit 7a61750eb3
  1. 23
      lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Api.pm
  2. 39
      lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Api/Providers.pm

@ -25,13 +25,22 @@ sub addRoutes {
$self->addRoute( 'api.html', undef, ['GET'] )
->addRoute(
api => {
v1 => {
hello => "helloworld",
},
},
['GET']
api => {
v1 => {
hello => "helloworld",
},
},
['GET']
)
->addRoute(
providers => {
oidc => {
rp => { ':confKey' => 'getOidcRpByConfKey' },
},
},
['GET']
);
}
}
1;

@ -3,4 +3,43 @@ our $VERSION = '2.0.7';
package Lemonldap::NG::Manager::Api;
sub getOidcRpByConfKey {
my ( $self, $req ) = @_;
my $confKey = $req->params('confKey')
or return $self->sendError( $req, 'confKey is missing', 400 );
$self->logger->debug("[API] OIDC RP $confKey configuration requested");
# Get latest configuration
my $conf = $self->_confAcc->getConf;
# To save configuration
#$self->_confAcc->saveConf( $conf ) ;
# Dump object
#use Data::Dumper; print STDERR Dumper($self);
# Check if confKey is defined
if ( !defined $conf->{oidcRPMetaDataOptions}->{$confKey} ) {
return $self->sendError( $req, 'Service Provider not found', 404 );
}
# Get Client ID
my $clientId = $conf->{oidcRPMetaDataOptions}->{$confKey}
->{oidcRPMetaDataOptionsClientID};
# Get exported vars
my $exportedVars = $conf->{oidcRPMetaDataExportedVars}->{$confKey};
return $self->sendJSONresponse(
$req,
{
confKey => $confKey,
clientId => $clientId,
exportedVars => $exportedVars
}
);
}
1;

Loading…
Cancel
Save