Skip to content

Commit 1fbe8fe

Browse files
authored
[7.17] Update OIDC test fixture (#89526) (#89556)
This commit updates the OIDC test fixture to use the latest demo docker image from https://connect2id.com. As part of this change some of the docker image demo login has changed from prior versions and the test code is updated accordingly. fixes #89477 reverts #89478 / e949dff.
1 parent 31fe12a commit 1fbe8fe

File tree

4 files changed

+25
-58
lines changed

4 files changed

+25
-58
lines changed

x-pack/qa/oidc-op-tests/build.gradle

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,4 @@ tasks.named("processJavaRestTestResources").configure {
2121
tasks.named("javaRestTest").configure {
2222
// OpenID Connect fixture does not support aarm64
2323
onlyIf { Architecture.current() == Architecture.X64 }
24-
25-
// AwaitsFix: https://github.com/elastic/elasticsearch/issues/89477
26-
enabled = false
2724
}

x-pack/qa/oidc-op-tests/src/javaRestTest/java/org/elasticsearch/xpack/security/authc/oidc/OpenIdConnectAuthIT.java

Lines changed: 13 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -214,58 +214,27 @@ private String authenticateAtOP(URI opAuthUri) throws Exception {
214214
assertThat(initResponse.getAsString("type"), equalTo("auth"));
215215
final String sid = initResponse.getAsString("sid");
216216
// Actually authenticate the user with ldapAuth
217-
HttpPost loginHttpPost = new HttpPost(LOGIN_API + "authenticateSubject?cacheBuster=" + randomAlphaOfLength(8));
217+
HttpPost loginHttpPost = new HttpPost(
218+
LOGIN_API + "authenticateSubject?cacheBuster=" + randomAlphaOfLength(8) + "&authSessionId=" + sid
219+
);
218220
String loginJson = "{" + "\"username\":\"alice\"," + "\"password\":\"secret\"" + "}";
219221
configureJsonRequest(loginHttpPost, loginJson);
220-
JSONObject loginJsonResponse = execute(httpClient, loginHttpPost, context, response -> {
222+
execute(httpClient, loginHttpPost, context, response -> {
221223
assertHttpOk(response.getStatusLine());
222224
return parseJsonResponse(response);
223225
});
224-
// Get the consent screen
225-
HttpPut consentFetchHttpPut = new HttpPut(
226-
LOGIN_API + "updateAuthRequest" + "/" + sid + "?cacheBuster=" + randomAlphaOfLength(8)
227-
);
228-
String consentFetchJson = "{"
229-
+ "\"sub\": \""
230-
+ loginJsonResponse.getAsString("id")
231-
+ "\","
232-
+ "\"acr\": \"http://loa.c2id.com/basic\","
233-
+ "\"amr\": [\"pwd\"],"
234-
+ "\"data\": {"
235-
+ "\"email\": \""
236-
+ loginJsonResponse.getAsString("email")
237-
+ "\","
238-
+ "\"name\": \""
239-
+ loginJsonResponse.getAsString("name")
240-
+ "\""
241-
+ "}"
242-
+ "}";
243-
configureJsonRequest(consentFetchHttpPut, consentFetchJson);
244-
JSONObject consentFetchResponse = execute(httpClient, consentFetchHttpPut, context, response -> {
226+
227+
HttpPut consentHttpPut = new HttpPut(LOGIN_API + "updateAuthRequest" + "/" + sid + "?cacheBuster=" + randomAlphaOfLength(8));
228+
String consentJson = "{" + "\"claims\":[\"name\", \"email\"]," + "\"scope\":[\"openid\"]" + "}";
229+
configureJsonRequest(consentHttpPut, consentJson);
230+
JSONObject jsonConsentResponse = execute(httpClient, consentHttpPut, context, response -> {
245231
assertHttpOk(response.getStatusLine());
246232
return parseJsonResponse(response);
247233
});
248-
if (consentFetchResponse.getAsString("type").equals("consent")) {
249-
// If needed, submit the consent
250-
HttpPut consentHttpPut = new HttpPut(
251-
LOGIN_API + "updateAuthRequest" + "/" + sid + "?cacheBuster=" + randomAlphaOfLength(8)
252-
);
253-
String consentJson = "{" + "\"claims\":[\"name\", \"email\"]," + "\"scope\":[\"openid\"]" + "}";
254-
configureJsonRequest(consentHttpPut, consentJson);
255-
JSONObject jsonConsentResponse = execute(httpClient, consentHttpPut, context, response -> {
256-
assertHttpOk(response.getStatusLine());
257-
return parseJsonResponse(response);
258-
});
259-
assertThat(jsonConsentResponse.getAsString("type"), equalTo("response"));
260-
JSONObject parameters = (JSONObject) jsonConsentResponse.get("parameters");
261-
return parameters.getAsString("uri");
262-
} else if (consentFetchResponse.getAsString("type").equals("response")) {
263-
JSONObject parameters = (JSONObject) consentFetchResponse.get("parameters");
264-
return parameters.getAsString("uri");
265-
} else {
266-
fail("Received an invalid response from the OP");
267-
return null;
268-
}
234+
assertThat(jsonConsentResponse.getAsString("type"), equalTo("response"));
235+
JSONObject parameters = (JSONObject) jsonConsentResponse.get("parameters");
236+
return parameters.getAsString("uri");
237+
269238
}
270239
}
271240

x-pack/test/idp-fixture/docker-compose.yml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -154,17 +154,16 @@ services:
154154
- ./idp/shibboleth-idp/metadata:/opt/shibboleth-idp/metadata
155155
- ./idp/shib-jetty-base/start.d/ssl.ini:/opt/shib-jetty-base/start.d/ssl.ini
156156

157-
# c2id/c2id-server image is no longer available
158-
# oidc-provider:
159-
# image: "c2id/c2id-server:9.5"
160-
# depends_on:
161-
# - http-proxy
162-
# ports:
163-
# - "8080"
164-
# expose:
165-
# - "8080"
166-
# volumes:
167-
# - ./oidc/override.properties:/etc/c2id/override.properties
157+
oidc-provider:
158+
image: "c2id/c2id-server-demo:12.16.1"
159+
depends_on:
160+
- http-proxy
161+
ports:
162+
- "8080"
163+
expose:
164+
- "8080"
165+
volumes:
166+
- ./oidc/override.properties:/etc/c2id/override.properties
168167

169168
http-proxy:
170169
image: "nginx:latest"

x-pack/test/idp-fixture/oidc/override.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ op.issuer=http://oidc-provider:8080/c2id
22
op.authz.endpoint=http://oidc-provider:8080/c2id-login/
33
op.reg.apiAccessTokenSHA256=d1c4fa70d9ee708d13cfa01daa0e060a05a2075a53c5cc1ad79e460e96ab5363
44
jose.jwkSer=RnVsbCBrZXk6CnsKICAia2V5cyI6IFsKICAgIHsKICAgICAgInAiOiAiLXhhN2d2aW5tY3N3QXU3Vm1mV2loZ2o3U3gzUzhmd2dFSTdMZEVveW5FU1RzcElaeUY5aHc0NVhQZmI5VHlpbzZsOHZTS0F5RmU4T2lOalpkNE1Ra0ttY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