From 202c8da9037925c1bc834a75411be45d89c697ba Mon Sep 17 00:00:00 2001 From: Glauco <37829079+rglauco@users.noreply.github.com> Date: Mon, 18 Mar 2024 16:21:09 +0100 Subject: [PATCH] fix: claim sub instead of email, fix wellknown tests --- .../spring/boot/relying/party/RelyingPartyWrapper.java | 4 ++-- .../oidc/handler/TestRelyingPartyHandlerWellKnown.java | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/relying-party-spring-boot/src/main/java/it/spid/cie/oidc/spring/boot/relying/party/RelyingPartyWrapper.java b/examples/relying-party-spring-boot/src/main/java/it/spid/cie/oidc/spring/boot/relying/party/RelyingPartyWrapper.java index 01013db..0f51b16 100644 --- a/examples/relying-party-spring-boot/src/main/java/it/spid/cie/oidc/spring/boot/relying/party/RelyingPartyWrapper.java +++ b/examples/relying-party-spring-boot/src/main/java/it/spid/cie/oidc/spring/boot/relying/party/RelyingPartyWrapper.java @@ -48,10 +48,10 @@ public JSONObject getUserInfo(String state, String code) } public String getUserKey(JSONObject userInfo) { - String userKey = userInfo.optString("email"); + String userKey = userInfo.optString("sub"); if (Validator.isNullOrEmpty(userKey)) { - userKey = userInfo.optString("email", ""); + userKey = userInfo.optString("sub ", ""); } return userKey; diff --git a/starter-kit/src/test/java/it/spid/cie/oidc/handler/TestRelyingPartyHandlerWellKnown.java b/starter-kit/src/test/java/it/spid/cie/oidc/handler/TestRelyingPartyHandlerWellKnown.java index b7e2e7e..034a931 100644 --- a/starter-kit/src/test/java/it/spid/cie/oidc/handler/TestRelyingPartyHandlerWellKnown.java +++ b/starter-kit/src/test/java/it/spid/cie/oidc/handler/TestRelyingPartyHandlerWellKnown.java @@ -22,7 +22,7 @@ public class TestRelyingPartyHandlerWellKnown { private static String TRUST_ANCHOR = "http://127.0.0.1:18000/"; private static String SPID_PROVIDER = "http://127.0.0.1:18000/oidc/op/"; - private static String RELYING_PARTY = "http://127.0.0.1:18080/oidc/rp/"; + private static String RELYING_PARTY = "http://127.0.0.1:18080/oidc/rp"; @Test public void testClass1() { @@ -142,7 +142,7 @@ public void testWellKnown2d() { options, new MemoryStorage()); wellKnown = handler.getWellKnownData( - RELYING_PARTY + OIDCConstants.OIDC_FEDERATION_WELLKNOWN_URL, + RELYING_PARTY + "/" + OIDCConstants.OIDC_FEDERATION_WELLKNOWN_URL, true); } catch (Exception e) { @@ -196,10 +196,10 @@ public void testWellKnown2f() { options, new MemoryStorage()); handler.getWellKnownData( - RELYING_PARTY + OIDCConstants.OIDC_FEDERATION_WELLKNOWN_URL, true); + RELYING_PARTY + "/" + OIDCConstants.OIDC_FEDERATION_WELLKNOWN_URL, true); wellKnown = handler.getWellKnownData( - RELYING_PARTY + OIDCConstants.OIDC_FEDERATION_WELLKNOWN_URL, true); + RELYING_PARTY + "/" + OIDCConstants.OIDC_FEDERATION_WELLKNOWN_URL, true); } catch (Exception e) { catched = true;