From 5557e1cb52e7b9d319eb716dc8ee3a5e7084eea6 Mon Sep 17 00:00:00 2001 From: Jim Anderson Date: Wed, 6 Dec 2023 12:27:06 -0600 Subject: [PATCH] [SDK-4736] support backchannel logout property on Client (#587) --- .../com/auth0/json/mgmt/client/Client.java | 17 +++++++++ .../mgmt/client/OIDCBackchannelLogout.java | 36 +++++++++++++++++++ .../auth0/json/mgmt/client/ClientTest.java | 8 ++++- 3 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/auth0/json/mgmt/client/OIDCBackchannelLogout.java diff --git a/src/main/java/com/auth0/json/mgmt/client/Client.java b/src/main/java/com/auth0/json/mgmt/client/Client.java index f55c0e62..de2d2fcd 100644 --- a/src/main/java/com/auth0/json/mgmt/client/Client.java +++ b/src/main/java/com/auth0/json/mgmt/client/Client.java @@ -94,6 +94,8 @@ public class Client { private ClientAuthenticationMethods clientAuthenticationMethods; @JsonProperty("require_pushed_authorization_requests") private Boolean requiresPushedAuthorizationRequests; + @JsonProperty("oidc_backchannel_logout") + private OIDCBackchannelLogout oidcBackchannelLogout; /** * Getter for the name of the tenant this client belongs to. @@ -820,5 +822,20 @@ public Boolean getRequiresPushedAuthorizationRequests() { public void setRequiresPushedAuthorizationRequests(Boolean requiresPushedAuthorizationRequests) { this.requiresPushedAuthorizationRequests = requiresPushedAuthorizationRequests; } + + /** + * @return the value of the {@code oidc_backchannel_logout} property. + */ + public OIDCBackchannelLogout getOidcBackchannelLogout() { + return oidcBackchannelLogout; + } + + /** + * Sets the {@code oidc_backchannel_logout} property. + * @param oidcBackchannelLogout the value to set the {@code oidc_backchannel_logout} property to. + */ + public void setOidcBackchannelLogout(OIDCBackchannelLogout oidcBackchannelLogout) { + this.oidcBackchannelLogout = oidcBackchannelLogout; + } } diff --git a/src/main/java/com/auth0/json/mgmt/client/OIDCBackchannelLogout.java b/src/main/java/com/auth0/json/mgmt/client/OIDCBackchannelLogout.java new file mode 100644 index 00000000..4f95b70c --- /dev/null +++ b/src/main/java/com/auth0/json/mgmt/client/OIDCBackchannelLogout.java @@ -0,0 +1,36 @@ +package com.auth0.json.mgmt.client; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.List; + +/** + * Represents the value of the {@code oidc_backchannel_logout} property on an Auth0 application.\ + * @see Client + * @see com.auth0.client.mgmt.ClientsEntity + */ +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class OIDCBackchannelLogout { + + @JsonProperty("backchannel_logout_urls") + private List backchannelLogoutUrls; + + /** + * Create a new instance with the given list of Logout URIs that will receive a {@code logout_token} when selected Back-Channel Logout Initiators occur. + * @param backchannelLogoutUrls the list of allowed backchannel logout URLs. + */ + public OIDCBackchannelLogout(@JsonProperty("backchannel_logout_urls") List backchannelLogoutUrls) { + this.backchannelLogoutUrls = backchannelLogoutUrls; + } + + /** + * @return the list of Logout URIs that will receive a {@code logout_token} when selected Back-Channel Logout Initiators occur. + */ + public List getBackchannelLogoutUrls() { + return this.backchannelLogoutUrls; + } +} diff --git a/src/test/java/com/auth0/json/mgmt/client/ClientTest.java b/src/test/java/com/auth0/json/mgmt/client/ClientTest.java index a3d59d67..ca2832e9 100644 --- a/src/test/java/com/auth0/json/mgmt/client/ClientTest.java +++ b/src/test/java/com/auth0/json/mgmt/client/ClientTest.java @@ -99,7 +99,10 @@ public class ClientTest extends JsonTest { " ]\n" + " }\n" + " },\n" + - " \"require_pushed_authorization_requests\": true\n" + + " \"require_pushed_authorization_requests\": true,\n" + + " \"oidc_backchannel_logout\": {\n" + + " \"backchannel_logout_urls\": [\"http://acme.eu.auth0.com/events\"]\n" + + " }\n" + "}"; @Test @@ -148,6 +151,7 @@ public void shouldSerialize() throws Exception { ClientAuthenticationMethods cam = new ClientAuthenticationMethods(privateKeyJwt); client.setClientAuthenticationMethods(cam); client.setRequiresPushedAuthorizationRequests(true); + client.setOidcBackchannelLogout(new OIDCBackchannelLogout(Collections.singletonList("http://acme.eu.auth0.com/events"))); String serialized = toJSON(client); assertThat(serialized, is(notNullValue())); @@ -184,6 +188,7 @@ public void shouldSerialize() throws Exception { assertThat(serialized, JsonMatcher.hasEntry("client_authentication_methods", notNullValue())); assertThat(serialized, JsonMatcher.hasEntry("client_authentication_methods", containsString("{\"private_key_jwt\":{\"credentials\":[{\"credential_type\":\"public_key\",\"pem\":\"PEM\"}]}}"))); assertThat(serialized, JsonMatcher.hasEntry("require_pushed_authorization_requests", true)); + assertThat(serialized, JsonMatcher.hasEntry("oidc_backchannel_logout", containsString("{\"backchannel_logout_urls\":[\"http://acme.eu.auth0.com/events\"]}"))); } @Test @@ -235,6 +240,7 @@ public void shouldDeserialize() throws Exception { assertThat(client.getClientAuthenticationMethods().getPrivateKeyJwt().getCredentials().get(0).getId(), is("cred_abc")); assertThat(client.getClientAuthenticationMethods().getPrivateKeyJwt().getCredentials().get(1).getId(), is("cred_123")); assertThat(client.getRequiresPushedAuthorizationRequests(), is(true)); + assertThat(client.getOidcBackchannelLogout().getBackchannelLogoutUrls().size(), is(1)); } @Test