Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(config-api): fix for associated client not fetched for scope #2540

Merged
merged 1 commit into from
Oct 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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