Skip to content

Commit 6b61556

Browse files
pujavsjgomer2001nynymikeiromliyuremm
authored
fix(config-api): swagger update for enum and error handling (#2934)
* fix(config-api): client creation exception * fix(config-api): client creations exception * fix(config-api): issues fixed 2743, 2755 and 2689 * fix(config-api): change to use fido2 app config model * fix(config-api): change to use fido2 app config model * docs(config-api): swagger fix for script enum * fix: avoid NPE when configuration is missing #2857 (#2863) * Initial commit IDM, IAG, 2FA Portal (#2873) initial commit * fix(image): multiple dynamic scopes created when using 2 replicas (#2871) * feat: for file based scripts check both script revision and file (#2878) modification time #2877 Co-authored-by: Yuriy Movchan <Yuriy.Movchan@gmail.com> * feat(jans-auth-server): added token exchange support to client #2518 (#2855) And added native sso http test. * feat: ssa revoke endpoint (#2865) * docs: update ubuntu.md (#2870) * docs: Helm install on GKE, AKS, and EKS (#2777) * docs: Helm install on GKE * docs: fix to yaml * docs: remove unnecessary sudo, kubeconfig flag and create namespace Creating namespace initially makes more sense. Since it can be used during the database installation. Also removing sudo makes kubeconfig flag unnecessary too * docs: fix file name * docs: fix * docs: fix indentation fix indentation so that copying is simpler * docs: rephrase * docs: Helm install on EKS docs: Helm install on EKS * fix: typo * docs: EKS fix * docs: fix mistake in GKE too * docs: Helm install on AKS * docs: fix * fix(jans-auth-server): fix language metadata format (#2883) * fix(jans-auth-server): fix language metadata format * fix(jans-auth-server): fix language metadata format * Initial checkin: RBAC, central authz (#2884) Starting point for these topics * fix(config-api): swagger update for enum and error handling Co-authored-by: Jose <bonustrack310@gmail.com> Co-authored-by: Mike Schwartz <mike@gluu.org> Co-authored-by: Isman Firmansyah <iromli@users.noreply.github.com> Co-authored-by: Yuriy M <95305560+yuremm@users.noreply.github.com> Co-authored-by: Yuriy Movchan <Yuriy.Movchan@gmail.com> Co-authored-by: YuriyZ <yzabrovarniy@gmail.com> Co-authored-by: Milton Ch <86965029+Milton-Ch@users.noreply.github.com> Co-authored-by: mzico <mohib@gluu.org> Co-authored-by: misba7 <amromisba7@gmail.com> Co-authored-by: Javier Rojas <javier.rojas.blum@gmail.com>
1 parent 056411c commit 6b61556

File tree

4 files changed

+83
-54
lines changed

4 files changed

+83
-54
lines changed

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

+22-12
Original file line numberDiff line numberDiff line change
@@ -7178,18 +7178,18 @@ components:
71787178
$ref: '#/components/schemas/AttributeValidation'
71797179
tooltip:
71807180
type: string
7181+
adminCanAccess:
7182+
type: boolean
7183+
userCanAccess:
7184+
type: boolean
71817185
adminCanEdit:
71827186
type: boolean
71837187
userCanView:
71847188
type: boolean
7185-
adminCanAccess:
7186-
type: boolean
71877189
userCanEdit:
71887190
type: boolean
71897191
adminCanView:
71907192
type: boolean
7191-
userCanAccess:
7192-
type: boolean
71937193
whitePagesCanView:
71947194
type: boolean
71957195
baseDn:
@@ -7370,14 +7370,24 @@ components:
73707370
idTokenTokenBindingCnf:
73717371
type: string
73727372
clientName:
7373-
$ref: '#/components/schemas/LocalizedString'
7373+
type: string
73747374
logoUri:
7375-
$ref: '#/components/schemas/LocalizedString'
7375+
type: string
73767376
clientUri:
7377-
$ref: '#/components/schemas/LocalizedString'
7377+
type: string
73787378
policyUri:
7379-
$ref: '#/components/schemas/LocalizedString'
7379+
type: string
73807380
tosUri:
7381+
type: string
7382+
clientNameLocalized:
7383+
$ref: '#/components/schemas/LocalizedString'
7384+
logoUriLocalized:
7385+
$ref: '#/components/schemas/LocalizedString'
7386+
clientUriLocalized:
7387+
$ref: '#/components/schemas/LocalizedString'
7388+
policyUriLocalized:
7389+
$ref: '#/components/schemas/LocalizedString'
7390+
tosUriLocalized:
73817391
$ref: '#/components/schemas/LocalizedString'
73827392
jwksUri:
73837393
type: string
@@ -7518,6 +7528,8 @@ components:
75187528
format: int32
75197529
displayName:
75207530
type: string
7531+
tokenBindingSupported:
7532+
type: boolean
75217533
authenticationMethod:
75227534
type: string
75237535
enum:
@@ -7529,8 +7541,6 @@ components:
75297541
- tls_client_auth
75307542
- self_signed_tls_client_auth
75317543
- none
7532-
tokenBindingSupported:
7533-
type: boolean
75347544
baseDn:
75357545
type: string
75367546
inum:
@@ -8333,8 +8343,6 @@ components:
83338343
$ref: '#/components/schemas/EngineConfig'
83348344
ssaConfiguration:
83358345
$ref: '#/components/schemas/SsaConfiguration'
8336-
fapi:
8337-
type: boolean
83388346
enabledFeatureFlags:
83398347
uniqueItems: true
83408348
type: array
@@ -8371,6 +8379,8 @@ components:
83718379
- code
83728380
- token
83738381
- id_token
8382+
fapi:
8383+
type: boolean
83748384
AuthenticationFilter:
83758385
required:
83768386
- baseDn

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

+28-31
Original file line numberDiff line numberDiff line change
@@ -4441,9 +4441,6 @@ components:
44414441
description: LDAP custom object class list for dynamic person enrolment.
44424442
items:
44434443
type: string
4444-
enum:
4445-
- gluuCustomPerson
4446-
- gluuPerson
44474444
persistIdTokenInLdap:
44484445
type: boolean
44494446
description: Specifies whether to persist id_token into LDAP (otherwise saves into cache).
@@ -5020,42 +5017,42 @@ components:
50205017
type: string
50215018
description: Data Type of attribute.
50225019
enum:
5023-
- STRING
5024-
- NUMERIC
5025-
- BOOLEAN
5026-
- BINARY
5027-
- CERTIFICATE
5028-
- DATE
5029-
- JSON
5020+
- string
5021+
- numeric
5022+
- boolean
5023+
- binary
5024+
- certificate
5025+
- date
5026+
- json
50305027
editType:
50315028
type: array
50325029
description: GluuUserRole
50335030
items:
50345031
type: string
50355032
enum:
5036-
- ADMIN
5037-
- OWNER
5038-
- MANAGER
5039-
- USER
5040-
- WHITEPAGES
5033+
- admin
5034+
- owner
5035+
- manager
5036+
- user
5037+
- whitepages
50415038
viewType:
50425039
type: array
50435040
description: GluuUserRole
50445041
items:
50455042
type: string
50465043
enum:
5047-
- ADMIN
5048-
- OWNER
5049-
- MANAGER
5050-
- USER
5051-
- WHITEPAGES
5044+
- admin
5045+
- owner
5046+
- manager
5047+
- user
5048+
- whitepages
50525049
usageType:
50535050
type: array
50545051
description: GluuAttributeUsageType
50555052
items:
50565053
type: string
50575054
enum:
5058-
- OPENID
5055+
- openid
50595056
claimName:
50605057
type: string
50615058
seeAlso:
@@ -5064,10 +5061,10 @@ components:
50645061
type: string
50655062
description: Attrubute status
50665063
enum:
5067-
- ACTIVE
5068-
- INACTIVE
5069-
- EXPIRED
5070-
- REGISTER
5064+
- active
5065+
- inactive
5066+
- expired
5067+
- register
50715068
saml1Uri:
50725069
type: string
50735070
saml2Uri:
@@ -5224,10 +5221,10 @@ components:
52245221
description: Scope creator type
52255222
type: string
52265223
enum:
5227-
- NONE
5228-
- CLIENT
5229-
- USER
5230-
- AUTO
5224+
- none
5225+
- client
5226+
- user
5227+
- auto
52315228
creationDate:
52325229
description: Scope creation date time.
52335230
type: string
@@ -7434,8 +7431,8 @@ components:
74347431
description: Session status
74357432
type: string
74367433
enum:
7437-
- AUTHENTICATED
7438-
- UNAUTHENTICATED
7434+
- authenticated
7435+
- unauthenticated
74397436
sessionState:
74407437
description: state of session.
74417438
type: string

jans-config-api/plugins/user-mgt-plugin/src/main/java/io/jans/configapi/plugin/mgt/rest/UserResource.java

+11-7
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ private class UserPagedResult extends PagedResult<CustomUser>{};
7474
"Configuration – User Management" }, security = @SecurityRequirement(name = "oauth2", scopes = {
7575
ApiAccessConstants.USER_READ_ACCESS }))
7676
@ApiResponses(value = {
77-
@ApiResponse(responseCode = "200", description = "Ok", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = UserPagedResult.class) , examples = @ExampleObject(name = "Response json example", value = "example/user/user-all.json"))),
77+
@ApiResponse(responseCode = "200", description = "Ok", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = UserPagedResult.class), examples = @ExampleObject(name = "Response json example", value = "example/user/user-all.json"))),
7878
@ApiResponse(responseCode = "401", description = "Unauthorized"),
7979
@ApiResponse(responseCode = "500", description = "InternalServerError") })
8080
@GET
@@ -101,7 +101,7 @@ public Response getUsers(
101101
"Configuration – User Management" }, security = @SecurityRequirement(name = "oauth2", scopes = {
102102
ApiAccessConstants.USER_READ_ACCESS }))
103103
@ApiResponses(value = {
104-
@ApiResponse(responseCode = "200", description = "Ok", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = CustomUser.class, description = "CustomUser identified by inum") , examples = @ExampleObject(name = "Response json example", value = "example/user/user.json"))),
104+
@ApiResponse(responseCode = "200", description = "Ok", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = CustomUser.class, description = "CustomUser identified by inum"), examples = @ExampleObject(name = "Response json example", value = "example/user/user.json"))),
105105
@ApiResponse(responseCode = "401", description = "Unauthorized"),
106106
@ApiResponse(responseCode = "404", description = "Not Found"),
107107
@ApiResponse(responseCode = "500", description = "InternalServerError") })
@@ -196,9 +196,13 @@ public Response updateUser(@Valid CustomUser customUser)
196196
List<String> excludeAttributes = List.of(USER_PWD);
197197
checkMissingAttributes(user, excludeAttributes);
198198
ignoreCustomObjectClassesForNonLDAP(user);
199-
200-
user = userMgmtSrv.updateUser(user);
201-
logger.debug("Updated user:{}", user);
199+
try {
200+
user = userMgmtSrv.updateUser(user);
201+
logger.debug("Updated user:{}", user);
202+
} catch (Exception ex) {
203+
logger.error("Error while updating user", ex);
204+
thorwInternalServerException(ex);
205+
}
202206

203207
// excludedAttributes
204208
user = excludeUserAttributes(user);
@@ -208,6 +212,7 @@ public Response updateUser(@Valid CustomUser customUser)
208212
logger.debug("updated customUser:{}", customUser);
209213

210214
return Response.ok(customUser).build();
215+
211216
}
212217

213218
@Operation(summary = "Patch user properties by Inum", description = "Patch user properties by Inum", operationId = "patch-user-by-inum", tags = {
@@ -270,8 +275,7 @@ public Response deleteUser(@PathParam(ApiConstants.INUM) @NotNull String inum) {
270275
return Response.noContent().build();
271276
}
272277

273-
private UserPagedResult doSearch(SearchRequest searchReq)
274-
throws IllegalAccessException, InvocationTargetException {
278+
private UserPagedResult doSearch(SearchRequest searchReq) throws IllegalAccessException, InvocationTargetException {
275279
if (logger.isDebugEnabled()) {
276280
logger.debug("User search params - searchReq:{} ", escapeLog(searchReq));
277281
}

jans-config-api/shared/src/main/java/io/jans/configapi/core/rest/BaseResource.java

+22-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import org.slf4j.LoggerFactory;
2929

3030
public class BaseResource {
31-
31+
3232
@Inject
3333
Util util;
3434

@@ -37,7 +37,7 @@ public class BaseResource {
3737
public static final String MISSING_ATTRIBUTE_CODE = "OCA001";
3838
public static final String MISSING_ATTRIBUTE_MESSAGE = "A required attribute is missing.";
3939
public static final String TOKEN_DELIMITER = ",";
40-
40+
4141
public static <T> void checkResourceNotNull(T resource, String objectName) {
4242
if (resource == null) {
4343
throw new NotFoundException(getNotFoundError(objectName));
@@ -101,6 +101,13 @@ public static void thorwInternalServerException(String msg) {
101101
throw new InternalServerErrorException(getInternalServerException(msg));
102102
}
103103

104+
public static void thorwInternalServerException(Throwable throwable) {
105+
throwable = findRootError(throwable);
106+
if (throwable != null) {
107+
throw new InternalServerErrorException(getInternalServerException(throwable.getMessage()));
108+
}
109+
}
110+
104111
/**
105112
* @param attributeName
106113
* @return
@@ -173,7 +180,7 @@ protected SearchRequest createSearchRequest(String schemas, String filter, Strin
173180
if (StringUtils.isEmpty(sortOrder) || !sortOrder.equals(SortOrder.DESCENDING.getValue())) {
174181
sortOrder = SortOrder.ASCENDING.getValue();
175182
}
176-
log.debug(" util.getTokens(filter,TOKEN_DELIMITER):{} ", util.getTokens(filter,TOKEN_DELIMITER));
183+
log.debug(" util.getTokens(filter,TOKEN_DELIMITER):{} ", util.getTokens(filter, TOKEN_DELIMITER));
177184
searchRequest.setSchemas(schemas);
178185
searchRequest.setAttributes(attrsList);
179186
searchRequest.setExcludedAttributes(excludedAttrsList);
@@ -183,9 +190,20 @@ protected SearchRequest createSearchRequest(String schemas, String filter, Strin
183190
searchRequest.setStartIndex(startIndex);
184191
searchRequest.setCount(count);
185192
searchRequest.setMaxCount(maximumRecCount);
186-
searchRequest.setFilterAssertionValue(util.getTokens(filter,TOKEN_DELIMITER));
193+
searchRequest.setFilterAssertionValue(util.getTokens(filter, TOKEN_DELIMITER));
187194
return searchRequest;
188195

189196
}
190197

198+
public static Throwable findRootError(Throwable throwable) {
199+
if (throwable == null) {
200+
return throwable;
201+
}
202+
Throwable rootCause = throwable;
203+
while (rootCause.getCause() != null && rootCause.getCause() != rootCause) {
204+
rootCause = rootCause.getCause();
205+
}
206+
return rootCause;
207+
}
208+
191209
}

0 commit comments

Comments
 (0)