Skip to content

Commit c581be8

Browse files
authored
Merge pull request #49907 from sberyozkin/enhance_oidc_metadata
Update OidcConfigMetadata to return supported properties such as subject and response types
2 parents 87b6487 + d3e98c2 commit c581be8

File tree

3 files changed

+88
-12
lines changed

3 files changed

+88
-12
lines changed

extensions/oidc/runtime/src/main/java/io/quarkus/oidc/OidcConfigurationMetadata.java

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@ public class OidcConfigurationMetadata {
1515
public static final String JWKS_ENDPOINT = "jwks_uri";
1616
public static final String USERINFO_ENDPOINT = "userinfo_endpoint";
1717
public static final String END_SESSION_ENDPOINT = "end_session_endpoint";
18-
private static final String REGISTRATION_ENDPOINT = "registration_endpoint";
19-
private static final String REVOCATION_ENDPOINT = "revocation_endpoint";
18+
public static final String REGISTRATION_ENDPOINT = "registration_endpoint";
19+
public static final String REVOCATION_ENDPOINT = "revocation_endpoint";
2020
public static final String SCOPES_SUPPORTED = "scopes_supported";
21+
public static final String RESPONSE_TYPES_SUPPORTED = "response_types_supported";
22+
public static final String SUBJECT_TYPES_SUPPORTED = "subject_types_supported";
23+
public static final String ID_TOKEN_SIGNING_ALGORITHMS_SUPPORTED = "id_token_signing_alg_values_supported";
24+
public static final String CODE_CHALLENGE_METHODS_SUPPORTED = "code_challenge_methods_supported";
2125

2226
private final String discoveryUri;
2327
private final String tokenUri;
@@ -125,6 +129,22 @@ public List<String> getSupportedScopes() {
125129
return getStringList(SCOPES_SUPPORTED);
126130
}
127131

132+
public List<String> getSupportedResponseTypes() {
133+
return getStringList(RESPONSE_TYPES_SUPPORTED);
134+
}
135+
136+
public List<String> getSupportedSubjectTypes() {
137+
return getStringList(SUBJECT_TYPES_SUPPORTED);
138+
}
139+
140+
public List<String> getSupportedIdTokenSigningAlgorithms() {
141+
return getStringList(ID_TOKEN_SIGNING_ALGORITHMS_SUPPORTED);
142+
}
143+
144+
public List<String> getSupportedCodeChallengeMethods() {
145+
return getStringList(CODE_CHALLENGE_METHODS_SUPPORTED);
146+
}
147+
128148
public String getIssuer() {
129149
return issuer;
130150
}

integration-tests/oidc-code-flow/src/main/java/io/quarkus/it/keycloak/ProtectedResource.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,30 @@ public String configMetadataScopes() {
103103
return configMetadata.getSupportedScopes().stream().collect(Collectors.joining(","));
104104
}
105105

106+
@GET
107+
@Path("configMetadataResponseTypes")
108+
public String configMetadataResponseTypes() {
109+
return configMetadata.getSupportedResponseTypes().stream().collect(Collectors.joining(","));
110+
}
111+
112+
@GET
113+
@Path("configMetadataSubjectTypes")
114+
public String configMetadataSubjectTypes() {
115+
return configMetadata.getSupportedSubjectTypes().stream().collect(Collectors.joining(","));
116+
}
117+
118+
@GET
119+
@Path("configMetadataIdTokenSigningAlgorithms")
120+
public String configMetadataIdTokenSigningAlgorithms() {
121+
return configMetadata.getSupportedIdTokenSigningAlgorithms().stream().collect(Collectors.joining(","));
122+
}
123+
124+
@GET
125+
@Path("configMetadataCodeChallengeMethods")
126+
public String configMetadataCodeChallengeMethods() {
127+
return configMetadata.getSupportedCodeChallengeMethods().stream().collect(Collectors.joining(","));
128+
}
129+
106130
@GET
107131
public String getName() {
108132
if (!idTokenCredential.getToken().equals(idToken.getRawToken())) {

integration-tests/oidc-code-flow/src/test/java/io/quarkus/it/keycloak/CodeFlowTest.java

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,7 @@ public void testCodeFlowNoConsent() throws IOException {
9797
assertEquals("Welcome to Test App", page.getTitleText(),
9898
"A second request should not redirect and just re-authenticate the user");
9999

100-
page = webClient.getPage("http://localhost:8081/web-app/configMetadataIssuer");
101-
102-
assertEquals(
103-
client.getAuthServerUrl(),
104-
page.asNormalizedText());
105-
106-
page = webClient.getPage("http://localhost:8081/web-app/configMetadataScopes");
107-
108-
assertTrue(page.asNormalizedText().contains("openid"));
109-
assertTrue(page.asNormalizedText().contains("profile"));
100+
verifyConfigurationMetadata(webClient);
110101

111102
Cookie sessionCookie = getSessionCookie(webClient, null);
112103
assertNotNull(sessionCookie);
@@ -154,6 +145,47 @@ public void testCodeFlowNoConsent() throws IOException {
154145
}
155146
}
156147

148+
private void verifyConfigurationMetadata(WebClient webClient) throws IOException {
149+
// Issuer
150+
HtmlPage page = webClient.getPage("http://localhost:8081/web-app/configMetadataIssuer");
151+
152+
assertEquals(
153+
client.getAuthServerUrl(),
154+
page.asNormalizedText());
155+
156+
// Scopes
157+
page = webClient.getPage("http://localhost:8081/web-app/configMetadataScopes");
158+
159+
assertTrue(page.asNormalizedText().contains("openid"));
160+
assertTrue(page.asNormalizedText().contains("profile"));
161+
162+
// Response types
163+
page = webClient.getPage("http://localhost:8081/web-app/configMetadataResponseTypes");
164+
165+
assertTrue(page.asNormalizedText().contains("code"));
166+
assertTrue(page.asNormalizedText().contains("token"));
167+
168+
// Subject types
169+
page = webClient.getPage("http://localhost:8081/web-app/configMetadataSubjectTypes");
170+
171+
assertTrue(page.asNormalizedText().contains("public"));
172+
assertTrue(page.asNormalizedText().contains("pairwise"));
173+
174+
// ID token signing algorithms
175+
page = webClient.getPage("http://localhost:8081/web-app/configMetadataIdTokenSigningAlgorithms");
176+
177+
assertTrue(page.asNormalizedText().contains("RS256"));
178+
assertTrue(page.asNormalizedText().contains("ES256"));
179+
assertTrue(page.asNormalizedText().contains("PS256"));
180+
181+
// PKCE code challenge methods
182+
page = webClient.getPage("http://localhost:8081/web-app/configMetadataCodeChallengeMethods");
183+
184+
assertTrue(page.asNormalizedText().contains("S256"));
185+
assertTrue(page.asNormalizedText().contains("plain"));
186+
187+
}
188+
157189
private static void checkHealth() {
158190
Response healthReadyResponse = RestAssured.when().get("http://localhost:8081/q/health/ready");
159191
JsonObject jsonHealth = new JsonObject(healthReadyResponse.asString());

0 commit comments

Comments
 (0)