Skip to content

Commit 3062e2a

Browse files
authored
Added support for SSO-FF (#702)
1 parent a7b0ff4 commit 3062e2a

File tree

9 files changed

+417
-17
lines changed

9 files changed

+417
-17
lines changed

src/main/java/com/auth0/client/mgmt/SelfServiceProfilesEntity.java

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
package com.auth0.client.mgmt;
22

3+
import com.auth0.client.auth.AuthAPI;
34
import com.auth0.client.mgmt.filter.PageBasedPaginationFilter;
4-
import com.auth0.json.mgmt.selfserviceprofiles.SelfServiceProfile;
5-
import com.auth0.json.mgmt.selfserviceprofiles.SelfServiceProfileResponse;
6-
import com.auth0.json.mgmt.selfserviceprofiles.SelfServiceProfileResponsePage;
7-
import com.auth0.json.mgmt.selfserviceprofiles.SsoAccessTicketResponse;
5+
import com.auth0.json.mgmt.selfserviceprofiles.*;
86
import com.auth0.net.*;
97
import com.auth0.net.client.Auth0HttpClient;
108
import com.auth0.net.client.HttpMethod;
@@ -187,14 +185,43 @@ public Request<Object> setCustomText(String id, String language, String page, Ob
187185
return request;
188186
}
189187

188+
/**
189+
* Create a new SSO access ticket.
190+
* A token with {@code create:sso_access_tickets} scope is needed
191+
* @see <a href="https://auth0.com/docs/api/management/v2#!/self-service-profiles/post-sso-ticket">https://auth0.com/docs/api/management/v2#!/self-service-profiles/post-sso-ticket</a>
192+
* @param id the self-service profile ID.
193+
* @param requestBody the payload.
194+
* @return a Request to execute.
195+
*/
196+
public Request<SsoAccessTicketResponse> createSsoAccessTicket(String id, SsoAccessTicketRequest requestBody) {
197+
Asserts.assertNotNull(id, "id");
198+
Asserts.assertNotNull(requestBody, "request body");
199+
200+
HttpUrl.Builder builder = baseUrl.newBuilder()
201+
.addPathSegments(ORGS_PATH)
202+
.addPathSegment(id)
203+
.addPathSegment("sso-ticket");
204+
205+
String url = builder.build().toString();
206+
207+
BaseRequest<SsoAccessTicketResponse> request = new BaseRequest<>(this.client, tokenProvider, url, HttpMethod.POST, new TypeReference<SsoAccessTicketResponse>() {
208+
});
209+
request.setBody(requestBody);
210+
return request;
211+
}
212+
213+
190214
/**
191215
* Create a new SSO access ticket.
192216
* A token with {@code create:sso_access_tickets} scope is needed
193217
* @see <a href="https://auth0.com/docs/api/management/v2#!/self-service-profiles/post-sso-ticket">https://auth0.com/docs/api/management/v2#!/self-service-profiles/post-sso-ticket</a>
194218
* @param id the self-service profile ID.
195219
* @param payload the payload.
196220
* @return a Request to execute.
221+
*
222+
* @deprecated Use {@link #createSsoAccessTicket(String, SsoAccessTicketRequest)} to create sso access ticket.
197223
*/
224+
@Deprecated
198225
public Request<SsoAccessTicketResponse> createSsoAccessTicket(String id, Object payload) {
199226
Asserts.assertNotNull(id, "id");
200227
Asserts.assertNotNull(payload, "payload");
@@ -203,7 +230,6 @@ public Request<SsoAccessTicketResponse> createSsoAccessTicket(String id, Object
203230
.addPathSegments(ORGS_PATH)
204231
.addPathSegment(id)
205232
.addPathSegment("sso-ticket");
206-
207233
String url = builder.build().toString();
208234

209235
BaseRequest<SsoAccessTicketResponse> request = new BaseRequest<>(this.client, tokenProvider, url, HttpMethod.POST, new TypeReference<SsoAccessTicketResponse>() {

src/main/java/com/auth0/json/mgmt/connections/Connection.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ public class Connection {
3434
private Map<String, String> metadata;
3535
@JsonProperty("realms")
3636
private List<String> realms;
37+
@JsonProperty("show_as_button")
38+
private boolean showAsButton;
39+
@JsonProperty("is_domain_connection")
40+
private boolean isDomainConnection;
3741

3842
public Connection() {
3943
}
@@ -183,4 +187,38 @@ public List<String> getRealms() {
183187
public void setRealms(List<String> realms) {
184188
this.realms = realms;
185189
}
190+
191+
/**
192+
* Getter for the show as button flag.
193+
*
194+
* @return the show as button flag.
195+
*/
196+
public boolean isShowAsButton() {
197+
return showAsButton;
198+
}
199+
200+
/**
201+
* Setter for the show as button flag.
202+
*
203+
* @param showAsButton the show as button flag to set.
204+
*/
205+
public void setShowAsButton(boolean showAsButton) {
206+
this.showAsButton = showAsButton;
207+
}
208+
209+
/**
210+
* Getter for the domain connection flag.
211+
* @return the domain connection flag.
212+
*/
213+
public boolean isDomainConnection() {
214+
return isDomainConnection;
215+
}
216+
217+
/**
218+
* Setter for the domain connection flag.
219+
* @param domainConnection the domain connection flag to set.
220+
*/
221+
public void setDomainConnection(boolean domainConnection) {
222+
isDomainConnection = domainConnection;
223+
}
186224
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.auth0.json.mgmt.selfserviceprofiles;
2+
3+
import com.fasterxml.jackson.annotation.JsonCreator;
4+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
5+
import com.fasterxml.jackson.annotation.JsonInclude;
6+
import com.fasterxml.jackson.annotation.JsonProperty;
7+
8+
@JsonInclude(JsonInclude.Include.NON_NULL)
9+
@JsonIgnoreProperties(ignoreUnknown = true)
10+
public class DomainAliasesConfig {
11+
@JsonProperty("domain_verification")
12+
private String domainVerification;
13+
14+
/**
15+
* Creates a new instance of the DomainAliasesConfig class.
16+
*/
17+
@JsonCreator
18+
public DomainAliasesConfig(@JsonProperty("domain_verification") String domainVerification) {
19+
this.domainVerification = domainVerification;
20+
}
21+
22+
/**
23+
* Getter for the domain verification.
24+
* @return the domain verification.
25+
*/
26+
public String getDomainVerification() {
27+
return domainVerification;
28+
}
29+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package com.auth0.json.mgmt.selfserviceprofiles;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import com.fasterxml.jackson.annotation.JsonInclude;
5+
import com.fasterxml.jackson.annotation.JsonProperty;
6+
7+
@JsonInclude(JsonInclude.Include.NON_NULL)
8+
@JsonIgnoreProperties(ignoreUnknown = true)
9+
public class EnabledOrganizations {
10+
@JsonProperty("organization_id")
11+
private String organizationId;
12+
@JsonProperty("assign_membership_on_login")
13+
private boolean assignMembershipOnLogin;
14+
@JsonProperty("show_as_button")
15+
private boolean showAsButton;
16+
17+
/**
18+
* Getter for the organization id.
19+
* @return the organization id.
20+
*/
21+
public String getOrganizationId() {
22+
return organizationId;
23+
}
24+
25+
/**
26+
* Setter for the organization id.
27+
* @param organizationId the organization id to set.
28+
*/
29+
public void setOrganizationId(String organizationId) {
30+
this.organizationId = organizationId;
31+
}
32+
33+
/**
34+
* Getter for the assign membership on login.
35+
* @return the assign membership on login.
36+
*/
37+
public boolean isAssignMembershipOnLogin() {
38+
return assignMembershipOnLogin;
39+
}
40+
41+
/**
42+
* Setter for the assign membership on login.
43+
* @param assignMembershipOnLogin the assign membership on login to set.
44+
*/
45+
public void setAssignMembershipOnLogin(boolean assignMembershipOnLogin) {
46+
this.assignMembershipOnLogin = assignMembershipOnLogin;
47+
}
48+
49+
/**
50+
* Getter for the show as button.
51+
* @return the show as button.
52+
*/
53+
public boolean isShowAsButton() {
54+
return showAsButton;
55+
}
56+
57+
/**
58+
* Setter for the show as button.
59+
* @param showAsButton the show as button to set.
60+
*/
61+
public void setShowAsButton(boolean showAsButton) {
62+
this.showAsButton = showAsButton;
63+
}
64+
}
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
package com.auth0.json.mgmt.selfserviceprofiles;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import com.fasterxml.jackson.annotation.JsonInclude;
5+
import com.fasterxml.jackson.annotation.JsonProperty;
6+
7+
import java.util.List;
8+
import java.util.Map;
9+
10+
@JsonInclude(JsonInclude.Include.NON_NULL)
11+
@JsonIgnoreProperties(ignoreUnknown = true)
12+
public class SsoAccessTicketRequest {
13+
@JsonProperty("connection_id")
14+
private String connectionId;
15+
@JsonProperty("connection_config")
16+
private Map<String, Object> connectionConfig;
17+
@JsonProperty("enabled_clients")
18+
private List<String> enabledClients;
19+
@JsonProperty("enabled_organizations")
20+
private List<EnabledOrganizations> enabledOrganizations;
21+
@JsonProperty("ttl_sec")
22+
private int ttlSec;
23+
@JsonProperty("domain_aliases_config")
24+
private DomainAliasesConfig domainAliasesConfig;
25+
26+
/**
27+
* Creates a new instance.
28+
* @return the new instance.
29+
*/
30+
public String getConnectionId() {
31+
return connectionId;
32+
}
33+
34+
/**
35+
* Sets the connection ID.
36+
* @param connectionId the connection ID to set.
37+
*/
38+
public void setConnectionId(String connectionId) {
39+
this.connectionId = connectionId;
40+
}
41+
42+
/**
43+
* Getter for the connection configuration.
44+
* @return the connection configuration.
45+
*/
46+
public Map<String, Object> getConnectionConfig() {
47+
return connectionConfig;
48+
}
49+
50+
/**
51+
* Setter for the connection configuration.
52+
* @param connectionConfig the connection configuration to set.
53+
*/
54+
public void setConnectionConfig(Map<String, Object> connectionConfig) {
55+
this.connectionConfig = connectionConfig;
56+
}
57+
58+
/**
59+
* Getter for the enabled clients.
60+
* @return the enabled clients.
61+
*/
62+
public List<String> getEnabledClients() {
63+
return enabledClients;
64+
}
65+
66+
/**
67+
* Setter for the enabled clients.
68+
* @param enabledClients the enabled clients to set.
69+
*/
70+
public void setEnabledClients(List<String> enabledClients) {
71+
this.enabledClients = enabledClients;
72+
}
73+
74+
/**
75+
* Getter for the enabled organizations.
76+
* @return the enabled organizations.
77+
*/
78+
public List<EnabledOrganizations> getEnabledOrganizations() {
79+
return enabledOrganizations;
80+
}
81+
82+
/**
83+
* Setter for the enabled organizations.
84+
* @param enabledOrganizations the enabled organizations to set.
85+
*/
86+
public void setEnabledOrganizations(List<EnabledOrganizations> enabledOrganizations) {
87+
this.enabledOrganizations = enabledOrganizations;
88+
}
89+
90+
/**
91+
* Getter for the TTL in seconds.
92+
* @return the TTL in seconds.
93+
*/
94+
public int getTtlSec() {
95+
return ttlSec;
96+
}
97+
98+
/**
99+
* Setter for the TTL in seconds.
100+
* @param ttlSec the TTL in seconds to set.
101+
*/
102+
public void setTtlSec(int ttlSec) {
103+
this.ttlSec = ttlSec;
104+
}
105+
106+
/**
107+
* Getter for the domain aliases configuration.
108+
* @return the domain aliases configuration.
109+
*/
110+
public DomainAliasesConfig getDomainAliasesConfig() {
111+
return domainAliasesConfig;
112+
}
113+
114+
/**
115+
* Setter for the domain aliases configuration.
116+
* @param domainAliasesConfig the domain aliases configuration to set.
117+
*/
118+
public void setDomainAliasesConfig(DomainAliasesConfig domainAliasesConfig) {
119+
this.domainAliasesConfig = domainAliasesConfig;
120+
}
121+
}

src/test/java/com/auth0/client/mgmt/ConnectionsEntityTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ public void shouldCreateConnection() throws Exception {
188188
assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
189189

190190
Map<String, Object> body = bodyFromRequest(recordedRequest);
191-
assertThat(body.size(), is(2));
191+
assertThat(body.size(), is(5));
192192
assertThat(body, hasEntry("name", "my-connection"));
193193
assertThat(body, hasEntry("strategy", "auth0"));
194194

@@ -244,7 +244,7 @@ public void shouldUpdateConnection() throws Exception {
244244
assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
245245

246246
Map<String, Object> body = bodyFromRequest(recordedRequest);
247-
assertThat(body.size(), is(2));
247+
assertThat(body.size(), is(5));
248248
assertThat(body, hasEntry("name", "my-connection"));
249249
assertThat(body, hasEntry("strategy", "auth0"));
250250

src/test/java/com/auth0/client/mgmt/SelfServiceProfilesEntityTest.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
package com.auth0.client.mgmt;
22

33
import com.auth0.client.mgmt.filter.PageBasedPaginationFilter;
4-
import com.auth0.json.mgmt.selfserviceprofiles.SelfServiceProfile;
5-
import com.auth0.json.mgmt.selfserviceprofiles.SelfServiceProfileResponse;
6-
import com.auth0.json.mgmt.selfserviceprofiles.SelfServiceProfileResponsePage;
7-
import com.auth0.json.mgmt.selfserviceprofiles.SsoAccessTicketResponse;
4+
import com.auth0.json.mgmt.selfserviceprofiles.*;
85
import com.auth0.net.Request;
96
import com.auth0.net.client.HttpMethod;
107
import okhttp3.mockwebserver.RecordedRequest;
@@ -268,22 +265,21 @@ public void shouldSetCustomText() throws Exception {
268265
@Test
269266
public void shouldThrowOnCreateSsoAccessTicketWhenIdIsNull() {
270267
verifyThrows(IllegalArgumentException.class,
271-
() -> api.selfServiceProfiles().createSsoAccessTicket(null, new Object()), "'id' cannot be null!");
268+
() -> api.selfServiceProfiles().createSsoAccessTicket(null, new SsoAccessTicketRequest()), "'id' cannot be null!");
272269
}
273270

274271
@Test
275272
public void shouldThrowOnCreateSsoAccessTicketWhenPayloadIsNull() {
276273
verifyThrows(IllegalArgumentException.class,
277-
() -> api.selfServiceProfiles().createSsoAccessTicket("id", null), "'payload' cannot be null!");
274+
() -> api.selfServiceProfiles().createSsoAccessTicket("id", null), "'request body' cannot be null!");
278275
}
279276

280277
@Test
281278
public void shouldCreateSsoAccessTicket() throws Exception{
282-
Map<String, Object> payload = new HashMap<>();
279+
SsoAccessTicketRequest requestBody = new SsoAccessTicketRequest();
280+
requestBody.setConnectionId("test-connection");
283281

284-
payload.put("connection_id", "test-connection");
285-
286-
Request<SsoAccessTicketResponse> request = api.selfServiceProfiles().createSsoAccessTicket("id", payload);
282+
Request<SsoAccessTicketResponse> request = api.selfServiceProfiles().createSsoAccessTicket("id", requestBody);
287283
assertThat(request, is(notNullValue()));
288284

289285
server.jsonResponse(SELF_SERVICE_PROFILE_SSO_TICKET, 200);

0 commit comments

Comments
 (0)