Skip to content

Commit 54f1f21

Browse files
committed
WIP sig algs
1 parent ba84375 commit 54f1f21

File tree

4 files changed

+212
-68
lines changed

4 files changed

+212
-68
lines changed

config/module_oidc.php.dist

Lines changed: 50 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ declare(strict_types=1);
2222
*/
2323

2424
use SimpleSAML\Module\oidc\ModuleConfig;
25-
use SimpleSAML\Module\oidc\ValueAbstracts\SignatureKeyPairConfig;
2625
use SimpleSAML\OpenID\Codebooks\ClaimsEnum;
2726
use SimpleSAML\OpenID\Codebooks\CredentialFormatIdentifiersEnum;
2827
use SimpleSAML\OpenID\Codebooks\CredentialTypesEnum;
@@ -71,35 +70,59 @@ $config = [
7170
// ModuleConfig::OPTION_PKI_NEW_CERTIFICATE_FILENAME => 'new_oidc_module.crt',
7271

7372
/**
74-
* Default protocol (Connect) signature algorithm and key-pair definition.
75-
* This algorithm and key will be used, for example, to sign ID Token JWS,
76-
* if no other algorithm is negotiated with the client.
77-
*/
78-
ModuleConfig::DEFAULT_PROTOCOL_SIGNATURE_KEY_PAIR => [
79-
'algorithm' => \SimpleSAML\OpenID\Algorithms\SignatureAlgorithmEnum::RS256,
80-
'privateKeyFilename' => ModuleConfig::DEFAULT_PKI_PRIVATE_KEY_FILENAME,
81-
'publicKeyFilename' => ModuleConfig::DEFAULT_PKI_CERTIFICATE_FILENAME,
82-
// 'privateKeyPassword' => 'private-key-password', // Optional
83-
// 'keyId' => 'rsa-connect-signing-key-2026', // Optional
84-
],
85-
86-
/**
87-
* Additionally supported protocol (Connect) signing algorithms and
88-
* key-pairs. These entries will be used in signing algorithm negotiation
89-
* with the client. The order in which the entries are set is important,
90-
* as the entries set first will have higher priority during negotiation.
73+
* Protocol (Connect) signature algorithm and key-pair definitions,
74+
* representing supported algorithms for signing, for example, ID Token JWS.
75+
* The order in which the entries are set is important. The entry set
76+
* first will have higher priority during signing algorithm negotiation
77+
* with the client. If the client doesn't designate desired signing
78+
* algorithm, the first algorithm in the list will be used for signing (the
79+
* first entry represents default algorithm and signing key). Note that
80+
* the OpenID Connect specification designates `RS256` as the signing
81+
* algorithm that should be used by default, so you would probably want
82+
* to use that algorithm as the default (first) one. However, you are free
83+
* to set other default (first) algorithm as needed.
84+
* You can also use this config option to advertise any (new) keys, for
85+
* example, for key-rollover scenarios. Just add those entries later in
86+
* the list, so they can be published on the OP discovery endpoint.
9187
*
92-
* You can also use this config option to advertise any
93-
* (new) keys, for example, for key-rollover scenarios. Just add those
94-
* entries last.
88+
* The format is array of associative arrays, where each array value
89+
* consists of the following properties (keys):
90+
* - ModuleConfig::KEY_ALGORITHM - \SimpleSAML\OpenID\Algorithms\SignatureAlgorithmEnum case
91+
* representing the algorithm.
92+
* - ModuleConfig::KEY_PRIVATE_KEY_FILENAME - the name of the file
93+
* containing private key inPEM format, which is available in SSP `cert`
94+
* folder.
95+
* - ModuleConfig::KEY_PUBLIC_KEY_FILENAME - the name of the file containing
96+
* corresponding public key in PEM format, which is available in SSP `cert`
97+
* folder.
98+
* - ModuleConfig::KEY_PRIVATE_KEY_PASSWORD - private key password, if
99+
* needed.
100+
* - ModuleConfig::KEY_KEY_ID - Optional string representing key identifier.
101+
* Use if you need to manually set key identifiers to be published. If not
102+
* set, a public key thumbprint will be generated on the fly and used as a
103+
* key ID.
104+
*
105+
* Note: in v7 of the module, a new way of automatic key ID generation is
106+
* used. In previous versions, a hash of a public key file was used as a
107+
* key ID. In v7, a public key thumbprint is used. If you are migrating from
108+
* previous version of the module, and you want to keep the old signing key,
109+
* you should manually set the key ID to the previous value, so that clients
110+
* know that the key did not change.
95111
*/
96-
ModuleConfig::ADDITIONAL_PROTOCOL_SIGNATURE_KEY_PAIRS => [
112+
ModuleConfig::OPTION_PROTOCOL_SIGNATURE_KEY_PAIRS => [
113+
[
114+
ModuleConfig::KEY_ALGORITHM => \SimpleSAML\OpenID\Algorithms\SignatureAlgorithmEnum::RS256,
115+
ModuleConfig::KEY_PRIVATE_KEY_FILENAME => ModuleConfig::DEFAULT_PKI_PRIVATE_KEY_FILENAME,
116+
ModuleConfig::KEY_PUBLIC_KEY_FILENAME => ModuleConfig::DEFAULT_PKI_CERTIFICATE_FILENAME,
117+
// ModuleConfig::KEY_PRIVATE_KEY_PASSWORD => 'private-key-password', // Optional
118+
// ModuleConfig::KEY_KEY_ID => 'rsa-connect-signing-key-2026', // Optional
119+
],
97120
[
98-
'algorithm' => \SimpleSAML\OpenID\Algorithms\SignatureAlgorithmEnum::ES256,
99-
'privateKeyFilename' => 'oidc_module_ec256.key',
100-
'publicKeyFilename' => 'oidc_module_ec256.pub',
101-
// 'privateKeyPassword' => 'private-key-password', // Optional
102-
// 'keyId' => 'ec-connect-signing-key-01', // Optional
121+
ModuleConfig::KEY_ALGORITHM => \SimpleSAML\OpenID\Algorithms\SignatureAlgorithmEnum::ES256,
122+
ModuleConfig::KEY_PRIVATE_KEY_FILENAME => 'oidc_module_ec256.key',
123+
ModuleConfig::KEY_PUBLIC_KEY_FILENAME => 'oidc_module_ec256.pub',
124+
// ModuleConfig::KEY_PRIVATE_KEY_PASSWORD => 'private-key-password', // Optional
125+
// ModuleConfig::KEY_KEY_ID => 'ec-connect-signing-key-01', // Optional
103126
],
104127
],
105128

src/Factories/FederationFactory.php

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77
use SimpleSAML\Module\oidc\ModuleConfig;
88
use SimpleSAML\Module\oidc\Services\LoggerService;
99
use SimpleSAML\Module\oidc\Utils\FederationCache;
10-
use SimpleSAML\OpenID\Algorithms\SignatureAlgorithmBag;
11-
use SimpleSAML\OpenID\Algorithms\SignatureAlgorithmEnum;
1210
use SimpleSAML\OpenID\Federation;
13-
use SimpleSAML\OpenID\SupportedAlgorithms;
1411

1512
class FederationFactory
1613
{
@@ -27,22 +24,8 @@ public function __construct(
2724
*/
2825
public function build(): Federation
2926
{
30-
$supportedAlgorithms = new SupportedAlgorithms(
31-
new SignatureAlgorithmBag(
32-
SignatureAlgorithmEnum::from($this->moduleConfig->getFederationSigner()->algorithmId()),
33-
SignatureAlgorithmEnum::RS384,
34-
SignatureAlgorithmEnum::RS512,
35-
SignatureAlgorithmEnum::ES256,
36-
SignatureAlgorithmEnum::ES384,
37-
SignatureAlgorithmEnum::ES512,
38-
SignatureAlgorithmEnum::PS256,
39-
SignatureAlgorithmEnum::PS384,
40-
SignatureAlgorithmEnum::PS512,
41-
),
42-
);
43-
4427
return new Federation(
45-
supportedAlgorithms: $supportedAlgorithms,
28+
supportedAlgorithms: $this->moduleConfig->getSupportedAlgorithms(),
4629
maxCacheDuration: $this->moduleConfig->getFederationCacheMaxDurationForFetched(),
4730
cache: $this->federationCache?->cache,
4831
logger: $this->loggerService,

0 commit comments

Comments
 (0)