Skip to content

Commit d8e14eb

Browse files
authored
feat: documentation for ssa and remove softwareRoles query param of get ssa (#3031)
1 parent 21dd6e5 commit d8e14eb

File tree

13 files changed

+432
-59
lines changed

13 files changed

+432
-59
lines changed

docs/admin/auth-server/endpoints/ssa.md

+399-7
Large diffs are not rendered by default.

jans-auth-server/client/src/main/java/io/jans/as/client/ssa/get/SsaGetClient.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import jakarta.ws.rs.HttpMethod;
1212
import jakarta.ws.rs.client.Invocation.Builder;
1313
import org.apache.commons.lang.StringUtils;
14-
import org.apache.http.client.utils.URIBuilder;
1514
import org.apache.log4j.Logger;
1615

1716
public class SsaGetClient extends BaseClient<SsaGetRequest, SsaGetResponse> {
@@ -27,12 +26,11 @@ public String getHttpMethod() {
2726
return HttpMethod.GET;
2827
}
2928

30-
public SsaGetResponse execSsaGet(String accessToken, String jti, Long orgId, Boolean softwareRoles) {
29+
public SsaGetResponse execSsaGet(String accessToken, String jti, Long orgId) {
3130
SsaGetRequest ssaGetRequest = new SsaGetRequest();
3231
ssaGetRequest.setAccessToken(accessToken);
3332
ssaGetRequest.setJti(jti);
3433
ssaGetRequest.setOrgId(orgId);
35-
ssaGetRequest.setSoftwareRoles(softwareRoles);
3634
setRequest(ssaGetRequest);
3735
return exec();
3836
}

jans-auth-server/client/src/main/java/io/jans/as/client/ssa/get/SsaGetRequest.java

-11
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ public class SsaGetRequest extends BaseRequest {
2020

2121
private Long orgId;
2222

23-
private Boolean softwareRoles;
24-
2523
public SsaGetRequest() {
2624
setContentType(MediaType.APPLICATION_JSON);
2725
setMediaType(MediaType.APPLICATION_JSON);
@@ -52,20 +50,11 @@ public void setOrgId(Long orgId) {
5250
this.orgId = orgId;
5351
}
5452

55-
public Boolean getSoftwareRoles() {
56-
return softwareRoles;
57-
}
58-
59-
public void setSoftwareRoles(Boolean softwareRoles) {
60-
this.softwareRoles = softwareRoles;
61-
}
62-
6353
@Override
6454
public String getQueryString() {
6555
QueryBuilder builder = QueryBuilder.instance();
6656
builder.append(SsaRequestParam.JTI.getName(), jti);
6757
builder.append(SsaRequestParam.ORG_ID.getName(), orgId != null ? orgId.toString() : "");
68-
builder.append(SsaRequestParam.SOFTWARE_ROLES.getName(), softwareRoles != null ? softwareRoles.toString() : "");
6958
return builder.toString();
7059
}
7160
}

jans-auth-server/client/src/test/java/io/jans/as/client/ssa/SsaGetTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public void getSsaSearchByOrgId(final String redirectUris, final String sectorId
5151

5252
// Ssa get
5353
SsaGetClient ssaGetClient = new SsaGetClient(ssaEndpoint);
54-
SsaGetResponse ssaGetResponse = ssaGetClient.execSsaGet(accessToken, null, orgId1, false);
54+
SsaGetResponse ssaGetResponse = ssaGetClient.execSsaGet(accessToken, null, orgId1);
5555
AssertBuilder.ssaGet(ssaGetResponse)
5656
.ssaListSize(2)
5757
.jtiList(jtiList)
@@ -82,7 +82,7 @@ public void getSsaSearchByJti(final String redirectUris, final String sectorIden
8282

8383
// Ssa get
8484
SsaGetClient ssaGetClient = new SsaGetClient(ssaEndpoint);
85-
SsaGetResponse ssaGetResponse = ssaGetClient.execSsaGet(accessToken, jti, null, false);
85+
SsaGetResponse ssaGetResponse = ssaGetClient.execSsaGet(accessToken, jti, null);
8686
AssertBuilder.ssaGet(ssaGetResponse)
8787
.ssaListSize(1)
8888
.jtiList(jtiList)
@@ -114,7 +114,7 @@ public void getSsaSearchByOrgIdAndJti(final String redirectUris, final String se
114114

115115
// Ssa get
116116
SsaGetClient ssaGetClient = new SsaGetClient(ssaEndpoint);
117-
SsaGetResponse ssaGetResponse = ssaGetClient.execSsaGet(accessToken, jti, orgId1, false);
117+
SsaGetResponse ssaGetResponse = ssaGetClient.execSsaGet(accessToken, jti, orgId1);
118118
AssertBuilder.ssaGet(ssaGetResponse)
119119
.ssaListSize(1)
120120
.jtiList(jtiList)
@@ -145,7 +145,7 @@ public void getSsaSearchByJtiNotExits(final String redirectUris, final String se
145145

146146
// Ssa get
147147
SsaGetClient ssaGetClient = new SsaGetClient(ssaEndpoint);
148-
SsaGetResponse ssaGetResponse = ssaGetClient.execSsaGet(accessToken, jti, null, false);
148+
SsaGetResponse ssaGetResponse = ssaGetClient.execSsaGet(accessToken, jti, null);
149149
AssertBuilder.ssaGet(ssaGetResponse)
150150
.ssaListSize(0)
151151
.jtiList(jtiList)

jans-auth-server/client/src/test/java/io/jans/as/client/ssa/SsaRevokeTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public void revokeWithJtiResponseOK(final String redirectUris, final String sect
6464

6565
// Ssa get
6666
SsaGetClient ssaGetClient = new SsaGetClient(ssaEndpoint);
67-
SsaGetResponse ssaGetResponse = ssaGetClient.execSsaGet(accessToken, jti, orgId, false);
67+
SsaGetResponse ssaGetResponse = ssaGetClient.execSsaGet(accessToken, jti, orgId);
6868
showClient(ssaGetClient);
6969
assertNotNull(ssaGetResponse, "Ssa get response is null");
7070
assertTrue(ssaGetResponse.getSsaList().isEmpty());

jans-auth-server/model/src/main/java/io/jans/as/model/ssa/SsaScopeType.java

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ public enum SsaScopeType {
1616
SSA_DEVELOPER("https://jans.io/auth/ssa.developer"),
1717
;
1818

19-
2019
private static final Map<String, SsaScopeType> lookup = new HashMap<>();
2120

2221
static {

jans-auth-server/server/src/main/java/io/jans/as/server/ssa/ws/rs/SsaRestWebService.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ Response create(
3737
/**
3838
* Get list of SSA based on "jti" or "org_id" filter.
3939
*
40-
* @param jti Unique identifier
41-
* @param orgId Organization ID
42-
* @param httpRequest Http request
40+
* @param jti Unique identifier
41+
* @param orgId Organization ID
42+
* @param httpRequest Http request
4343
* @return the {@link Response} with status {@code 200 (Ok)} and with body the ssa list,
4444
* or with status {@code 401 (Unauthorized)} if unauthorized access request,
4545
* or with status {@code 500 (Internal Server Error)} if internal error occurred.
@@ -48,7 +48,6 @@ Response create(
4848
@Path("/ssa")
4949
@Produces({MediaType.APPLICATION_JSON})
5050
Response get(
51-
@QueryParam("software_roles") Boolean softwareRoles,
5251
@QueryParam("jti") String jti,
5352
@QueryParam("org_id") Long orgId,
5453
@Context HttpServletRequest httpRequest

jans-auth-server/server/src/main/java/io/jans/as/server/ssa/ws/rs/SsaRestWebServiceImpl.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ public Response create(String requestParams, HttpServletRequest httpRequest) {
6060
* @return {@link Response} with status {@code 200 (Ok)} and with body List of SSA.
6161
*/
6262
@Override
63-
public Response get(Boolean softwareRoles, String jti, Long orgId, HttpServletRequest httpRequest) {
64-
return ssaGetAction.get(softwareRoles, jti, orgId, httpRequest);
63+
public Response get(String jti, Long orgId, HttpServletRequest httpRequest) {
64+
return ssaGetAction.get(jti, orgId, httpRequest);
6565
}
6666

6767
/**

jans-auth-server/server/src/main/java/io/jans/as/server/ssa/ws/rs/SsaService.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public Ssa findSsaByJti(String jti) {
104104
*/
105105
public List<Ssa> getSsaList(String jti, Long orgId, SsaState status, String clientId, String[] scopes) {
106106
List<Filter> filters = new ArrayList<>();
107-
if (hasPortalScope(Arrays.asList(scopes))) {
107+
if (hasDeveloperScope(Arrays.asList(scopes))) {
108108
filters.add(Filter.createEqualityFilter("creatorId", clientId));
109109
}
110110
if (jti != null) {
@@ -183,19 +183,19 @@ public Response.ResponseBuilder createNotAcceptableResponse() {
183183
}
184184

185185
/**
186-
* Check if there is only one "ssa.portal" scope
186+
* Check if there is only one "ssa.developer" scope
187187
*
188188
* @param scopes List of scope
189-
* @return true if is only one "ssa.portal", or false otherwise
189+
* @return true if is only one "ssa.developer", or false otherwise
190190
*/
191-
private boolean hasPortalScope(List<String> scopes) {
191+
private boolean hasDeveloperScope(List<String> scopes) {
192192
Iterator<String> scopesIterator = scopes.iterator();
193193
boolean result = false;
194194
while (scopesIterator.hasNext()) {
195195
String scope = scopesIterator.next();
196-
if (scope.equals(SsaScopeType.SSA_ADMIN.getValue())) {
196+
if (scope.equals(SsaScopeType.SSA_ADMIN.getValue()) || scope.equals(SsaScopeType.SSA_PORTAL.getValue())) {
197197
return false;
198-
} else if (scope.equals(SsaScopeType.SSA_PORTAL.getValue())) {
198+
} else if (scope.equals(SsaScopeType.SSA_DEVELOPER.getValue())) {
199199
result = true;
200200
}
201201
}

jans-auth-server/server/src/main/java/io/jans/as/server/ssa/ws/rs/action/SsaGetAction.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,14 @@ public class SsaGetAction {
9393
* @param httpRequest Http request
9494
* @return {@link Response} with status {@code 200 (Ok)} and the body containing the list of SSAs.
9595
*/
96-
public Response get(Boolean softwareRoles, String jti, Long orgId, HttpServletRequest httpRequest) {
97-
log.debug("Attempting to read ssa: softwareRoles = {}, jti = '{}', orgId = {}", softwareRoles, jti, orgId);
96+
public Response get(String jti, Long orgId, HttpServletRequest httpRequest) {
97+
log.debug("Attempting to read ssa: softwareRoles = {}, orgId = {}", jti, orgId);
9898

9999
errorResponseFactory.validateFeatureEnabled(FeatureFlagType.SSA);
100100
Response.ResponseBuilder builder = Response.ok();
101101
try {
102102
final Client client = ssaRestWebServiceValidator.getClientFromSession();
103-
ssaRestWebServiceValidator.checkScopesPolicy(client, Arrays.asList(SsaScopeType.SSA_ADMIN.getValue(), SsaScopeType.SSA_PORTAL.getValue()));
103+
ssaRestWebServiceValidator.checkScopesPolicy(client, Arrays.asList(SsaScopeType.SSA_ADMIN.getValue(), SsaScopeType.SSA_PORTAL.getValue(), SsaScopeType.SSA_DEVELOPER.getValue()));
104104

105105
final List<Ssa> ssaList = ssaService.getSsaList(jti, orgId, SsaState.ACTIVE, client.getClientId(), client.getScopes());
106106

jans-auth-server/server/src/test/java/io/jans/as/server/ssa/ws/rs/SsaRestWebServiceImplTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ public void create_validParams_validResponse() {
4747

4848
@Test
4949
public void get_validParams_validResponse() {
50-
when(ssaGetAction.get(anyBoolean(), anyString(), any(), any())).thenReturn(mock(Response.class));
50+
when(ssaGetAction.get(anyString(), any(), any())).thenReturn(mock(Response.class));
5151

52-
Response response = ssaRestWebServiceImpl.get(false, "testJti", 1000L, mock(HttpServletRequest.class));
52+
Response response = ssaRestWebServiceImpl.get("testJti", 1000L, mock(HttpServletRequest.class));
5353
assertNotNull(response, "response is null");
54-
verify(ssaGetAction).get(anyBoolean(), anyString(), any(), any());
54+
verify(ssaGetAction).get(anyString(), any(), any());
5555
verifyNoMoreInteractions(ssaGetAction);
5656
}
5757

jans-auth-server/server/src/test/java/io/jans/as/server/ssa/ws/rs/SsaServiceTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ public void findSsaByJti_jtiNotFound_ssaNull() {
198198
}
199199

200200
@Test
201-
public void getSsaList_withPortalScope_valid() {
201+
public void getSsaList_withDeveloperScope_valid() {
202202
BaseDnConfiguration baseDnConfiguration = new BaseDnConfiguration();
203203
baseDnConfiguration.setSsa("ou=ssa,o=jans");
204204
when(staticConfiguration.getBaseDn()).thenReturn(baseDnConfiguration);
@@ -207,7 +207,7 @@ public void getSsaList_withPortalScope_valid() {
207207
Long orgId = null;
208208
SsaState status = null;
209209
String clientId = "test-client";
210-
String[] scopes = new String[]{SsaScopeType.SSA_PORTAL.getValue()};
210+
String[] scopes = new String[]{SsaScopeType.SSA_DEVELOPER.getValue()};
211211
List<Ssa> ssaList = ssaService.getSsaList(jti, orgId, status, clientId, scopes);
212212
assertNotNull(ssaList);
213213
verify(log).trace(eq("Filter with AND created: " + String.format("[(creatorId=%s)]", clientId)));

jans-auth-server/server/src/test/java/io/jans/as/server/ssa/ws/rs/action/SsaGetActionTest.java

+8-12
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,13 @@ public void get_withAllParam_valid() {
5555
client.setDn("inum=0000,ou=clients,o=jans");
5656
when(ssaRestWebServiceValidator.getClientFromSession()).thenReturn(client);
5757

58-
boolean softwareRoles = false;
5958
String jti = "my-jti";
6059
Long orgId = 1000L;
61-
Response response = ssaGetAction.get(softwareRoles, jti, orgId, mock(HttpServletRequest.class));
60+
Response response = ssaGetAction.get(jti, orgId, mock(HttpServletRequest.class));
6261
assertNotNull(response, "response is null");
6362
assertNotNull(response.getEntity(), "response entity is null");
6463
assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
65-
verify(log).debug(anyString(), any(), any(), any());
64+
verify(log).debug(anyString(), any(), any());
6665
verify(errorResponseFactory).validateFeatureEnabled(any());
6766
verify(ssaContextBuilder).buildModifySsaResponseContext(any(), any(), any(), any(), any());
6867
verify(ssaJsonService).jsonArrayToString(any());
@@ -79,11 +78,10 @@ public void get_invalidClientAndIsErrorEnabledFalse_badRequestResponse() {
7978
doThrow(error).when(ssaRestWebServiceValidator).getClientFromSession();
8079
when(log.isErrorEnabled()).thenReturn(Boolean.FALSE);
8180

82-
boolean softwareRoles = false;
8381
String jti = "my-jti";
8482
Long orgId = 1000L;
85-
assertThrows(WebApplicationException.class, () -> ssaGetAction.get(softwareRoles, jti, orgId, mock(HttpServletRequest.class)));
86-
verify(log).debug(anyString(), any(), any(), any());
83+
assertThrows(WebApplicationException.class, () -> ssaGetAction.get(jti, orgId, mock(HttpServletRequest.class)));
84+
verify(log).debug(anyString(), any(), any());
8785
verify(ssaRestWebServiceValidator).getClientFromSession();
8886
verify(log).isErrorEnabled();
8987
verify(log, never()).error(anyString(), any(WebApplicationException.class));
@@ -100,11 +98,10 @@ public void get_invalidClientAndIsErrorEnabledTrue_badRequestResponse() {
10098
doThrow(error).when(ssaRestWebServiceValidator).getClientFromSession();
10199
when(log.isErrorEnabled()).thenReturn(Boolean.TRUE);
102100

103-
boolean softwareRoles = false;
104101
String jti = "my-jti";
105102
Long orgId = 1000L;
106-
assertThrows(WebApplicationException.class, () -> ssaGetAction.get(softwareRoles, jti, orgId, mock(HttpServletRequest.class)));
107-
verify(log).debug(anyString(), any(), any(), any());
103+
assertThrows(WebApplicationException.class, () -> ssaGetAction.get(jti, orgId, mock(HttpServletRequest.class)));
104+
verify(log).debug(anyString(), any(), any());
108105
verify(ssaRestWebServiceValidator).getClientFromSession();
109106
verify(log).isErrorEnabled();
110107
verify(log).error(anyString(), any(WebApplicationException.class));
@@ -120,11 +117,10 @@ public void get_invalidClientInternalServer_badRequestResponse() {
120117
.build());
121118
when(errorResponseFactory.createWebApplicationException(any(Response.Status.class), any(SsaErrorResponseType.class), anyString())).thenThrow(error);
122119

123-
boolean softwareRoles = false;
124120
String jti = "my-jti";
125121
Long orgId = 1000L;
126-
assertThrows(WebApplicationException.class, () -> ssaGetAction.get(softwareRoles, jti, orgId, mock(HttpServletRequest.class)));
127-
verify(log).debug(anyString(), any(), any(), any());
122+
assertThrows(WebApplicationException.class, () -> ssaGetAction.get(jti, orgId, mock(HttpServletRequest.class)));
123+
verify(log).debug(anyString(), any(), any());
128124
verify(ssaRestWebServiceValidator).getClientFromSession();
129125
verify(log, never()).isErrorEnabled();
130126
verify(log).error(any(), any(Exception.class));

0 commit comments

Comments
 (0)