Skip to content

Commit 21dd6e5

Browse files
authored
fix(config-api): error handling for agama get and org patch (#3028)
1 parent 6681c45 commit 21dd6e5

File tree

7 files changed

+40
-35
lines changed

7 files changed

+40
-35
lines changed

jans-config-api/common/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@
3434
</dependency>
3535

3636
<!-- Others -->
37-
<dependency>
37+
<!--<dependency>
3838
<groupId>com.github.fge</groupId>
3939
<artifactId>json-patch</artifactId>
40-
</dependency>
40+
</dependency> -->
4141
<dependency>
4242
<groupId>javax.servlet</groupId>
4343
<artifactId>javax.servlet-api</artifactId>

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

+11-11
Original file line numberDiff line numberDiff line change
@@ -7178,18 +7178,18 @@ components:
71787178
$ref: '#/components/schemas/AttributeValidation'
71797179
tooltip:
71807180
type: string
7181-
adminCanEdit:
7181+
adminCanAccess:
71827182
type: boolean
71837183
userCanAccess:
71847184
type: boolean
7185-
adminCanView:
7186-
type: boolean
7187-
adminCanAccess:
7188-
type: boolean
71897185
userCanView:
71907186
type: boolean
7187+
adminCanView:
7188+
type: boolean
71917189
userCanEdit:
71927190
type: boolean
7191+
adminCanEdit:
7192+
type: boolean
71937193
whitePagesCanView:
71947194
type: boolean
71957195
baseDn:
@@ -7528,6 +7528,8 @@ components:
75287528
format: int32
75297529
displayName:
75307530
type: string
7531+
tokenBindingSupported:
7532+
type: boolean
75317533
authenticationMethod:
75327534
type: string
75337535
enum:
@@ -7539,8 +7541,6 @@ components:
75397541
- tls_client_auth
75407542
- self_signed_tls_client_auth
75417543
- none
7542-
tokenBindingSupported:
7543-
type: boolean
75447544
baseDn:
75457545
type: string
75467546
inum:
@@ -7622,6 +7622,8 @@ components:
76227622
idTokenLifetime:
76237623
type: integer
76247624
format: int32
7625+
allowOfflineAccessWithoutConsent:
7626+
type: boolean
76257627
CustomObjectAttribute:
76267628
type: object
76277629
properties:
@@ -8343,6 +8345,8 @@ components:
83438345
$ref: '#/components/schemas/EngineConfig'
83448346
ssaConfiguration:
83458347
$ref: '#/components/schemas/SsaConfiguration'
8348+
fapi:
8349+
type: boolean
83468350
allResponseTypesSupported:
83478351
uniqueItems: true
83488352
type: array
@@ -8352,8 +8356,6 @@ components:
83528356
- code
83538357
- token
83548358
- id_token
8355-
fapi:
8356-
type: boolean
83578359
enabledFeatureFlags:
83588360
uniqueItems: true
83598361
type: array
@@ -8860,8 +8862,6 @@ components:
88608862
type: string
88618863
jsFaviconPath:
88628864
type: string
8863-
organizationTitle:
8864-
type: string
88658865
baseDn:
88668866
type: string
88678867
Scope:

jans-config-api/plugins/docs/jans-admin-ui-plugin-swagger.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ paths:
462462
description: InternalServerError
463463
security:
464464
- oauth2:
465-
- https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.write
465+
- https://jans.io/oauth/jans-auth-server/config/adminui/user/permission.delete
466466
/admin-ui/adminUIRoles/{adminUIRole}:
467467
get:
468468
tags:
@@ -523,7 +523,7 @@ paths:
523523
description: InternalServerError
524524
security:
525525
- oauth2:
526-
- https://jans.io/oauth/jans-auth-server/config/adminui/user/role.write
526+
- https://jans.io/oauth/jans-auth-server/config/adminui/user/role.delete
527527
/admin-ui/adminUIRolePermissionsMapping/{adminUIRole}:
528528
get:
529529
tags:
@@ -584,7 +584,7 @@ paths:
584584
description: InternalServerError
585585
security:
586586
- oauth2:
587-
- https://jans.io/oauth/jans-auth-server/config/adminui/user/rolePermissionMapping.write
587+
- https://jans.io/oauth/jans-auth-server/config/adminui/user/rolePermissionMapping.delete
588588
components:
589589
schemas:
590590
LicenseRequest:

jans-config-api/plugins/sample/helloworld/pom.xml

-5
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,6 @@
126126
<artifactId>resteasy-jackson2-provider</artifactId>
127127
<version>${resteasy.version}</version>
128128
</dependency>
129-
<dependency>
130-
<groupId>org.jboss.resteasy</groupId>
131-
<artifactId>resteasy-json-p-provider</artifactId>
132-
<version>${resteasy.version}</version>
133-
</dependency>
134129

135130

136131
<!-- Othres -->

jans-config-api/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -372,11 +372,11 @@
372372
</dependency>
373373

374374
<!-- Others -->
375-
<dependency>
375+
<!--<dependency>
376376
<groupId>com.github.fge</groupId>
377377
<artifactId>json-patch</artifactId>
378378
<version>1.9</version>
379-
</dependency>
379+
</dependency>-->
380380
<dependency>
381381
<groupId>org.apache.commons</groupId>
382382
<artifactId>commons-collections4</artifactId>

jans-config-api/server/src/main/java/io/jans/configapi/rest/resource/auth/AgamaResource.java

+12-9
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ public Response getFlowByName(@PathParam(ApiConstants.QNAME) @NotNull String flo
115115
@Operation(summary = "Create a new agama flow", description = "Create a new agama flow", operationId = "post-agama-flow", tags = {
116116
"Configuration – Agama Flow" }, security = @SecurityRequirement(name = "oauth2", scopes = {
117117
ApiAccessConstants.AGAMA_WRITE_ACCESS }))
118-
@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")))
118+
@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")))
119119
@ApiResponses(value = {
120-
@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"))),
120+
@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"))),
121121
@ApiResponse(responseCode = "401", description = "Unauthorized"),
122122
@ApiResponse(responseCode = "500", description = "InternalServerError") })
123123
@POST
@@ -146,9 +146,9 @@ public Response createFlow(@Valid Flow flow)
146146
@Operation(summary = "Create a new agama flow from source", description = "Create a new agama flow from source.", operationId = "post-agama-flow-from-source", tags = {
147147
"Configuration – Agama Flow" }, security = @SecurityRequirement(name = "oauth2", scopes = {
148148
ApiAccessConstants.AGAMA_WRITE_ACCESS }))
149-
@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")))
149+
@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")))
150150
@ApiResponses(value = {
151-
@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"))),
151+
@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"))),
152152
@ApiResponse(responseCode = "400", description = "Bad Request"),
153153
@ApiResponse(responseCode = "401", description = "Unauthorized"),
154154
@ApiResponse(responseCode = "500", description = "InternalServerError") })
@@ -187,9 +187,9 @@ public Response createFlowFromSource(@PathParam(ApiConstants.QNAME) @NotNull Str
187187
@Operation(summary = "Update agama flow from source file", description = "Update agama flow from source file.", operationId = "put-agama-flow-from-source", tags = {
188188
"Configuration – Agama Flow" }, security = @SecurityRequirement(name = "oauth2", scopes = {
189189
ApiAccessConstants.AGAMA_WRITE_ACCESS }))
190-
@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")))
190+
@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")))
191191
@ApiResponses(value = {
192-
@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"))),
192+
@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"))),
193193
@ApiResponse(responseCode = "401", description = "Unauthorized"),
194194
@ApiResponse(responseCode = "404", description = "Not Found"),
195195
@ApiResponse(responseCode = "500", description = "InternalServerError") })
@@ -223,9 +223,9 @@ public Response updateFlowSource(@PathParam(ApiConstants.QNAME) @NotNull String
223223
@Operation(summary = "Partially modify a Agama Flow", description = "Partially modify a Agama Flow", operationId = "patch-agama-flow", tags = {
224224
"Configuration – Agama Flow" }, security = @SecurityRequirement(name = "oauth2", scopes = {
225225
ApiAccessConstants.AGAMA_WRITE_ACCESS }))
226-
@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")))
226+
@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")))
227227
@ApiResponses(value = {
228-
@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"))),
228+
@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"))),
229229
@ApiResponse(responseCode = "401", description = "Unauthorized"),
230230
@ApiResponse(responseCode = "404", description = "Not Found"),
231231
@ApiResponse(responseCode = "500", description = "InternalServerError") })
@@ -397,12 +397,15 @@ private Flow updateMetadata(Flow flow) {
397397
}
398398

399399
private Flow minimize(Flow flow, boolean includeSource) {
400-
400+
if (flow == null) {
401+
return flow;
402+
}
401403
flow.setTranspiled(null);
402404
flow.setTransHash(null);
403405
if (!includeSource) {
404406
flow.setSource(null);
405407
}
408+
406409
return flow;
407410

408411
}

jans-config-api/server/src/main/java/io/jans/configapi/rest/resource/auth/OrganizationResource.java

+10-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class OrganizationResource extends ConfigBaseResource {
4343

4444
@Operation(summary = "Retrieves organization configuration", description = "Retrieves organization configuration", operationId = "get-organization-config", tags = {
4545
"Organization Configuration" }, security = @SecurityRequirement(name = "oauth2", scopes = {
46-
ApiAccessConstants.ORG_CONFIG_READ_ACCESS }))
46+
ApiAccessConstants.ORG_CONFIG_READ_ACCESS }))
4747
@ApiResponses(value = {
4848
@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"))),
4949
@ApiResponse(responseCode = "401", description = "Unauthorized"),
@@ -68,8 +68,15 @@ public Response getOrganization() {
6868
public Response patchOrganization(@NotNull String pathString) throws JsonPatchException, IOException {
6969
logger.trace("Organization patch request - pathString:{} ", pathString);
7070
GluuOrganization organization = organizationService.getOrganization();
71-
organization = Jackson.applyPatch(pathString, organization);
72-
organizationService.updateOrganization(organization);
71+
try {
72+
73+
organization = Jackson.applyPatch(pathString, organization);
74+
organizationService.updateOrganization(organization);
75+
76+
} catch (Exception ex) {
77+
logger.error("Error while patching Organization details", ex);
78+
thorwInternalServerException(ex);
79+
}
7380
return Response.ok(organizationService.getOrganization()).build();
7481
}
7582

0 commit comments

Comments
 (0)