From 358c49409a172d6419382dd800a21b845a8cc708 Mon Sep 17 00:00:00 2001 From: Jose Date: Wed, 12 Apr 2023 11:51:23 -0500 Subject: [PATCH] fix(jans-config-api): agama deployment detail endpoint not including all flows IDs (#4565) * fix: ensure all flows are serialized in deployment details #4563 * docs: minor doc updates #4563 --- docs/admin/developer/agama/gama-deployment.md | 20 +++++++++---------- .../src/main/java/io/jans/ads/Deployer.java | 2 +- .../docs/jans-config-api-swagger.yaml | 14 ++++++------- .../auth/AgamaDeploymentsResource.java | 11 ++++++++-- .../service/auth/AgamaDeploymentsService.java | 2 +- 5 files changed, 27 insertions(+), 22 deletions(-) diff --git a/docs/admin/developer/agama/gama-deployment.md b/docs/admin/developer/agama/gama-deployment.md index f937b8f656d..b22a2340562 100644 --- a/docs/admin/developer/agama/gama-deployment.md +++ b/docs/admin/developer/agama/gama-deployment.md @@ -126,11 +126,11 @@ The following tables summarize the available endpoints. All URLs are relative to |Status|200 (OK)| -|Endpoint -> |`/agama-deployment`| +|Endpoint -> |`/agama-deployment/{name}`| |-|-| |Purpose|Retrieve details of a single deployment by name| |Method|GET| -|Query params|`name` - mandatory| +|Path params|`name`| |Sample output|The structure of a deployment is explained below| |Status|200 (deployment task is finished), 204 (task still in course), 404 (project unknown), 400 (a param is missing)| @@ -152,39 +152,39 @@ The following tables summarize the available endpoints. All URLs are relative to |flowsError|A mapping of the errors obtained per flow found in the archive. The keys correspond to qualified names. A `null` value indicates the flow was successfully added|`{ "co.acme.example": "Syntax error on line 4", "io.jans.test": null }`| -|Endpoint -> |`/agama-deployment`| +|Endpoint -> |`/agama-deployment/{name}`| |-|-| |Purpose|Add or replace an ADS project to the server| |Method|POST| -|Query params|`name` (the project's name) - mandatory| +|Path params|`name` (the project's name)| |Body|The binary contents of a `.gama` file; example [here](#sample-file). Ensure to use header `Content-Type: application/zip`| |Output|Textual explanation, e.g. `A deployment task for project XXX has been queued. Use the GET endpoint to poll status`| |Status|202 (the task was created and scheduled for deployment), 409 (there is a task already for this project and it hasn't finished yet), 400 (a param is missing)| -|Endpoint -> |`/agama-deployment/configs`| +|Endpoint -> |`/agama-deployment/configs/{name}`| |-|-| |Purpose|Retrieve the configurations associated to flows that belong to the project of interest. The project must have been already processed fully| |Method|GET| -|Query params|`name` (the project's name) - mandatory| +|Path params|`name` (the project's name)| |Output|A JSON object whose properties are flow names and values correspond to configuration properties defined (JSON objects too)| |Status|200 (successful response), 204 (this project is still in course of deployment), 404 (unknown project), 400 (a param is missing)| -|Endpoint -> |`/agama-deployment/configs`| +|Endpoint -> |`/agama-deployment/configs/{name}`| |-|-| |Purpose|Set or replace the configurations associated to flows that belong to the project of interest. The project must have been already processed fully| |Method|PUT| -|Query params|`name` (the project's name) - mandatory| +|Path params|`name` (the project's name)| |Output|A JSON object whose properties are flow names and values correspond to a boolean indicating the success of the update for the given flow| |Status|200 (successful response), 204 (this project is still in course of deployment), 404 (unknown project), 400 (a param is missing)| -|Endpoint -> |`/agama-deployment`| +|Endpoint -> |`/agama-deployment/{name}`| |-|-| |Purpose|Undeploy an ADS project from the server. Entails removing flows and assets initally supplied| |Method|DELETE| -|Query params|`name` (the project's name) - mandatory| +|Path params|`name` (the project's name)| |Status|204 (scheduled for removal), 409 (the project is being deployed currently), 404 (unknown project), 400 (a param is missing)| ### Endpoints access diff --git a/jans-auth-server/agama/engine/src/main/java/io/jans/ads/Deployer.java b/jans-auth-server/agama/engine/src/main/java/io/jans/ads/Deployer.java index 135e3c96efe..840c1f71a8e 100644 --- a/jans-auth-server/agama/engine/src/main/java/io/jans/ads/Deployer.java +++ b/jans-auth-server/agama/engine/src/main/java/io/jans/ads/Deployer.java @@ -156,7 +156,6 @@ private void deployProject(String dn, String prjId, String name) throws IOExcept if (dd.getError() == null) { projectsFlows.put(prjId, flowIds); - Set libsPaths = transferJarFiles(plib); ZipFile zip = compileAssetsArchive(p, pweb, plib, prjBasepath); byte[] bytes = extractZipFileWithPurge(zip, ASSETS_DIR, projectsBasePaths.get(prjId), projectsLibs.get(prjId)); @@ -164,6 +163,7 @@ private void deployProject(String dn, String prjId, String name) throws IOExcept Set basePaths = Set.of(prjBasepath); projectsBasePaths.put(prjId, basePaths); + Set libsPaths = transferJarFiles(plib); //Update this project's libs paths libsPaths.addAll(computeSourcePaths(plib)); projectsLibs.put(prjId, libsPaths); diff --git a/jans-config-api/docs/jans-config-api-swagger.yaml b/jans-config-api/docs/jans-config-api-swagger.yaml index fcf55b29f80..79ad7201ff0 100644 --- a/jans-config-api/docs/jans-config-api-swagger.yaml +++ b/jans-config-api/docs/jans-config-api-swagger.yaml @@ -7652,8 +7652,6 @@ components: type: string description: type: string - version: - type: string configs: type: object additionalProperties: @@ -7881,20 +7879,20 @@ components: $ref: '#/components/schemas/AttributeValidation' tooltip: type: string - adminCanView: - type: boolean - userCanAccess: - type: boolean adminCanAccess: type: boolean + adminCanView: + type: boolean adminCanEdit: type: boolean - userCanView: + userCanAccess: type: boolean - userCanEdit: + userCanView: type: boolean whitePagesCanView: type: boolean + userCanEdit: + type: boolean baseDn: type: string clientAuthMapSchema: diff --git a/jans-config-api/server/src/main/java/io/jans/configapi/rest/resource/auth/AgamaDeploymentsResource.java b/jans-config-api/server/src/main/java/io/jans/configapi/rest/resource/auth/AgamaDeploymentsResource.java index b9e8874e142..9a3b1957d89 100644 --- a/jans-config-api/server/src/main/java/io/jans/configapi/rest/resource/auth/AgamaDeploymentsResource.java +++ b/jans-config-api/server/src/main/java/io/jans/configapi/rest/resource/auth/AgamaDeploymentsResource.java @@ -95,7 +95,13 @@ public Response getDeployment(@Parameter(description = "Agama project name") @Pa return Response.noContent().build(); d.getDetails().setFolders(null); - return Response.ok(d).build(); + try { + //Use own mapper so flows with no errors are effectively serialized + return Response.ok(mapper.writeValueAsString(d)).build(); + } catch (JsonProcessingException e) { + logger.error(e.getMessage(), e); + return Response.serverError().build(); + } } @@ -171,7 +177,8 @@ public Response undeploy(@Parameter(description = "Agama project name") @PathPar @GET @ProtectedApi(scopes = { ApiAccessConstants.AGAMA_READ_ACCESS }, groupScopes = {ApiAccessConstants.AGAMA_WRITE_ACCESS }, superScopes = { ApiAccessConstants.SUPER_ADMIN_READ_ACCESS }) @Path(ApiConstants.CONFIGS + ApiConstants.NAME_PARAM_PATH) - public Response getConfigs(@Parameter(description = "Agama project name") @PathParam(ApiConstants.NAME) @NotNull String projectName) throws JsonProcessingException { + public Response getConfigs(@Parameter(description = "Agama project name") @PathParam(ApiConstants.NAME) @NotNull String projectName) + throws JsonProcessingException { Pair> pair = projectFlows(projectName); Response resp = pair.getFirst(); diff --git a/jans-config-api/server/src/main/java/io/jans/configapi/service/auth/AgamaDeploymentsService.java b/jans-config-api/server/src/main/java/io/jans/configapi/service/auth/AgamaDeploymentsService.java index 2c7a791b36d..1612fc748ff 100644 --- a/jans-config-api/server/src/main/java/io/jans/configapi/service/auth/AgamaDeploymentsService.java +++ b/jans-config-api/server/src/main/java/io/jans/configapi/service/auth/AgamaDeploymentsService.java @@ -41,7 +41,7 @@ public PagedResult list(int start, int count, int maxCount) { public Deployment getDeployment(String name) { - String[] attrs = new String[]{ "jansStartDate", "jansEndDate", "adsPrjDeplDetails" }; + String[] attrs = new String[]{ "jansId", "jansStartDate", "jansEndDate", "adsPrjDeplDetails" }; logger.info("Looking up project named {}", name); Deployment d = null;