From e7db56c98c64db7cf1deef463b1a02d6ef58d01d Mon Sep 17 00:00:00 2001 From: Tanvi Prasad Date: Wed, 20 Sep 2023 15:10:14 +0530 Subject: [PATCH 1/3] domains field added --- docs/openapi.yaml | 9 ++++++++- .../catalogue/server/mlayer/MlayerServiceImpl.java | 10 +++++++++- .../server/validator/mlayerDatasetSchema.json | 14 ++++++++++++++ ...catalogue-server-v5.0.0.postman_collection.json | 8 ++++---- 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/docs/openapi.yaml b/docs/openapi.yaml index d4bd5ae4..0b764dbf 100644 --- a/docs/openapi.yaml +++ b/docs/openapi.yaml @@ -1809,7 +1809,7 @@ paths: post: tags: - Mlayer Dataset - description: Fetches the dataset details of a particular dataset using dataset_id. Domains, Instance and provider field can be used to filter the datasets. + description: Fetches the dataset details of a particular dataset using dataset_id. Domains, Instance, Tags and provider field can be used to filter the datasets. operationId: get dataset and its resources requestBody: description: 'Based on id dataset and its resources are retrieved. If id field blank or not present then, tags, providers and instance can be used to filter from all datasets.' @@ -4061,6 +4061,11 @@ components: description: provider/providers based on which datasets need to be filtered items: type: string + domains: + type: array + description: data models based on which datasets need to be filtered + items: + type: string example: id: 8b95ab80-2aaf-4636-a65e-7f2563d0d371 @@ -4071,6 +4076,8 @@ components: providers: - bbeacb12-5e54-339d-92e0-d8e063b551a8 - bbeacb12-5e54-339d-92e0-d8e063b551r9 + domains: + - itms successResponseForGettingDatasetResources: type: object diff --git a/src/main/java/iudx/catalogue/server/mlayer/MlayerServiceImpl.java b/src/main/java/iudx/catalogue/server/mlayer/MlayerServiceImpl.java index d1dd2365..0c819473 100644 --- a/src/main/java/iudx/catalogue/server/mlayer/MlayerServiceImpl.java +++ b/src/main/java/iudx/catalogue/server/mlayer/MlayerServiceImpl.java @@ -259,9 +259,17 @@ public MlayerService getMlayerDataset( }); } else if ((requestData.containsKey("tags") || requestData.containsKey("instance") - || requestData.containsKey("providers")) + || requestData.containsKey("providers") + || requestData.containsKey("domains")) && (!requestData.containsKey(ID) || requestData.getString(ID).isBlank())) { + if (requestData.containsKey("domains") && !requestData.getJsonArray("domains").isEmpty()) { + JsonArray domainsArray = requestData.getJsonArray("domains"); + JsonArray tagsArray = requestData.containsKey("tags") + ? requestData.getJsonArray("tags") : new JsonArray(); + tagsArray.addAll(domainsArray); + requestData.put("tags", tagsArray); + } String query = GET_ALL_DATASETS_BY_FIELDS; if (requestData.containsKey(TAGS) && !requestData.getJsonArray(TAGS).isEmpty()) { diff --git a/src/main/resources/iudx/catalogue/server/validator/mlayerDatasetSchema.json b/src/main/resources/iudx/catalogue/server/validator/mlayerDatasetSchema.json index 3550e39f..949c9c64 100644 --- a/src/main/resources/iudx/catalogue/server/validator/mlayerDatasetSchema.json +++ b/src/main/resources/iudx/catalogue/server/validator/mlayerDatasetSchema.json @@ -12,6 +12,9 @@ "instance": "pune", "tags": [ "flood", "env" + ], + "domains": [ + "flood", "env" ] } ], @@ -69,6 +72,17 @@ } ] } + }, + "domains": { + "$id": "#/properties/domains", + "type": "array", + "title": "Mlayer Dataset Domains Schema", + "description": "Domain names are the data models", + "default": "", + "examples": [ + ["flood", "flooding"] + ], + "pattern": "^[a-zA-Z ]*$" } }, "additionalProperties": false diff --git a/src/test/resources/iudx-catalogue-server-v5.0.0.postman_collection.json b/src/test/resources/iudx-catalogue-server-v5.0.0.postman_collection.json index cd612afb..fd7629e7 100644 --- a/src/test/resources/iudx-catalogue-server-v5.0.0.postman_collection.json +++ b/src/test/resources/iudx-catalogue-server-v5.0.0.postman_collection.json @@ -1,9 +1,9 @@ { "info": { - "_postman_id": "7dcd7e34-2e9a-4fd3-97fe-4c41e1f86cca", + "_postman_id": "18907aa9-5b2f-4c81-b526-f18b1e940d1c", "name": "iudx-catalogue-server v5.0.0", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", - "_exporter_id": "17194681" + "_exporter_id": "27217689" }, "item": [ { @@ -14401,7 +14401,7 @@ ], "body": { "mode": "raw", - "raw": "{\r\n \"tags\" : [\"flood\", \"transport\"],\r\n \"instance\" : \"pune\",\r\n \"providers\": [\"bbeacb12-5e54-339d-92e0-d8e063b551a8\"]\r\n}", + "raw": "{\r\n \"tags\" : [\"flood\", \"transport\"],\r\n \"instance\" : \"pune\",\r\n \"providers\": [\"bbeacb12-5e54-339d-92e0-d8e063b551a8\"],\r\n \"domains\" : [\"itms\"]\r\n}", "options": { "raw": { "language": "json" @@ -14454,7 +14454,7 @@ ], "body": { "mode": "raw", - "raw": "{\r\n \"tags\" : [],\r\n \"instance\" : \"\",\r\n \"providers\": []\r\n}", + "raw": "{\r\n \"tags\" : [],\r\n \"instance\" : \"\",\r\n \"providers\": [],\r\n \"domains\": []\r\n}", "options": { "raw": { "language": "json" From 420b3722166d5ed63d1f7aa242e9285dc8383c27 Mon Sep 17 00:00:00 2001 From: pranavrd Date: Wed, 20 Sep 2023 18:29:24 +0530 Subject: [PATCH 2/3] fix: authorization for cos admin --- configs/config-example.json | 5 +- .../server/authenticator/Constants.java | 2 +- .../JwtAuthenticationServiceImpl.java | 26 +++---- .../AuthorizationContextFactory.java | 3 +- .../validator/ValidatorServiceImpl.java | 8 ++- .../authenticator/JwtAuthServiceImplTest.java | 14 ++-- .../server/authenticator/JwtTokenHelper.java | 4 +- .../authenticator/KCAuthServiceImplTest.java | 8 +-- .../AuthorizationContextFactoryTest.java | 2 +- ...ogue-server-v5.0.0.postman_collection.json | 68 ++++++++++++++++++- 10 files changed, 102 insertions(+), 38 deletions(-) diff --git a/configs/config-example.json b/configs/config-example.json index 927d0544..76a9dbaa 100644 --- a/configs/config-example.json +++ b/configs/config-example.json @@ -29,13 +29,12 @@ "bypassAuth": true }, { - "id": "iudx.catalogue.server.authenticator.AuthenticationVerticle", + "id": "iudx.catalogue.server.authenticator.AuthenticationVerticle", "host": "", - "tempCopAudience": "", + "consumerHost": "", "verticleInstances": 1, "authServerHost": "", "issuer": "", - "tempCopIssuer": "", "jwtIgnoreExpiry": true }, { diff --git a/src/main/java/iudx/catalogue/server/authenticator/Constants.java b/src/main/java/iudx/catalogue/server/authenticator/Constants.java index 8e6ef1d8..89566615 100644 --- a/src/main/java/iudx/catalogue/server/authenticator/Constants.java +++ b/src/main/java/iudx/catalogue/server/authenticator/Constants.java @@ -5,7 +5,6 @@ public class Constants { public static final String AUTH_SERVER_HOST = "authServerHost"; public static final String UAC_DEPLOYMENT = "isUACInstance"; public static final String UAC_ADMIN = "uacAdmin"; - public static final String COP_ADMIN = "copAdmin"; public static final String KEYCLOACK_HOST = "keycloakServerHost"; public static final String CERTS_ENDPOINT = "certsEndpoint"; public static final String DUMMY_TOKEN_KEY = "authDummyToken"; @@ -18,6 +17,7 @@ public class Constants { public static final String REQUEST = "request"; public static final String BODY = "body"; public static final String RESOURCE_SERVER_URL = "resourceServerRegURL"; + public static final String RATINGS = "ratings"; public static final String AUTH_SERVER_ERROR = "Error calling the Auth Server"; diff --git a/src/main/java/iudx/catalogue/server/authenticator/JwtAuthenticationServiceImpl.java b/src/main/java/iudx/catalogue/server/authenticator/JwtAuthenticationServiceImpl.java index 1b048c11..29b3ce26 100644 --- a/src/main/java/iudx/catalogue/server/authenticator/JwtAuthenticationServiceImpl.java +++ b/src/main/java/iudx/catalogue/server/authenticator/JwtAuthenticationServiceImpl.java @@ -39,17 +39,15 @@ public class JwtAuthenticationServiceImpl implements AuthenticationService { final JWTAuth jwtAuth; final String audience; + final String consumerAudience; final String issuer; - String tempCopAudience; - String tempCopIssuer; private Api api; JwtAuthenticationServiceImpl(final JWTAuth jwtAuth, final JsonObject config, final Api api) { this.jwtAuth = jwtAuth; this.audience = config.getString("host"); + this.consumerAudience = config.getString("consumerHost"); this.issuer = config.getString("issuer"); - this.tempCopAudience = config.getString("tempCopAudience"); - this.tempCopIssuer = config.getString("tempCopIssuer"); this.api = api; } @@ -86,12 +84,13 @@ Future isValidAudienceValue(JwtData jwtData, String itemType, String se case ITEM_TYPE_RESOURCE: isValidAudience = serverUrl != null && serverUrl.equalsIgnoreCase(jwtData.getAud()); break; - default: + case RATINGS: isValidAudience = - tempCopAudience != null && tempCopAudience.equalsIgnoreCase(jwtData.getAud()); + consumerAudience != null && consumerAudience.equalsIgnoreCase(jwtData.getAud()); + break; + default: + isValidAudience = audience != null && audience.equalsIgnoreCase(jwtData.getAud()); break; - // default: - // isValidAudience = audience != null && audience.equalsIgnoreCase(jwtData.getAud()); } if (isValidAudience) { @@ -214,9 +213,8 @@ public AuthenticationService tokenInterospect( result.jwtData = decodeHandler; // audience for ratings is different from other cos endpoints - if (endPoint.equalsIgnoreCase(api.getRouteRating()) - && result.jwtData.getAud().equalsIgnoreCase(audience)) { - return Future.succeededFuture(true); + if (endPoint.equalsIgnoreCase(api.getRouteRating())) { + return isValidAudienceValue(result.jwtData, RATINGS, resourceServerRegUrl); } return isValidAudienceValue(result.jwtData, itemType, resourceServerRegUrl); }) @@ -285,8 +283,7 @@ Future isValidItemId(JwtData jwtData, String itemType, String resourceS case ITEM_TYPE_OWNER: case ITEM_TYPE_COS: case ITEM_TYPE_RESOURCE_SERVER: - // TODO: change type validation to cos - isValidIid = type.equalsIgnoreCase("cop") && server.equalsIgnoreCase(tempCopIssuer); + isValidIid = type.equalsIgnoreCase("cos") && server.equalsIgnoreCase(issuer); break; case ITEM_TYPE_PROVIDER: case ITEM_TYPE_RESOURCE_GROUP: @@ -313,8 +310,7 @@ Future isValidIssuer(JwtData jwtData, String issuer) { } Future isValidAdmin(JwtData jwtData) { - // TODO: cop_admin or cos_admin??? - if (jwtData.getRole().equalsIgnoreCase("cop_admin")) { + if (jwtData.getRole().equalsIgnoreCase("cos_admin")) { return Future.succeededFuture(true); } else if (jwtData.getRole().equalsIgnoreCase("admin")) { return Future.succeededFuture(true); diff --git a/src/main/java/iudx/catalogue/server/authenticator/authorization/AuthorizationContextFactory.java b/src/main/java/iudx/catalogue/server/authenticator/authorization/AuthorizationContextFactory.java index 809ca740..4e2a2147 100644 --- a/src/main/java/iudx/catalogue/server/authenticator/authorization/AuthorizationContextFactory.java +++ b/src/main/java/iudx/catalogue/server/authenticator/authorization/AuthorizationContextFactory.java @@ -26,8 +26,7 @@ public static AuthorizationStratergy create(String role, Api api) { case "admin": { return AdminAuthStrategy.getInstance(api); } - // TODO: cop_admin or cos_admin??? - case "cop_admin": { + case "cos_admin": { return CosAdminAuthStrategy.getInstance(api); } default: diff --git a/src/main/java/iudx/catalogue/server/validator/ValidatorServiceImpl.java b/src/main/java/iudx/catalogue/server/validator/ValidatorServiceImpl.java index c478b98a..afe6f76e 100644 --- a/src/main/java/iudx/catalogue/server/validator/ValidatorServiceImpl.java +++ b/src/main/java/iudx/catalogue/server/validator/ValidatorServiceImpl.java @@ -112,7 +112,9 @@ String getReturnTypeForValidation(JsonObject result) { .toString(); } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + * */ @SuppressWarnings("unchecked") public ValidatorService validateSchema( JsonObject request, Handler> handler) { @@ -155,7 +157,9 @@ public ValidatorService validateSchema( return this; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + * */ @SuppressWarnings("unchecked") @Override public ValidatorService validateItem( diff --git a/src/test/java/iudx/catalogue/server/authenticator/JwtAuthServiceImplTest.java b/src/test/java/iudx/catalogue/server/authenticator/JwtAuthServiceImplTest.java index 9b47e31e..3c2d15f8 100644 --- a/src/test/java/iudx/catalogue/server/authenticator/JwtAuthServiceImplTest.java +++ b/src/test/java/iudx/catalogue/server/authenticator/JwtAuthServiceImplTest.java @@ -50,8 +50,8 @@ static void init(Vertx vertx, VertxTestContext testContext) { authConfig = Configuration.getConfiguration("./configs/config-test.json",1); String cert = authConfig.getString("cert"); authConfig.put("dxApiBasePath", "/iudx/cat/v1"); - authConfig.put("tempCopIssuer", "cop.iudx.io"); - authConfig.put("tempCopAudience", "cop.iudx.io"); + authConfig.put("tempCopIssuer", "cos.iudx.io"); + authConfig.put("tempCopAudience", "cos.iudx.io"); JWTAuthOptions jwtAuthOptions = new JWTAuthOptions(); jwtAuthOptions.addPubSecKey( new PubSecKeyOptions() @@ -107,8 +107,8 @@ private JsonObject authJson() { .put("id", "iisc.ac.in/89a36273d77dac4cf38114fca1bbe64392547f86") .put("apiEndpoint", "/iudx/cat/v1/item") .put("itemType", "iudx:Resource") - .put("resourceServerRegURL", "cat-test.iudx.io") - .put("ownerUserId", "d8e46706-b9db-44e1-a9aa-e40839396b01") + .put("resourceServerRegURL", "rs.iudx.io") + .put("ownerUserId", "b2c27f3f-2524-4a84-816e-91f9ab23f837") .put("method", Method.POST); return jsonObject; } @@ -207,7 +207,7 @@ public void decodeJwtCosAdminSuccess(VertxTestContext testContext) { jwtAuthenticationService.decodeJwt(JwtTokenHelper.cosAdminToken) .onComplete(handler -> { if(handler.succeeded()) { - assertEquals("cop_admin", handler.result().getRole()); + assertEquals("cos_admin", handler.result().getRole()); testContext.completeNow(); } else { testContext.failNow(handler.cause()); @@ -357,7 +357,7 @@ private static Stream itemTypes2() { @DisplayName("successful valid iid check - against cos") public void validIidCheckAgainstCos(String itemType, VertxTestContext testContext) { JwtData jwtData = jwtDataObject(); - jwtData.setIid("cop:cop.iudx.io"); + jwtData.setIid("cos:cos.iudx.io"); jwtAuthenticationService.isValidItemId(jwtData, itemType, "") .onComplete(handler -> { @@ -419,7 +419,7 @@ public void invalidIssuerCheck(VertxTestContext testContext) { @DisplayName("successful valid admin check") public void validAdminCheck(VertxTestContext testContext) { JwtData jwtData = jwtDataObject(); - jwtData.setRole("cop_admin"); + jwtData.setRole("cos_admin"); jwtAuthenticationService.isValidAdmin(jwtData) .onComplete(handler -> { diff --git a/src/test/java/iudx/catalogue/server/authenticator/JwtTokenHelper.java b/src/test/java/iudx/catalogue/server/authenticator/JwtTokenHelper.java index 56a5ee41..da544f38 100644 --- a/src/test/java/iudx/catalogue/server/authenticator/JwtTokenHelper.java +++ b/src/test/java/iudx/catalogue/server/authenticator/JwtTokenHelper.java @@ -3,7 +3,7 @@ public class JwtTokenHelper { static String providerToken = - "eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NiJ9.eyJzdWIiOi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ImNvcy5pdWR4LmlvIiwiZXhwIjoxNjk1MjUxNTQzLCJpYXQiOjE2OTUyMDgzNDMsImlpZCI6ImNvczpjb3MuaXVkeC5pbyIsInJvbGUiOiJjb3NfYWRtaW4iLCJjb25zIjp7fX0.1nW4ERu6f3XqL2pdf4xrKYDfxS3-W3lQgUtVVnV47BCPR-BCodrB6pMBhekZByzwyJsZiXZSKlgARX83XW4Ilw"; } diff --git a/src/test/java/iudx/catalogue/server/authenticator/KCAuthServiceImplTest.java b/src/test/java/iudx/catalogue/server/authenticator/KCAuthServiceImplTest.java index 9a1d6d0b..81967811 100644 --- a/src/test/java/iudx/catalogue/server/authenticator/KCAuthServiceImplTest.java +++ b/src/test/java/iudx/catalogue/server/authenticator/KCAuthServiceImplTest.java @@ -62,10 +62,10 @@ public void TestTokenIntrospect(Vertx vertx, VertxTestContext testContext) { .put(METHOD, Method.POST.toString()) .put(TOKEN, "") .put(ITEM_TYPE, ITEM_TYPE_PROVIDER) - .put(RESOURCE_SERVER_URL, "cop.iudx.io"); + .put(RESOURCE_SERVER_URL, "cos.iudx.io"); JwtData jwtData = new JwtData(); - jwtData.setIss("authvertx.iudx.io"); + jwtData.setIss("cos.iudx.io"); doAnswer(Answer -> Future.succeededFuture(jwtData)) .when(kcAuthenticationServiceSpy) .decodeKcToken(anyString()); @@ -141,7 +141,7 @@ private JWTClaimsSet jwtClaimsSetBuilder() throws ParseException { + "\t\"aud\": \"account\",\n" + "\t\"sub\": \"dummy-admin-id\",\n" + "\t\"typ\": \"Bearer\",\n" - + "\t\"clientId\": \"cop.iudx.io\"\n" + + "\t\"clientId\": \"cos.iudx.io\"\n" + "}"); } @@ -170,7 +170,7 @@ public void TestisValidUAC(Vertx vertx, VertxTestContext testContext) throws Par JWTClaimsSet jwtClaimsSet = jwtClaimsSetBuilder(); JwtData jwtData = new JwtData(new JsonObject(jwtClaimsSet.toString())); - Util.isValidAdmin("cop.iudx.io", jwtData, true) + Util.isValidAdmin("cos.iudx.io", jwtData, true) .onComplete( handler -> { if (handler.succeeded()) { diff --git a/src/test/java/iudx/catalogue/server/authenticator/authorization/AuthorizationContextFactoryTest.java b/src/test/java/iudx/catalogue/server/authenticator/authorization/AuthorizationContextFactoryTest.java index 1614fbb0..5db861db 100644 --- a/src/test/java/iudx/catalogue/server/authenticator/authorization/AuthorizationContextFactoryTest.java +++ b/src/test/java/iudx/catalogue/server/authenticator/authorization/AuthorizationContextFactoryTest.java @@ -63,7 +63,7 @@ public void testCreateDelegate(VertxTestContext vertxTestContext) { @Description("test create for cop admin") public void testCreateCopAdmin(VertxTestContext testContext) { authorizationContextFactory=new AuthorizationContextFactory(); - String role="cop_admin"; + String role="cos_admin"; delegateAuthStrategy= DelegateAuthStrategy.getInstance(this.api); assertFalse(delegateAuthStrategy.isAuthorized(authRequest)); assertNotNull(AuthorizationContextFactory.create(role,this.api)); diff --git a/src/test/resources/iudx-catalogue-server-v5.0.0.postman_collection.json b/src/test/resources/iudx-catalogue-server-v5.0.0.postman_collection.json index fd7629e7..65a63667 100644 --- a/src/test/resources/iudx-catalogue-server-v5.0.0.postman_collection.json +++ b/src/test/resources/iudx-catalogue-server-v5.0.0.postman_collection.json @@ -45,7 +45,7 @@ ], "body": { "mode": "raw", - "raw": "{\n \"itemId\": \"cat-test.iudx.io\",\n \"itemType\": \"resource_server\",\n \"role\": \"consumer\"\n}", + "raw": "{\n \"itemId\": \"rs.iudx.io\",\n \"itemType\": \"resource_server\",\n \"role\": \"consumer\"\n}", "options": { "raw": { "language": "json" @@ -197,6 +197,72 @@ } }, "response": [] + }, + { + "name": "Get Cos ADMIN token", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);", + "pm.environment.set(\"adminToken\", jsonData.results.accessToken);", + "postman.setEnvironmentVariable(\"cosAdminToken\", jsonData.results.accessToken);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "noauth" + }, + "method": "POST", + "header": [ + { + "key": "clientId", + "value": "{{providerClientID}}", + "type": "text" + }, + { + "key": "clientSecret", + "value": "{{providerClientSecret}}", + "type": "text" + }, + { + "key": "Cache-Control", + "value": "no-cache, no-store, must-revalidate", + "type": "text" + }, + { + "key": "", + "value": "", + "type": "text", + "disabled": true + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"itemId\": \"cos.iudx.io\", \n \"itemType\": \"cos\",\n \"role\": \"cos_admin\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "https://{{auth-url}}/{{dxAuthBasePath}}/token", + "protocol": "https", + "host": [ + "{{auth-url}}" + ], + "path": [ + "{{dxAuthBasePath}}", + "token" + ] + } + }, + "response": [] } ] }, From c7219f1bfd19c8757fad55bc839d17ae414373ff Mon Sep 17 00:00:00 2001 From: pranavrd Date: Wed, 20 Sep 2023 22:06:01 +0530 Subject: [PATCH 3/3] fix: environment variable --- .../iudx-catalogue-server-v5.0.0.postman_collection.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/iudx-catalogue-server-v5.0.0.postman_collection.json b/src/test/resources/iudx-catalogue-server-v5.0.0.postman_collection.json index 65a63667..43e90dd8 100644 --- a/src/test/resources/iudx-catalogue-server-v5.0.0.postman_collection.json +++ b/src/test/resources/iudx-catalogue-server-v5.0.0.postman_collection.json @@ -206,7 +206,7 @@ "script": { "exec": [ "var jsonData = JSON.parse(responseBody);", - "pm.environment.set(\"adminToken\", jsonData.results.accessToken);", + "pm.environment.set(\"cosAdminToken\", jsonData.results.accessToken);", "postman.setEnvironmentVariable(\"cosAdminToken\", jsonData.results.accessToken);" ], "type": "text/javascript"