Skip to content

Commit

Permalink
fix(config-api): fix for assosiated client not fetched for scope (#2540)
Browse files Browse the repository at this point in the history
  • Loading branch information
pujavs authored Oct 4, 2022
1 parent 9d4d84a commit 08488d1
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 30 deletions.
40 changes: 20 additions & 20 deletions jans-config-api/docs/jans-config-api-swagger-auto.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2945,19 +2945,19 @@ components:
$ref: '#/components/schemas/AttributeValidation'
tooltip:
type: string
adminCanView:
whitePagesCanView:
type: boolean
userCanAccess:
adminCanAccess:
type: boolean
adminCanEdit:
userCanEdit:
type: boolean
userCanView:
adminCanEdit:
type: boolean
userCanEdit:
adminCanView:
type: boolean
adminCanAccess:
userCanView:
type: boolean
whitePagesCanView:
userCanAccess:
type: boolean
baseDn:
type: string
Expand Down Expand Up @@ -4090,17 +4090,6 @@ components:
$ref: '#/components/schemas/EngineConfig'
ssaConfiguration:
$ref: '#/components/schemas/SsaConfiguration'
fapi:
type: boolean
allResponseTypesSupported:
uniqueItems: true
type: array
items:
type: string
enum:
- code
- token
- id_token
enabledFeatureFlags:
uniqueItems: true
type: array
Expand Down Expand Up @@ -4128,6 +4117,17 @@ components:
- STAT
- PAR
- SSA
fapi:
type: boolean
allResponseTypesSupported:
uniqueItems: true
type: array
items:
type: string
enum:
- code
- token
- id_token
AuthenticationFilter:
required:
- baseDn
Expand Down Expand Up @@ -4384,13 +4384,13 @@ components:
type: boolean
internal:
type: boolean
locationPath:
type: string
locationType:
type: string
enum:
- ldap
- file
locationPath:
type: string
baseDn:
type: string
ScriptError:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,7 @@ public Response deleteScope(@PathParam(ApiConstants.INUM) @NotNull String inum)
}

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

PagedResult<CustomScope> pagedResult = scopeService.getScopeResult(searchReq, type, withAssociatedClients);
if (logger.isTraceEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,30 +207,42 @@ public List<CustomScope> searchScope(SearchRequest searchRequest) {
}

private CustomScope setClients(Scope scope, List<Client> clients, List<UmaResource> umaResources) {
logger.debug("Search Scope with associated clients - scope:{}, clients:{}, umaResources:{}", scope, clients,
umaResources);

ObjectMapper mapper = new ObjectMapper();
CustomScope customScope = mapper.convertValue(scope, CustomScope.class);
customScope.setClients(Lists.newArrayList());

for (Client client : clients) {
if (client.getScopes() == null) {
continue;
}
logger.debug(
"Associated clients serach - scope.getScopeType():{}, scope.getInum():{}, scope.getCreatorId():{}, client.getClientId():{}, clientService.getDnForClient(client.getClientId()):{}, client.getScopes():{}, client.getClientId().equals(scope.getCreatorId()):{}",
scope.getScopeType(), scope.getInum(), scope.getCreatorId(), client.getClientId(),
clientService.getDnForClient(client.getClientId()), client.getScopes(),
client.getClientId().equals(scope.getCreatorId()));

if (scope.getScopeType() == ScopeType.OPENID || scope.getScopeType() == ScopeType.OAUTH
|| scope.getScopeType() == ScopeType.DYNAMIC) {
if (Arrays.asList(client.getScopes()).contains(getDnForScope(scope.getInum()))) {
if (client.getScopes() != null
&& Arrays.asList(client.getScopes()).contains(getDnForScope(scope.getInum()))) {
customScope.getClients().add(client);
}
} else if (scope.getScopeType() == ScopeType.UMA) {
List<UmaResource> umaRes = umaResources.stream()
.filter(umaResource -> (umaResource.getScopes() != null
&& umaResource.getScopes().contains(getDnForScope(scope.getInum()))))
.collect(Collectors.toList());
if (umaRes.stream().anyMatch(
ele -> ele.getClients().contains(clientService.getDnForClient(client.getClientId())))) {
logger.trace("Associated clients serach - umaRes():{}", umaRes);
for (UmaResource res : umaRes) {
logger.trace(
" client.getDn():{}, res.getInum():{}, res.getClients():{}, res.getClients().contains(clientService.getDnForClient(client.getClientId()):{}",
client.getDn(), res.getInum(), res.getClients(),
res.getClients().contains(clientService.getDnForClient(client.getClientId())));
customScope.getClients().add(client);

}
} else if ((scope.getScopeType() == ScopeType.SPONTANEOUS)
&& (client.getClientId().equals(customScope.getCreatorId()))) {
&& (client.getClientId().equals(scope.getCreatorId()))) {
customScope.getClients().add(client);
}
}
Expand Down

0 comments on commit 08488d1

Please sign in to comment.