Manager API - get SAML sp #2034
This commit is contained in:
parent
cd93caef72
commit
e5a45f505b
|
@ -39,6 +39,9 @@ sub addRoutes {
|
|||
oidc => {
|
||||
rp => { ':confKey' => 'getOidcRpByConfKey' },
|
||||
},
|
||||
saml => {
|
||||
sp => { ':confKey' => 'getSamlSpByConfKey' },
|
||||
},
|
||||
},
|
||||
},
|
||||
['GET']
|
||||
|
|
|
@ -22,7 +22,7 @@ sub getOidcRpByConfKey {
|
|||
|
||||
# Check if confKey is defined
|
||||
if ( !defined $conf->{oidcRPMetaDataOptions}->{$confKey} ) {
|
||||
return $self->sendError( $req, 'Service Provider not found', 404 );
|
||||
return $self->sendError( $req, "OIDC relying party '$confKey' not found", 404 );
|
||||
}
|
||||
|
||||
# Get Client ID
|
||||
|
@ -50,4 +50,72 @@ sub getOidcRpByConfKey {
|
|||
);
|
||||
}
|
||||
|
||||
sub getSamlSpByConfKey {
|
||||
my ( $self, $req ) = @_;
|
||||
|
||||
my $confKey = $req->params('confKey')
|
||||
or return $self->sendError( $req, 'confKey is missing', 400 );
|
||||
|
||||
$self->logger->debug("[API] SAML SP $confKey configuration requested");
|
||||
|
||||
# Get latest configuration
|
||||
my $conf = $self->_confAcc->getConf;
|
||||
|
||||
# Check if confKey is defined
|
||||
if ( !defined $conf->{samlSPMetaDataXML}->{$confKey} ) {
|
||||
return $self->sendError( $req, "SAML service Provider '$confKey' not found", 404 );
|
||||
}
|
||||
|
||||
# Get metadata
|
||||
my $metadata = $conf->{samlSPMetaDataXML}->{$confKey}
|
||||
->{samlSPMetaDataXML};
|
||||
|
||||
# Get exported attributes
|
||||
my %exportedAttributes;
|
||||
foreach (
|
||||
keys %{
|
||||
$conf->{samlSPMetaDataExportedAttributes}
|
||||
->{$confKey}
|
||||
}
|
||||
)
|
||||
{
|
||||
# Extract fields from exportedAttr value
|
||||
my ( $mandatory, $name, $format, $friendly_name ) =
|
||||
split( /;/,
|
||||
$conf->{samlSPMetaDataExportedAttributes}
|
||||
->{$confKey}->{$_} );
|
||||
|
||||
$mandatory = !!$mandatory ? 'true' : 'false';
|
||||
|
||||
$exportedAttributes->{$_} = {
|
||||
name => $name,
|
||||
mandatory => $mandatory
|
||||
};
|
||||
|
||||
if (defined $friendly_name && $friendly_name ne '') {
|
||||
$exportedAttributes->{$_}->{friendlyName} = $friendly_name;
|
||||
}
|
||||
|
||||
if (defined $format && $format ne '') {
|
||||
$exportedAttributes->{$_}->{format} = $format;
|
||||
}
|
||||
}
|
||||
|
||||
# Dump object
|
||||
use Data::Dumper; print STDERR Dumper($exportedAttributes);
|
||||
|
||||
# Get options
|
||||
my $options = $conf->{samlSPMetaDataOptions}->{$confKey};
|
||||
|
||||
return $self->sendJSONresponse(
|
||||
$req,
|
||||
{
|
||||
confKey => $confKey,
|
||||
metadata => $metadata,
|
||||
exportedAttributes => $exportedAttributes,
|
||||
options => $options
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
Loading…
Reference in New Issue
Block a user