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): swagger update for enum and error handling #2934

Merged
merged 21 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
d071713
fix(config-api): client creation exception
pujavs Nov 2, 2022
9b339d9
Merge branch 'main' of https://github.com/JanssenProject/jans into ja…
pujavs Nov 2, 2022
10bcd90
fix(config-api): client creations exception
pujavs Nov 2, 2022
2b3982b
Merge branch 'main' of https://github.com/JanssenProject/jans into ja…
pujavs Nov 3, 2022
40f5482
fix(config-api): issues fixed 2743, 2755 and 2689
pujavs Nov 3, 2022
88251e3
fix(config-api): change to use fido2 app config model
pujavs Nov 3, 2022
118249f
fix(config-api): change to use fido2 app config model
pujavs Nov 3, 2022
409f027
Merge branch 'main' of https://github.com/JanssenProject/jans into ja…
pujavs Nov 4, 2022
4cd9f57
docs(config-api): swagger fix for script enum
pujavs Nov 4, 2022
007b3ec
fix: avoid NPE when configuration is missing #2857 (#2863)
jgomer2001 Nov 4, 2022
7641521
Initial commit IDM, IAG, 2FA Portal (#2873)
nynymike Nov 7, 2022
6dd1537
fix(image): multiple dynamic scopes created when using 2 replicas (#2…
iromli Nov 7, 2022
8f150a6
feat: for file based scripts check both script revision and file (#2878)
yuremm Nov 7, 2022
04221b6
feat(jans-auth-server): added token exchange support to client #2518 …
yuriyz Nov 7, 2022
41d4916
feat: ssa revoke endpoint (#2865)
Milton-Ch Nov 7, 2022
8217a99
docs: update ubuntu.md (#2870)
mzico Nov 7, 2022
44a5410
docs: Helm install on GKE, AKS, and EKS (#2777)
misba7 Nov 7, 2022
c947524
fix(jans-auth-server): fix language metadata format (#2883)
qbert2k Nov 7, 2022
8c107c0
Initial checkin: RBAC, central authz (#2884)
nynymike Nov 8, 2022
d352131
Merge branch 'main' of https://github.com/JanssenProject/jans into ja…
pujavs Nov 8, 2022
cf23694
fix(config-api): swagger update for enum and error handling
pujavs Nov 8, 2022
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
34 changes: 22 additions & 12 deletions jans-config-api/docs/jans-config-api-swagger-auto.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7178,18 +7178,18 @@ components:
$ref: '#/components/schemas/AttributeValidation'
tooltip:
type: string
adminCanAccess:
type: boolean
userCanAccess:
type: boolean
adminCanEdit:
type: boolean
userCanView:
type: boolean
adminCanAccess:
type: boolean
userCanEdit:
type: boolean
adminCanView:
type: boolean
userCanAccess:
type: boolean
whitePagesCanView:
type: boolean
baseDn:
Expand Down Expand Up @@ -7370,14 +7370,24 @@ components:
idTokenTokenBindingCnf:
type: string
clientName:
$ref: '#/components/schemas/LocalizedString'
type: string
logoUri:
$ref: '#/components/schemas/LocalizedString'
type: string
clientUri:
$ref: '#/components/schemas/LocalizedString'
type: string
policyUri:
$ref: '#/components/schemas/LocalizedString'
type: string
tosUri:
type: string
clientNameLocalized:
$ref: '#/components/schemas/LocalizedString'
logoUriLocalized:
$ref: '#/components/schemas/LocalizedString'
clientUriLocalized:
$ref: '#/components/schemas/LocalizedString'
policyUriLocalized:
$ref: '#/components/schemas/LocalizedString'
tosUriLocalized:
$ref: '#/components/schemas/LocalizedString'
jwksUri:
type: string
Expand Down Expand Up @@ -7518,6 +7528,8 @@ components:
format: int32
displayName:
type: string
tokenBindingSupported:
type: boolean
authenticationMethod:
type: string
enum:
Expand All @@ -7529,8 +7541,6 @@ components:
- tls_client_auth
- self_signed_tls_client_auth
- none
tokenBindingSupported:
type: boolean
baseDn:
type: string
inum:
Expand Down Expand Up @@ -8333,8 +8343,6 @@ components:
$ref: '#/components/schemas/EngineConfig'
ssaConfiguration:
$ref: '#/components/schemas/SsaConfiguration'
fapi:
type: boolean
enabledFeatureFlags:
uniqueItems: true
type: array
Expand Down Expand Up @@ -8371,6 +8379,8 @@ components:
- code
- token
- id_token
fapi:
type: boolean
AuthenticationFilter:
required:
- baseDn
Expand Down
59 changes: 28 additions & 31 deletions jans-config-api/docs/jans-config-api-swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4441,9 +4441,6 @@ components:
description: LDAP custom object class list for dynamic person enrolment.
items:
type: string
enum:
- gluuCustomPerson
- gluuPerson
persistIdTokenInLdap:
type: boolean
description: Specifies whether to persist id_token into LDAP (otherwise saves into cache).
Expand Down Expand Up @@ -5020,42 +5017,42 @@ components:
type: string
description: Data Type of attribute.
enum:
- STRING
- NUMERIC
- BOOLEAN
- BINARY
- CERTIFICATE
- DATE
- JSON
- string
- numeric
- boolean
- binary
- certificate
- date
- json
editType:
type: array
description: GluuUserRole
items:
type: string
enum:
- ADMIN
- OWNER
- MANAGER
- USER
- WHITEPAGES
- admin
- owner
- manager
- user
- whitepages
viewType:
type: array
description: GluuUserRole
items:
type: string
enum:
- ADMIN
- OWNER
- MANAGER
- USER
- WHITEPAGES
- admin
- owner
- manager
- user
- whitepages
usageType:
type: array
description: GluuAttributeUsageType
items:
type: string
enum:
- OPENID
- openid
claimName:
type: string
seeAlso:
Expand All @@ -5064,10 +5061,10 @@ components:
type: string
description: Attrubute status
enum:
- ACTIVE
- INACTIVE
- EXPIRED
- REGISTER
- active
- inactive
- expired
- register
saml1Uri:
type: string
saml2Uri:
Expand Down Expand Up @@ -5224,10 +5221,10 @@ components:
description: Scope creator type
type: string
enum:
- NONE
- CLIENT
- USER
- AUTO
- none
- client
- user
- auto
creationDate:
description: Scope creation date time.
type: string
Expand Down Expand Up @@ -7434,8 +7431,8 @@ components:
description: Session status
type: string
enum:
- AUTHENTICATED
- UNAUTHENTICATED
- authenticated
- unauthenticated
sessionState:
description: state of session.
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private class UserPagedResult extends PagedResult<CustomUser>{};
"Configuration – User Management" }, security = @SecurityRequirement(name = "oauth2", scopes = {
ApiAccessConstants.USER_READ_ACCESS }))
@ApiResponses(value = {
@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"))),
@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"))),
@ApiResponse(responseCode = "401", description = "Unauthorized"),
@ApiResponse(responseCode = "500", description = "InternalServerError") })
@GET
Expand All @@ -101,7 +101,7 @@ public Response getUsers(
"Configuration – User Management" }, security = @SecurityRequirement(name = "oauth2", scopes = {
ApiAccessConstants.USER_READ_ACCESS }))
@ApiResponses(value = {
@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"))),
@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"))),
@ApiResponse(responseCode = "401", description = "Unauthorized"),
@ApiResponse(responseCode = "404", description = "Not Found"),
@ApiResponse(responseCode = "500", description = "InternalServerError") })
Expand Down Expand Up @@ -196,9 +196,13 @@ public Response updateUser(@Valid CustomUser customUser)
List<String> excludeAttributes = List.of(USER_PWD);
checkMissingAttributes(user, excludeAttributes);
ignoreCustomObjectClassesForNonLDAP(user);

user = userMgmtSrv.updateUser(user);
logger.debug("Updated user:{}", user);
try {
user = userMgmtSrv.updateUser(user);
logger.debug("Updated user:{}", user);
} catch (Exception ex) {
logger.error("Error while updating user", ex);
thorwInternalServerException(ex);
}

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

return Response.ok(customUser).build();

}

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

private UserPagedResult doSearch(SearchRequest searchReq)
throws IllegalAccessException, InvocationTargetException {
private UserPagedResult doSearch(SearchRequest searchReq) throws IllegalAccessException, InvocationTargetException {
if (logger.isDebugEnabled()) {
logger.debug("User search params - searchReq:{} ", escapeLog(searchReq));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.slf4j.LoggerFactory;

public class BaseResource {

@Inject
Util util;

Expand All @@ -37,7 +37,7 @@ public class BaseResource {
public static final String MISSING_ATTRIBUTE_CODE = "OCA001";
public static final String MISSING_ATTRIBUTE_MESSAGE = "A required attribute is missing.";
public static final String TOKEN_DELIMITER = ",";

public static <T> void checkResourceNotNull(T resource, String objectName) {
if (resource == null) {
throw new NotFoundException(getNotFoundError(objectName));
Expand Down Expand Up @@ -101,6 +101,13 @@ public static void thorwInternalServerException(String msg) {
throw new InternalServerErrorException(getInternalServerException(msg));
}

public static void thorwInternalServerException(Throwable throwable) {
throwable = findRootError(throwable);
if (throwable != null) {
throw new InternalServerErrorException(getInternalServerException(throwable.getMessage()));
}
}

/**
* @param attributeName
* @return
Expand Down Expand Up @@ -173,7 +180,7 @@ protected SearchRequest createSearchRequest(String schemas, String filter, Strin
if (StringUtils.isEmpty(sortOrder) || !sortOrder.equals(SortOrder.DESCENDING.getValue())) {
sortOrder = SortOrder.ASCENDING.getValue();
}
log.debug(" util.getTokens(filter,TOKEN_DELIMITER):{} ", util.getTokens(filter,TOKEN_DELIMITER));
log.debug(" util.getTokens(filter,TOKEN_DELIMITER):{} ", util.getTokens(filter, TOKEN_DELIMITER));
searchRequest.setSchemas(schemas);
searchRequest.setAttributes(attrsList);
searchRequest.setExcludedAttributes(excludedAttrsList);
Expand All @@ -183,9 +190,20 @@ protected SearchRequest createSearchRequest(String schemas, String filter, Strin
searchRequest.setStartIndex(startIndex);
searchRequest.setCount(count);
searchRequest.setMaxCount(maximumRecCount);
searchRequest.setFilterAssertionValue(util.getTokens(filter,TOKEN_DELIMITER));
searchRequest.setFilterAssertionValue(util.getTokens(filter, TOKEN_DELIMITER));
return searchRequest;

}

public static Throwable findRootError(Throwable throwable) {
if (throwable == null) {
return throwable;
}
Throwable rootCause = throwable;
while (rootCause.getCause() != null && rootCause.getCause() != rootCause) {
rootCause = rootCause.getCause();
}
return rootCause;
}

}