Skip to content

Commit 08488d1

Browse files
authored
fix(config-api): fix for assosiated client not fetched for scope (#2540)
1 parent 9d4d84a commit 08488d1

File tree

3 files changed

+40
-30
lines changed

3 files changed

+40
-30
lines changed

jans-config-api/docs/jans-config-api-swagger-auto.yaml

+20-20
Original file line numberDiff line numberDiff line change
@@ -2945,19 +2945,19 @@ components:
29452945
$ref: '#/components/schemas/AttributeValidation'
29462946
tooltip:
29472947
type: string
2948-
adminCanView:
2948+
whitePagesCanView:
29492949
type: boolean
2950-
userCanAccess:
2950+
adminCanAccess:
29512951
type: boolean
2952-
adminCanEdit:
2952+
userCanEdit:
29532953
type: boolean
2954-
userCanView:
2954+
adminCanEdit:
29552955
type: boolean
2956-
userCanEdit:
2956+
adminCanView:
29572957
type: boolean
2958-
adminCanAccess:
2958+
userCanView:
29592959
type: boolean
2960-
whitePagesCanView:
2960+
userCanAccess:
29612961
type: boolean
29622962
baseDn:
29632963
type: string
@@ -4090,17 +4090,6 @@ components:
40904090
$ref: '#/components/schemas/EngineConfig'
40914091
ssaConfiguration:
40924092
$ref: '#/components/schemas/SsaConfiguration'
4093-
fapi:
4094-
type: boolean
4095-
allResponseTypesSupported:
4096-
uniqueItems: true
4097-
type: array
4098-
items:
4099-
type: string
4100-
enum:
4101-
- code
4102-
- token
4103-
- id_token
41044093
enabledFeatureFlags:
41054094
uniqueItems: true
41064095
type: array
@@ -4128,6 +4117,17 @@ components:
41284117
- STAT
41294118
- PAR
41304119
- SSA
4120+
fapi:
4121+
type: boolean
4122+
allResponseTypesSupported:
4123+
uniqueItems: true
4124+
type: array
4125+
items:
4126+
type: string
4127+
enum:
4128+
- code
4129+
- token
4130+
- id_token
41314131
AuthenticationFilter:
41324132
required:
41334133
- baseDn
@@ -4384,13 +4384,13 @@ components:
43844384
type: boolean
43854385
internal:
43864386
type: boolean
4387-
locationPath:
4388-
type: string
43894387
locationType:
43904388
type: string
43914389
enum:
43924390
- ldap
43934391
- file
4392+
locationPath:
4393+
type: string
43944394
baseDn:
43954395
type: string
43964396
ScriptError:

jans-config-api/server/src/main/java/io/jans/configapi/rest/resource/auth/ScopesResource.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,7 @@ public Response deleteScope(@PathParam(ApiConstants.INUM) @NotNull String inum)
263263
}
264264

265265
private PagedResult<CustomScope> doSearch(SearchRequest searchReq, String type, boolean withAssociatedClients) {
266-
if (logger.isDebugEnabled()) {
267-
logger.debug("CustomScope search params - searchReq:{} ", escapeLog(searchReq));
268-
}
266+
logger.debug("CustomScope search params - searchReq:{}, type:{}, withAssociatedClients:{} ", searchReq, type, withAssociatedClients);
269267

270268
PagedResult<CustomScope> pagedResult = scopeService.getScopeResult(searchReq, type, withAssociatedClients);
271269
if (logger.isTraceEnabled()) {

jans-config-api/server/src/main/java/io/jans/configapi/service/auth/ScopeService.java

+19-7
Original file line numberDiff line numberDiff line change
@@ -207,30 +207,42 @@ public List<CustomScope> searchScope(SearchRequest searchRequest) {
207207
}
208208

209209
private CustomScope setClients(Scope scope, List<Client> clients, List<UmaResource> umaResources) {
210+
logger.debug("Search Scope with associated clients - scope:{}, clients:{}, umaResources:{}", scope, clients,
211+
umaResources);
212+
210213
ObjectMapper mapper = new ObjectMapper();
211214
CustomScope customScope = mapper.convertValue(scope, CustomScope.class);
212215
customScope.setClients(Lists.newArrayList());
213216

214217
for (Client client : clients) {
215-
if (client.getScopes() == null) {
216-
continue;
217-
}
218+
logger.debug(
219+
"Associated clients serach - scope.getScopeType():{}, scope.getInum():{}, scope.getCreatorId():{}, client.getClientId():{}, clientService.getDnForClient(client.getClientId()):{}, client.getScopes():{}, client.getClientId().equals(scope.getCreatorId()):{}",
220+
scope.getScopeType(), scope.getInum(), scope.getCreatorId(), client.getClientId(),
221+
clientService.getDnForClient(client.getClientId()), client.getScopes(),
222+
client.getClientId().equals(scope.getCreatorId()));
223+
218224
if (scope.getScopeType() == ScopeType.OPENID || scope.getScopeType() == ScopeType.OAUTH
219225
|| scope.getScopeType() == ScopeType.DYNAMIC) {
220-
if (Arrays.asList(client.getScopes()).contains(getDnForScope(scope.getInum()))) {
226+
if (client.getScopes() != null
227+
&& Arrays.asList(client.getScopes()).contains(getDnForScope(scope.getInum()))) {
221228
customScope.getClients().add(client);
222229
}
223230
} else if (scope.getScopeType() == ScopeType.UMA) {
224231
List<UmaResource> umaRes = umaResources.stream()
225232
.filter(umaResource -> (umaResource.getScopes() != null
226233
&& umaResource.getScopes().contains(getDnForScope(scope.getInum()))))
227234
.collect(Collectors.toList());
228-
if (umaRes.stream().anyMatch(
229-
ele -> ele.getClients().contains(clientService.getDnForClient(client.getClientId())))) {
235+
logger.trace("Associated clients serach - umaRes():{}", umaRes);
236+
for (UmaResource res : umaRes) {
237+
logger.trace(
238+
" client.getDn():{}, res.getInum():{}, res.getClients():{}, res.getClients().contains(clientService.getDnForClient(client.getClientId()):{}",
239+
client.getDn(), res.getInum(), res.getClients(),
240+
res.getClients().contains(clientService.getDnForClient(client.getClientId())));
230241
customScope.getClients().add(client);
242+
231243
}
232244
} else if ((scope.getScopeType() == ScopeType.SPONTANEOUS)
233-
&& (client.getClientId().equals(customScope.getCreatorId()))) {
245+
&& (client.getClientId().equals(scope.getCreatorId()))) {
234246
customScope.getClients().add(client);
235247
}
236248
}

0 commit comments

Comments
 (0)