10
10
11
11
namespace IntegrationTests . Endpoints . Discovery ;
12
12
13
- public class DiscoveryEndpointTests_token_endpoint_auth_signing_alg_values_supported
13
+ public class DiscoveryEndpointTests_token_endpoint_auth
14
14
{
15
- private const string Category = "Discovery endpoint - token_endpoint_auth_signing_alg_values_supported " ;
15
+ private const string Category = "Discovery endpoint - token_endpoint_auth " ;
16
16
17
- [ Fact ]
17
+ [ Theory ]
18
18
[ Trait ( "Category" , Category ) ]
19
- public async Task token_endpoint_auth_signing_alg_values_supported_should_match_configuration ( )
19
+ [ InlineData ( true , true , SecurityAlgorithms . RsaSha256 , SecurityAlgorithms . HmacSha256 ) ]
20
+ [ InlineData ( true , true , SecurityAlgorithms . RsaSsaPssSha384 , SecurityAlgorithms . HmacSha384 ) ]
21
+ [ InlineData ( true , true , SecurityAlgorithms . EcdsaSha512 , SecurityAlgorithms . HmacSha512 ) ]
22
+ [ InlineData ( false , true , SecurityAlgorithms . HmacSha256 ) ]
23
+ [ InlineData ( false , true , SecurityAlgorithms . HmacSha384 ) ]
24
+ [ InlineData ( false , true , SecurityAlgorithms . HmacSha512 ) ]
25
+ [ InlineData ( true , false , SecurityAlgorithms . RsaSha256 ) ]
26
+ [ InlineData ( true , false , SecurityAlgorithms . RsaSha384 ) ]
27
+ [ InlineData ( true , false , SecurityAlgorithms . RsaSha512 ) ]
28
+ [ InlineData ( true , false , SecurityAlgorithms . RsaSsaPssSha256 ) ]
29
+ [ InlineData ( true , false , SecurityAlgorithms . RsaSsaPssSha384 ) ]
30
+ [ InlineData ( true , false , SecurityAlgorithms . RsaSsaPssSha512 ) ]
31
+ [ InlineData ( true , false , SecurityAlgorithms . EcdsaSha256 ) ]
32
+ [ InlineData ( true , false , SecurityAlgorithms . EcdsaSha384 ) ]
33
+ [ InlineData ( true , false , SecurityAlgorithms . EcdsaSha512 ) ]
34
+
35
+ public async Task token_endpoint_auth_should_match_configuration ( bool privateKeyJwtExpected , bool clientSecretJwtExpected , params string [ ] algorithms )
20
36
{
37
+ // This test verifies that the algorithms supported match the configured algorithms, and that
38
+ // the supported auth methods are appropriate for the algorithms
21
39
var pipeline = new IdentityServerPipeline ( ) ;
22
40
pipeline . OnPostConfigureServices += svcs =>
23
41
svcs . AddIdentityServerBuilder ( ) . AddJwtBearerClientAuthentication ( ) ;
24
42
pipeline . Initialize ( ) ;
25
- pipeline . Options . SupportedClientAssertionSigningAlgorithms =
26
- [
27
- SecurityAlgorithms . RsaSsaPssSha256 ,
28
- SecurityAlgorithms . EcdsaSha256
29
- ] ;
43
+ pipeline . Options . SupportedClientAssertionSigningAlgorithms = algorithms ;
30
44
31
45
var disco = await pipeline . BackChannelClient
32
46
. GetDiscoveryDocumentAsync ( "https://server/.well-known/openid-configuration" ) ;
33
47
disco . IsError . ShouldBeFalse ( ) ;
34
48
35
49
var algorithmsSupported = disco . TokenEndpointAuthenticationSigningAlgorithmsSupported ;
36
50
37
- algorithmsSupported . Count ( ) . ShouldBe ( 2 ) ;
38
- algorithmsSupported . ShouldContain ( SecurityAlgorithms . RsaSsaPssSha256 ) ;
39
- algorithmsSupported . ShouldContain ( SecurityAlgorithms . EcdsaSha256 ) ;
51
+ algorithmsSupported . Count ( ) . ShouldBe ( algorithms . Length ) ;
52
+ foreach ( var algorithm in algorithms )
53
+ {
54
+ algorithmsSupported . ShouldContain ( algorithm ) ;
55
+ }
56
+
57
+ var authMethods = disco . TokenEndpointAuthenticationMethodsSupported ;
58
+ authMethods . Contains ( "private_key_jwt" ) . ShouldBe ( privateKeyJwtExpected ) ;
59
+ authMethods . Contains ( "client_secret_jwt" ) . ShouldBe ( clientSecretJwtExpected ) ;
40
60
}
41
61
42
62
[ Fact ]
@@ -68,6 +88,10 @@ await pipeline.BackChannelClient.GetDiscoveryDocumentAsync(
68
88
algorithmsSupported . ShouldContain ( SecurityAlgorithms . HmacSha256 ) ;
69
89
algorithmsSupported . ShouldContain ( SecurityAlgorithms . HmacSha384 ) ;
70
90
algorithmsSupported . ShouldContain ( SecurityAlgorithms . HmacSha512 ) ;
91
+
92
+ var authMethods = result . TokenEndpointAuthenticationMethodsSupported ;
93
+ authMethods . ShouldContain ( "private_key_jwt" ) ;
94
+ authMethods . ShouldContain ( "client_secret_jwt" ) ;
71
95
}
72
96
73
97
[ Fact ]
@@ -84,7 +108,6 @@ public async Task token_endpoint_auth_signing_alg_values_supported_should_not_be
84
108
// Verify assumptions
85
109
disco . IsError . ShouldBeFalse ( ) ;
86
110
disco . TokenEndpointAuthenticationMethodsSupported . ShouldNotContain ( "private_key_jwt" ) ;
87
- // we don't even support client_secret_jwt, but per spec, if you DO, you must include the algs supported
88
111
disco . TokenEndpointAuthenticationMethodsSupported . ShouldNotContain ( "client_secret_jwt" ) ;
89
112
90
113
// Assert that we got no signing algs.
0 commit comments