2019-12-21 11:40:47 +01:00
|
|
|
use lib 'inc';
|
|
|
|
use Test::More;
|
|
|
|
use strict;
|
|
|
|
use IO::String;
|
|
|
|
use LWP::UserAgent;
|
|
|
|
use LWP::Protocol::PSGI;
|
|
|
|
use MIME::Base64;
|
|
|
|
use JSON;
|
|
|
|
|
|
|
|
BEGIN {
|
|
|
|
require 't/test-lib.pm';
|
2020-02-05 22:44:14 +01:00
|
|
|
require 't/oidc-lib.pm';
|
2019-12-21 11:40:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
my $debug = 'error';
|
|
|
|
my $res;
|
|
|
|
|
|
|
|
# Initialization
|
|
|
|
ok( my $op = op(), 'OP portal' );
|
|
|
|
|
|
|
|
my $register_data = {
|
|
|
|
"application_type" => "web",
|
|
|
|
"redirect_uris" => [
|
|
|
|
"https://client.example.org/callback",
|
|
|
|
"https://client.example.org/callback2"
|
|
|
|
],
|
|
|
|
"client_name" => "My Example",
|
|
|
|
"logo_uri" => "https://client.example.org/logo.png",
|
|
|
|
"subject_type" => "pairwise",
|
|
|
|
"token_endpoint_auth_method" => "client_secret_basic",
|
|
|
|
};
|
|
|
|
|
|
|
|
my $register_data_json = JSON::to_json($register_data);
|
|
|
|
|
|
|
|
ok(
|
|
|
|
$res = $op->_post(
|
|
|
|
"/oauth2/register",
|
|
|
|
IO::String->new($register_data_json),
|
|
|
|
accept => 'application/json',
|
|
|
|
length => length($register_data_json),
|
|
|
|
),
|
|
|
|
"Post register data"
|
|
|
|
);
|
|
|
|
|
|
|
|
ok( $res->[0] == 201, "Return code is 201" );
|
|
|
|
my $register_answer = JSON::from_json( $res->[2]->[0] );
|
|
|
|
|
|
|
|
ok( defined $register_answer->{client_id},
|
|
|
|
"Client ID found in answer: " . $register_answer->{client_id} );
|
|
|
|
|
|
|
|
# New configuration registered
|
2020-01-07 19:07:30 +01:00
|
|
|
my $confFile = "$main::tmpDir/lmConf-2.json";
|
2019-12-21 11:40:47 +01:00
|
|
|
my $conf = JSON::from_json(`cat $confFile`);
|
|
|
|
|
|
|
|
# Check saved data
|
|
|
|
my $rpId = ( keys %{ $conf->{oidcRPMetaDataOptions} } )[0];
|
|
|
|
|
|
|
|
ok(
|
|
|
|
$conf->{oidcRPMetaDataOptions}->{$rpId}->{oidcRPMetaDataOptionsClientID} eq
|
|
|
|
$register_answer->{client_id},
|
|
|
|
"Client ID saved in configuration"
|
|
|
|
);
|
|
|
|
|
2019-12-21 12:08:48 +01:00
|
|
|
# Check extra claims and extra attributes
|
|
|
|
ok(
|
|
|
|
$conf->{oidcRPMetaDataOptionsExtraClaims}->{$rpId}->{"extra_claim"} eq
|
|
|
|
"extra_var",
|
|
|
|
"Extra claim defined"
|
|
|
|
);
|
|
|
|
ok( $conf->{oidcRPMetaDataExportedVars}->{$rpId}->{"extra_var"} eq "mail",
|
|
|
|
"Extra variable defined" );
|
|
|
|
|
2019-12-21 11:40:47 +01:00
|
|
|
unlink $confFile;
|
|
|
|
clean_sessions();
|
|
|
|
done_testing();
|
|
|
|
|
|
|
|
sub op {
|
2020-01-07 19:07:30 +01:00
|
|
|
return LLNG::Manager::Test->new( {
|
2019-12-21 11:40:47 +01:00
|
|
|
ini => {
|
|
|
|
logLevel => $debug,
|
|
|
|
domain => 'idp.com',
|
|
|
|
portal => 'http://auth.op.com',
|
|
|
|
authentication => 'Demo',
|
|
|
|
userDB => 'Same',
|
|
|
|
issuerDBOpenIDConnectActivation => 1,
|
|
|
|
issuerDBOpenIDConnectRule => '$uid eq "french"',
|
|
|
|
oidcRPMetaDataExportedVars => {
|
|
|
|
rp => {
|
|
|
|
email => "mail",
|
|
|
|
family_name => "extract_sn",
|
|
|
|
name => "cn"
|
|
|
|
}
|
|
|
|
},
|
2019-12-21 12:08:48 +01:00
|
|
|
oidcServiceDynamicRegistrationExportedVars =>
|
|
|
|
{ "extra_var" => "mail" },
|
|
|
|
oidcServiceDynamicRegistrationExtraClaims =>
|
|
|
|
{ "extra_claim" => "extra_var" },
|
2019-12-21 11:40:47 +01:00
|
|
|
oidcServiceMetaDataAuthorizeURI => "authorize",
|
|
|
|
oidcServiceMetaDataCheckSessionURI => "checksession.html",
|
|
|
|
oidcServiceMetaDataJWKSURI => "jwks",
|
|
|
|
oidcServiceMetaDataEndSessionURI => "logout",
|
|
|
|
oidcServiceMetaDataRegistrationURI => "register",
|
|
|
|
oidcServiceMetaDataTokenURI => "token",
|
|
|
|
oidcServiceMetaDataUserInfoURI => "userinfo",
|
|
|
|
oidcServiceAllowHybridFlow => 1,
|
|
|
|
oidcServiceAllowImplicitFlow => 1,
|
|
|
|
oidcServiceAllowDynamicRegistration => 1,
|
|
|
|
oidcServiceAllowAuthorizationCodeFlow => 1,
|
|
|
|
oidcRPMetaDataMacros => {
|
|
|
|
rp => {
|
|
|
|
extract_sn => '(split(/\s/, $cn))[1]',
|
|
|
|
}
|
|
|
|
},
|
|
|
|
oidcRPMetaDataOptions => {
|
|
|
|
rp => {
|
|
|
|
oidcRPMetaDataOptionsDisplayName => "RP",
|
|
|
|
oidcRPMetaDataOptionsIDTokenExpiration => 3600,
|
|
|
|
oidcRPMetaDataOptionsClientID => "rpid",
|
|
|
|
oidcRPMetaDataOptionsIDTokenSignAlg => "HS512",
|
|
|
|
oidcRPMetaDataOptionsBypassConsent => 1,
|
|
|
|
oidcRPMetaDataOptionsClientSecret => "rpsecret",
|
|
|
|
oidcRPMetaDataOptionsUserIDAttr => "",
|
|
|
|
oidcRPMetaDataOptionsAccessTokenExpiration => 3600,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
oidcOPMetaDataOptions => {},
|
|
|
|
oidcOPMetaDataJSON => {},
|
|
|
|
oidcOPMetaDataJWKS => {},
|
|
|
|
oidcServiceMetaDataAuthnContext => {
|
|
|
|
'loa-4' => 4,
|
|
|
|
'loa-1' => 1,
|
|
|
|
'loa-5' => 5,
|
|
|
|
'loa-2' => 2,
|
|
|
|
'loa-3' => 3
|
|
|
|
},
|
2020-02-05 22:44:14 +01:00
|
|
|
oidcServicePrivateKeySig => oidc_key_op_private_sig,
|
|
|
|
oidcServicePublicKeySig => oidc_key_op_public_sig,
|
2019-12-21 11:40:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|