Skip to content

Commit d51ae24

Browse files
authored
fix(config-api): scope addiotion while client creation (#2714)
* feat(config-api): swagger fixes * feat(config-api): swagger fixes * fix(config-api): scope addiotion while client creation
1 parent e4e2670 commit d51ae24

File tree

3 files changed

+35
-56
lines changed

3 files changed

+35
-56
lines changed

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

+17-17
Original file line numberDiff line numberDiff line change
@@ -2945,18 +2945,18 @@ components:
29452945
$ref: '#/components/schemas/AttributeValidation'
29462946
tooltip:
29472947
type: string
2948-
adminCanEdit:
2948+
userCanAccess:
29492949
type: boolean
29502950
adminCanView:
29512951
type: boolean
2952+
adminCanAccess:
2953+
type: boolean
29522954
userCanView:
29532955
type: boolean
2954-
userCanAccess:
2956+
adminCanEdit:
29552957
type: boolean
29562958
userCanEdit:
29572959
type: boolean
2958-
adminCanAccess:
2959-
type: boolean
29602960
whitePagesCanView:
29612961
type: boolean
29622962
baseDn:
@@ -3389,24 +3389,24 @@ components:
33893389
type: array
33903390
items:
33913391
type: object
3392-
displayValue:
3393-
type: string
33943392
value:
33953393
type: object
3394+
displayValue:
3395+
type: string
33963396
LocalizedString:
33973397
type: object
33983398
properties:
33993399
values:
34003400
type: object
34013401
additionalProperties:
34023402
type: string
3403+
value:
3404+
type: string
34033405
languageTags:
34043406
uniqueItems: true
34053407
type: array
34063408
items:
34073409
type: string
3408-
value:
3409-
type: string
34103410
AppConfiguration:
34113411
type: object
34123412
properties:
@@ -4093,6 +4093,15 @@ components:
40934093
$ref: '#/components/schemas/EngineConfig'
40944094
ssaConfiguration:
40954095
$ref: '#/components/schemas/SsaConfiguration'
4096+
allResponseTypesSupported:
4097+
uniqueItems: true
4098+
type: array
4099+
items:
4100+
type: string
4101+
enum:
4102+
- code
4103+
- token
4104+
- id_token
40964105
fapi:
40974106
type: boolean
40984107
enabledFeatureFlags:
@@ -4122,15 +4131,6 @@ components:
41224131
- STAT
41234132
- PAR
41244133
- SSA
4125-
allResponseTypesSupported:
4126-
uniqueItems: true
4127-
type: array
4128-
items:
4129-
type: string
4130-
enum:
4131-
- code
4132-
- token
4133-
- id_token
41344134
AuthenticationFilter:
41354135
required:
41364136
- baseDn

jans-config-api/plugins/docs/user-mgt-plugin-swagger.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,10 @@ components:
225225
type: array
226226
items:
227227
type: object
228-
displayValue:
229-
type: string
230228
value:
231229
type: object
230+
displayValue:
231+
type: string
232232
CustomUser:
233233
type: object
234234
properties:

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

+16-37
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@
3838
import org.apache.commons.lang.StringUtils;
3939
import org.slf4j.Logger;
4040

41-
import com.google.common.collect.Lists;
42-
4341
/**
4442
* @author Mougang T.Gasmyr
4543
*
@@ -199,7 +197,7 @@ public Client setClientDefaultAttributes(Client client, boolean update) {
199197
return client;
200198
}
201199

202-
logger.debug("client.getApplicationType:{}, client.getRedirectUris():{}, client.getClaimRedirectUris():{}",
200+
logger.trace("client.getApplicationType:{}, client.getRedirectUris():{}, client.getClaimRedirectUris():{}",
203201
client.getApplicationType(), client.getRedirectUris(), client.getClaimRedirectUris());
204202

205203
List<String> redirectUris = client.getRedirectUris() != null ? Arrays.asList(client.getRedirectUris()) : null;
@@ -214,15 +212,17 @@ public Client setClientDefaultAttributes(Client client, boolean update) {
214212
claimsRedirectUris = new ArrayList<>(new HashSet<>(claimsRedirectUris)); // Remove repeated elements
215213
client.setClaimRedirectUris(claimsRedirectUris.toArray(new String[0]));
216214
}
217-
215+
logger.trace("After setting client.getApplicationType:{}, client.getRedirectUris():{}, client.getClaimRedirectUris():{}",
216+
client.getApplicationType(), client.getRedirectUris(), client.getClaimRedirectUris());
217+
218218
client.setApplicationType(
219219
client.getApplicationType() != null ? client.getApplicationType() : ApplicationType.WEB);
220220

221221
if (StringUtils.isNotBlank(client.getSectorIdentifierUri())) {
222222
client.setSectorIdentifierUri(client.getSectorIdentifierUri());
223223
}
224224

225-
logger.debug("client.getResponseTypes():{}, client.getGrantTypes():{}", client.getResponseTypes(),
225+
logger.trace("client.getApplicationType():{}, client.getResponseTypes():{}, client.getGrantTypes():{}",client.getApplicationType(), client.getResponseTypes(),
226226
client.getGrantTypes());
227227
Set<ResponseType> responseTypeSet = client.getResponseTypes() != null
228228
? new HashSet<>(Arrays.asList(client.getResponseTypes()))
@@ -255,7 +255,9 @@ public Client setClientDefaultAttributes(Client client, boolean update) {
255255

256256
responseTypeSet.retainAll(appConfiguration.getAllResponseTypesSupported());
257257
grantTypeSet.retainAll(appConfiguration.getGrantTypesSupported());
258-
258+
logger.trace("After setting - client.getResponseTypes():{}, client.getGrantTypes():{}", client.getResponseTypes(),
259+
client.getGrantTypes());
260+
259261
Set<GrantType> dynamicGrantTypeDefault = appConfiguration.getDynamicGrantTypeDefault();
260262
grantTypeSet.retainAll(dynamicGrantTypeDefault);
261263

@@ -267,21 +269,21 @@ public Client setClientDefaultAttributes(Client client, boolean update) {
267269
client.setGrantTypes(grantTypeSet.toArray(new GrantType[0]));
268270
}
269271

270-
logger.debug("Set client.getResponseTypes():{}, client.getGrantTypes():{}", client.getResponseTypes(),
272+
logger.trace("Set client.getResponseTypes():{}, client.getGrantTypes():{}", client.getResponseTypes(),
271273
client.getGrantTypes());
272274
List<String> contacts = client.getContacts() != null ? Arrays.asList(client.getContacts()) : null;
273275
if (contacts != null && !contacts.isEmpty()) {
274276
contacts = new ArrayList<>(new HashSet<>(contacts)); // Remove repeated elements
275277
client.setContacts(contacts.toArray(new String[0]));
276278
}
277279

278-
logger.debug("client.getTokenEndpointAuthMethod():{}", client.getTokenEndpointAuthMethod());
280+
logger.trace("client.getTokenEndpointAuthMethod():{}", client.getTokenEndpointAuthMethod());
279281
if (StringUtils.isBlank(client.getTokenEndpointAuthMethod())) {
280282
// If omitted, the default is client_secret_basic
281283
client.setTokenEndpointAuthMethod(AuthenticationMethod.CLIENT_SECRET_BASIC.toString());
282284
}
283285

284-
logger.debug("client.getDefaultAcrValues():{}", client.getDefaultAcrValues());
286+
logger.trace("client.getDefaultAcrValues():{}", client.getDefaultAcrValues());
285287
List<String> defaultAcrValues = client.getDefaultAcrValues() != null
286288
? Arrays.asList(client.getDefaultAcrValues())
287289
: null;
@@ -318,39 +320,16 @@ public Client setClientDefaultAttributes(Client client, boolean update) {
318320
authorizedOrigins = new ArrayList<>(new HashSet<>(authorizedOrigins)); // Remove repeated elements
319321
client.setAuthorizedOrigins(authorizedOrigins.toArray(new String[authorizedOrigins.size()]));
320322
}
321-
322-
List<String> scopes = client.getScopes() != null ? Arrays.asList(client.getScopes()) : null;
323-
if (grantTypeSet.contains(GrantType.RESOURCE_OWNER_PASSWORD_CREDENTIALS)
324-
&& !appConfiguration.getDynamicRegistrationAllowedPasswordGrantScopes().isEmpty()) {
325-
scopes = Lists.newArrayList(scopes);
326-
scopes.retainAll(appConfiguration.getDynamicRegistrationAllowedPasswordGrantScopes());
327-
}
328-
List<String> scopesDn;
329-
if (scopes != null && !scopes.isEmpty()
330-
&& isTrue(appConfiguration.getDynamicRegistrationScopesParamEnabled())) {
331-
List<String> defaultScopes = scopeService.getDefaultScopesDn();
332-
List<String> requestedScopes = scopeService.getScopesDn(scopes);
333-
Set<String> allowedScopes = new HashSet<>();
334-
335-
for (String requestedScope : requestedScopes) {
336-
if (defaultScopes.contains(requestedScope)) {
337-
allowedScopes.add(requestedScope);
338-
}
339-
}
340-
341-
scopesDn = new ArrayList<>(allowedScopes);
342-
client.setScopes(scopesDn.toArray(new String[scopesDn.size()]));
343-
} else {
344-
scopesDn = scopeService.getDefaultScopesDn();
345-
client.setScopes(scopesDn.toArray(new String[scopesDn.size()]));
346-
}
347-
323+
324+
logger.debug("client.getScopes():{}, appConfiguration.getDynamicRegistrationScopesParamEnabled():{}",client.getScopes(), appConfiguration.getDynamicRegistrationScopesParamEnabled());
325+
348326
List<String> claims = client.getClaims() != null ? Arrays.asList(client.getClaims()) : null;
349327
if (claims != null && !claims.isEmpty()) {
350328
List<String> claimsDn = attributeService.getAttributesDn(claims);
351329
client.setClaims(claimsDn.toArray(new String[claimsDn.size()]));
352330
}
353-
331+
logger.debug("client.getClaims():{}, client.getAttributes().getAuthorizedAcrValues():{}",client.getClaims(), client.getAttributes().getAuthorizedAcrValues());
332+
354333
List<String> authorizedAcrValues = client.getAttributes().getAuthorizedAcrValues();
355334
if (authorizedAcrValues != null && !authorizedAcrValues.isEmpty()) {
356335
authorizedAcrValues = new ArrayList<>(new HashSet<>(authorizedAcrValues)); // Remove repeated elements

0 commit comments

Comments
 (0)