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): error handling for agama get and org patch #3028

Merged
merged 1 commit into from
Nov 18, 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
4 changes: 2 additions & 2 deletions jans-config-api/common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
</dependency>

<!-- Others -->
<dependency>
<!--<dependency>
<groupId>com.github.fge</groupId>
<artifactId>json-patch</artifactId>
</dependency>
</dependency> -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
Expand Down
22 changes: 11 additions & 11 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
adminCanEdit:
adminCanAccess:
type: boolean
userCanAccess:
type: boolean
adminCanView:
type: boolean
adminCanAccess:
type: boolean
userCanView:
type: boolean
adminCanView:
type: boolean
userCanEdit:
type: boolean
adminCanEdit:
type: boolean
whitePagesCanView:
type: boolean
baseDn:
Expand Down Expand Up @@ -7528,6 +7528,8 @@ components:
format: int32
displayName:
type: string
tokenBindingSupported:
type: boolean
authenticationMethod:
type: string
enum:
Expand All @@ -7539,8 +7541,6 @@ components:
- tls_client_auth
- self_signed_tls_client_auth
- none
tokenBindingSupported:
type: boolean
baseDn:
type: string
inum:
Expand Down Expand Up @@ -7622,6 +7622,8 @@ components:
idTokenLifetime:
type: integer
format: int32
allowOfflineAccessWithoutConsent:
type: boolean
CustomObjectAttribute:
type: object
properties:
Expand Down Expand Up @@ -8343,6 +8345,8 @@ components:
$ref: '#/components/schemas/EngineConfig'
ssaConfiguration:
$ref: '#/components/schemas/SsaConfiguration'
fapi:
type: boolean
allResponseTypesSupported:
uniqueItems: true
type: array
Expand All @@ -8352,8 +8356,6 @@ components:
- code
- token
- id_token
fapi:
type: boolean
enabledFeatureFlags:
uniqueItems: true
type: array
Expand Down Expand Up @@ -8860,8 +8862,6 @@ components:
type: string
jsFaviconPath:
type: string
organizationTitle:
type: string
baseDn:
type: string
Scope:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ paths:
description: InternalServerError
security:
- oauth2:
- https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.write
- https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.delete
/admin-ui/adminUIRoles/{adminUIRole}:
get:
tags:
Expand Down Expand Up @@ -523,7 +523,7 @@ paths:
description: InternalServerError
security:
- oauth2:
- https://jans.io/oauth/jans-auth-server/config/adminui/user/role.write
- https://jans.io/oauth/jans-auth-server/config/adminui/user/role.delete
/admin-ui/adminUIRolePermissionsMapping/{adminUIRole}:
get:
tags:
Expand Down Expand Up @@ -584,7 +584,7 @@ paths:
description: InternalServerError
security:
- oauth2:
- https://jans.io/oauth/jans-auth-server/config/adminui/user/rolePermissionMapping.write
- https://jans.io/oauth/jans-auth-server/config/adminui/user/rolePermissionMapping.delete
components:
schemas:
LicenseRequest:
Expand Down
5 changes: 0 additions & 5 deletions jans-config-api/plugins/sample/helloworld/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,6 @@
<artifactId>resteasy-jackson2-provider</artifactId>
<version>${resteasy.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-json-p-provider</artifactId>
<version>${resteasy.version}</version>
</dependency>


<!-- Othres -->
Expand Down
4 changes: 2 additions & 2 deletions jans-config-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,11 @@
</dependency>

<!-- Others -->
<dependency>
<!--<dependency>
<groupId>com.github.fge</groupId>
<artifactId>json-patch</artifactId>
<version>1.9</version>
</dependency>
</dependency>-->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ public Response getFlowByName(@PathParam(ApiConstants.QNAME) @NotNull String flo
@Operation(summary = "Create a new agama flow", description = "Create a new agama flow", operationId = "post-agama-flow", tags = {
"Configuration – Agama Flow" }, security = @SecurityRequirement(name = "oauth2", scopes = {
ApiAccessConstants.AGAMA_WRITE_ACCESS }))
@RequestBody(description = "Agama Flow", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = Flow.class), examples = @ExampleObject(name = "Request example" , value = "example/agama/agama.json")))
@RequestBody(description = "Agama Flow", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = Flow.class), examples = @ExampleObject(name = "Request example", value = "example/agama/agama.json")))
@ApiResponses(value = {
@ApiResponse(responseCode = "201", description = "Created", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = Flow.class) , examples = @ExampleObject(name = "Response example" , value = "example/agama/agama.json"))),
@ApiResponse(responseCode = "201", description = "Created", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = Flow.class), examples = @ExampleObject(name = "Response example", value = "example/agama/agama.json"))),
@ApiResponse(responseCode = "401", description = "Unauthorized"),
@ApiResponse(responseCode = "500", description = "InternalServerError") })
@POST
Expand Down Expand Up @@ -146,9 +146,9 @@ public Response createFlow(@Valid Flow flow)
@Operation(summary = "Create a new agama flow from source", description = "Create a new agama flow from source.", operationId = "post-agama-flow-from-source", tags = {
"Configuration – Agama Flow" }, security = @SecurityRequirement(name = "oauth2", scopes = {
ApiAccessConstants.AGAMA_WRITE_ACCESS }))
@RequestBody(description = "Agama Flow", content = @Content(mediaType = MediaType.TEXT_PLAIN, schema = @Schema(implementation = String.class) , examples = @ExampleObject(name = "Request example" , value = "example/agama/test-agama-source.json")))
@RequestBody(description = "Agama Flow", content = @Content(mediaType = MediaType.TEXT_PLAIN, schema = @Schema(implementation = String.class), examples = @ExampleObject(name = "Request example", value = "example/agama/test-agama-source.json")))
@ApiResponses(value = {
@ApiResponse(responseCode = "201", description = "Created", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = Flow.class) , examples = @ExampleObject(name = "Response example" , value = "example/agama/agama.json"))),
@ApiResponse(responseCode = "201", description = "Created", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = Flow.class), examples = @ExampleObject(name = "Response example", value = "example/agama/agama.json"))),
@ApiResponse(responseCode = "400", description = "Bad Request"),
@ApiResponse(responseCode = "401", description = "Unauthorized"),
@ApiResponse(responseCode = "500", description = "InternalServerError") })
Expand Down Expand Up @@ -187,9 +187,9 @@ public Response createFlowFromSource(@PathParam(ApiConstants.QNAME) @NotNull Str
@Operation(summary = "Update agama flow from source file", description = "Update agama flow from source file.", operationId = "put-agama-flow-from-source", tags = {
"Configuration – Agama Flow" }, security = @SecurityRequirement(name = "oauth2", scopes = {
ApiAccessConstants.AGAMA_WRITE_ACCESS }))
@RequestBody(description = "String representing patch-document.", content = @Content(mediaType = MediaType.TEXT_PLAIN, schema = @Schema(implementation = String.class), examples = @ExampleObject(name = "Request example" , value = "example/agama/test-agama-source.json")))
@RequestBody(description = "String representing patch-document.", content = @Content(mediaType = MediaType.TEXT_PLAIN, schema = @Schema(implementation = String.class), examples = @ExampleObject(name = "Request example", value = "example/agama/test-agama-source.json")))
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Ok", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = Flow.class), examples = @ExampleObject(name = "Response example" , value = "example/agama/agama.json"))),
@ApiResponse(responseCode = "200", description = "Ok", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = Flow.class), examples = @ExampleObject(name = "Response example", value = "example/agama/agama.json"))),
@ApiResponse(responseCode = "401", description = "Unauthorized"),
@ApiResponse(responseCode = "404", description = "Not Found"),
@ApiResponse(responseCode = "500", description = "InternalServerError") })
Expand Down Expand Up @@ -223,9 +223,9 @@ public Response updateFlowSource(@PathParam(ApiConstants.QNAME) @NotNull String
@Operation(summary = "Partially modify a Agama Flow", description = "Partially modify a Agama Flow", operationId = "patch-agama-flow", tags = {
"Configuration – Agama Flow" }, security = @SecurityRequirement(name = "oauth2", scopes = {
ApiAccessConstants.AGAMA_WRITE_ACCESS }))
@RequestBody(description = "JsonPatch object", content = @Content(mediaType = MediaType.APPLICATION_JSON_PATCH_JSON, array = @ArraySchema(schema = @Schema(implementation = JsonPatch.class)) , examples = @ExampleObject(name = "Request example" , value = "example/agama/agama-patch.json")))
@RequestBody(description = "JsonPatch object", content = @Content(mediaType = MediaType.APPLICATION_JSON_PATCH_JSON, array = @ArraySchema(schema = @Schema(implementation = JsonPatch.class)), examples = @ExampleObject(name = "Request example", value = "example/agama/agama-patch.json")))
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Patched Agama Flow", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = Flow.class), examples = @ExampleObject(name = "Response example" , value = "example/agama/agama.json"))),
@ApiResponse(responseCode = "200", description = "Patched Agama Flow", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = Flow.class), examples = @ExampleObject(name = "Response example", value = "example/agama/agama.json"))),
@ApiResponse(responseCode = "401", description = "Unauthorized"),
@ApiResponse(responseCode = "404", description = "Not Found"),
@ApiResponse(responseCode = "500", description = "InternalServerError") })
Expand Down Expand Up @@ -397,12 +397,15 @@ private Flow updateMetadata(Flow flow) {
}

private Flow minimize(Flow flow, boolean includeSource) {

if (flow == null) {
return flow;
}
flow.setTranspiled(null);
flow.setTransHash(null);
if (!includeSource) {
flow.setSource(null);
}

return flow;

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class OrganizationResource extends ConfigBaseResource {

@Operation(summary = "Retrieves organization configuration", description = "Retrieves organization configuration", operationId = "get-organization-config", tags = {
"Organization Configuration" }, security = @SecurityRequirement(name = "oauth2", scopes = {
ApiAccessConstants.ORG_CONFIG_READ_ACCESS }))
ApiAccessConstants.ORG_CONFIG_READ_ACCESS }))
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Ok", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = GluuOrganization.class), examples = @ExampleObject(name = "Response json example", value = "example/org/org.json"))),
@ApiResponse(responseCode = "401", description = "Unauthorized"),
Expand All @@ -68,8 +68,15 @@ public Response getOrganization() {
public Response patchOrganization(@NotNull String pathString) throws JsonPatchException, IOException {
logger.trace("Organization patch request - pathString:{} ", pathString);
GluuOrganization organization = organizationService.getOrganization();
organization = Jackson.applyPatch(pathString, organization);
organizationService.updateOrganization(organization);
try {

organization = Jackson.applyPatch(pathString, organization);
organizationService.updateOrganization(organization);

} catch (Exception ex) {
logger.error("Error while patching Organization details", ex);
thorwInternalServerException(ex);
}
return Response.ok(organizationService.getOrganization()).build();
}

Expand Down