diff --git a/documentation/postman/-gcube-devsec-devVRE.postman_environment.json b/documentation/postman/Hello World Env for devVRE.postman_environment.json similarity index 60% rename from documentation/postman/-gcube-devsec-devVRE.postman_environment.json rename to documentation/postman/Hello World Env for devVRE.postman_environment.json index a106ec9..02bbf3e 100644 --- a/documentation/postman/-gcube-devsec-devVRE.postman_environment.json +++ b/documentation/postman/Hello World Env for devVRE.postman_environment.json @@ -1,7 +1,25 @@ { - "id": "f1860155-0d84-4c0c-917b-2f8f015b2752", - "name": "/gcube/devsec/devVRE", + "id": "ff7036fd-e12d-4dd7-9d0f-816bb5a0f06a", + "name": "Hello World Env for devVRE", "values": [ + { + "key": "introspect_secret", + "value": "", + "type": "secret", + "enabled": true + }, + { + "key": "password", + "value": "", + "type": "secret", + "enabled": true + }, +{ + "key": "service_client_secret", + "value": "", + "type": "secret", + "enabled": true + }, { "key": "realm", "value": "d4science", @@ -10,7 +28,7 @@ }, { "key": "username", - "value": "alfredo.oliviero", + "value": "luca.frosini", "type": "default", "enabled": true }, @@ -21,29 +39,11 @@ "enabled": true }, { - "key": "service_client_secret", - "value": "09c26f24-3c65-4039-9fa0-e5cc4f4032cd", - "type": "secret", - "enabled": true - }, - { - "key": "proxy_disabled", - "value": "false", - "type": "default", - "enabled": true - }, - { - "key": "scope_context", + "key": "context", "value": "/gcube/devsec/devVRE", "type": "default", "enabled": true }, - { - "key": "key_password", - "value": "password_alfredo.oliviero", - "type": "default", - "enabled": false - }, { "key": "keycloak_url", "value": "https://accounts.dev.d4science.org/auth", @@ -62,44 +62,14 @@ "type": "default", "enabled": true }, - { - "key": "password", - "value": "", - "type": "secret", - "enabled": true - }, { "key": "introspect_client", "value": "token-exchange-dedicated", "type": "default", "enabled": true - }, - { - "key": "introspect_secret", - "value": "CSFoPr80ua1jv1kMdKRvYT8yU56Hrrdm", - "type": "secret", - "enabled": true - }, - { - "key": "user_test", - "value": "andrea.rossi", - "type": "default", - "enabled": true - }, - { - "key": "pass_test", - "value": "gcube321", - "type": "secret", - "enabled": true - }, - { - "key": "social_access_token", - "value": "", - "type": "default", - "enabled": true } ], "_postman_variable_scope": "environment", - "_postman_exported_at": "2024-05-22T13:44:26.620Z", + "_postman_exported_at": "2024-05-24T16:06:23.560Z", "_postman_exported_using": "Postman/11.1.14" } \ No newline at end of file diff --git a/documentation/postman/Hello World Service.postman_collection.json b/documentation/postman/Hello World Service.postman_collection.json new file mode 100644 index 0000000..d843f68 --- /dev/null +++ b/documentation/postman/Hello World Service.postman_collection.json @@ -0,0 +1,692 @@ +{ + "info": { + "_postman_id": "e152bab3-7be5-4fe2-81bd-625fec76373d", + "name": "Hello World Service", + "description": "An example collection that can be used for communicating with gcube services\n\nget TOKEN and at UMA_TOKEN from url: [https://next.dev.d4science.org/group/gcube/home](https://next.dev.d4science.org/group/gcube/home)\n\nupdate the collection's variables gcube_token and uma_token", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "3092110" + }, + "item": [ + { + "name": "LOGIN", + "item": [ + { + "name": "Clear Env", + "event": [ + { + "listen": "prerequest", + "script": { + "exec": [ + "console.log(\"executing clear script\");", + "", + "variables = [", + " 'token',", + " 'access_token',", + " 'refresh_token',", + "", + " 'uma_token',", + " 'uma_refresh',", + "", + " 'profile_token',", + " 'gcube_token',", + " 'oidc_access_token',", + " 'oidc_refresh_token',", + " 'id_token',", + "", + " 'clientId',", + "", + " 'current_username',", + " 'current_password',", + " 'current_context',", + " 'current_url-encoded-context',", + " 'current_iam-url',", + " 'current_client-id',", + " 'current_uma-token',", + " 'current_access-token',", + "", + " 'oidc_token',", + " 'oidc_access_token',", + " 'oidc_refresh_token',", + " 'uma_token',", + " 'exchanged_token'", + "", + "]", + "", + "for (var v of variables) {", + " pm.environment.unset(v);", + " pm.globals.unset(v);", + "}", + "", + " ", + "", + "", + " ", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "/", + "path": [ + "" + ] + } + }, + "response": [] + }, + { + "name": "Get User Token For Context", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);", + "postman.setEnvironmentVariable(\"oidc_access_token\", jsonData.access_token);", + "postman.setEnvironmentVariable(\"oidc_refresh_token\", jsonData.refresh_token);", + "", + "postman.setEnvironmentVariable(\"uma_token\", jsonData.access_token);", + "", + "postman.setEnvironmentVariable(\"access_token\", jsonData.access_token);", + "postman.setEnvironmentVariable(\"refresh_token\", jsonData.refresh_token);", + "" + ], + "type": "text/javascript", + "packages": {} + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "auth": { + "type": "noauth" + }, + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/x-www-form-urlencoded" + }, + { + "key": "X-D4Science-Context", + "value": "{{encoded_context}}" + } + ], + "body": { + "mode": "urlencoded", + "urlencoded": [ + { + "key": "client_id", + "value": "{{service_client_id}}", + "type": "text" + }, + { + "key": "username", + "value": "{{username}}", + "type": "text" + }, + { + "key": "password", + "value": "{{password}}", + "type": "text" + }, + { + "key": "grant_type", + "value": "password", + "type": "text" + }, + { + "key": "client_secret", + "value": "{{service_client_secret}}", + "type": "text" + } + ] + }, + "url": { + "raw": "{{keycloak_url}}/realms/{{realm}}/protocol/openid-connect/token", + "host": [ + "{{keycloak_url}}" + ], + "path": [ + "realms", + "{{realm}}", + "protocol", + "openid-connect", + "token" + ] + }, + "description": "Obtain UAT = user access token from a user in realm" + }, + "response": [] + }, + { + "name": "Get ClientId Token For Context", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);", + "", + "// postman.setEnvironmentVariable(\"refresh_token\", jsonData.refresh_token);", + "// postman.setEnvironmentVariable(\"id_token\", jsonData.id_token);", + "", + "postman.setEnvironmentVariable(\"oidc_access_token\", jsonData.access_token);", + "", + "postman.setEnvironmentVariable(\"access_token\", jsonData.access_token);", + "postman.setEnvironmentVariable(\"token\", jsonData.access_token);", + "", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "auth": { + "type": "noauth" + }, + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/x-www-form-urlencoded" + }, + { + "key": "X-D4Science-Context", + "value": "{{encoded_context}}" + } + ], + "body": { + "mode": "urlencoded", + "urlencoded": [ + { + "key": "client_id", + "value": "{{service_client_id}}", + "type": "text" + }, + { + "key": "client_secret", + "value": "{{service_client_secret}}", + "type": "text" + }, + { + "key": "grant_type", + "value": "client_credentials", + "type": "text" + } + ] + }, + "url": { + "raw": "{{keycloak_url}}/realms/{{realm}}/protocol/openid-connect/token", + "host": [ + "{{keycloak_url}}" + ], + "path": [ + "realms", + "{{realm}}", + "protocol", + "openid-connect", + "token" + ] + }, + "description": "Obtain SAT (service account token)" + }, + "response": [] + }, + { + "name": "Validate Access Token", + "request": { + "auth": { + "type": "noauth" + }, + "method": "POST", + "header": [ + { + "key": "Authorization", + "value": "Basic YWxmcmVkby1pZG0tc2VydmljZS1kZXY6OTc5YmQzYmMtNWNjNC0xMWVjLWJmNjMtMDI0MmFjMTMwMDAy" + } + ], + "body": { + "mode": "urlencoded", + "urlencoded": [ + { + "key": "token", + "value": "{{access_token}}", + "type": "text" + }, + { + "key": "username\n", + "value": "{{introspect_client}}", + "type": "text", + "disabled": true + }, + { + "key": "password", + "value": "{{introspect_secret}}", + "type": "text", + "disabled": true + }, + { + "key": "client_id", + "value": "{{introspect_client}}", + "type": "text" + }, + { + "key": "client_secret", + "value": "{{introspect_secret}}", + "type": "text" + } + ] + }, + "url": { + "raw": "{{keycloak_url}}/realms/{{realm}}/protocol/openid-connect/token/introspect", + "host": [ + "{{keycloak_url}}" + ], + "path": [ + "realms", + "{{realm}}", + "protocol", + "openid-connect", + "token", + "introspect" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "REST", + "item": [ + { + "name": "authorized", + "item": [ + { + "name": "legacy-token", + "item": [ + { + "name": "hello TOKEN PARAM", + "request": { + "auth": { + "type": "noauth" + }, + "method": "GET", + "header": [ + { + "key": "", + "value": "{{token}}" + } + ], + "url": { + "raw": "{{base_url}}/{{application}}/hello?gcube-token={{gcube_token}}", + "host": [ + "{{base_url}}" + ], + "path": [ + "{{application}}", + "hello" + ], + "query": [ + { + "key": "gcube-token", + "value": "{{gcube_token}}" + } + ] + } + }, + "response": [] + }, + { + "name": "details TOKEN PARAM", + "request": { + "auth": { + "type": "noauth" + }, + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/{{application}}/details?gcube-token={{gcube_token}}", + "host": [ + "{{base_url}}" + ], + "path": [ + "{{application}}", + "details" + ], + "query": [ + { + "key": "gcube-token", + "value": "{{gcube_token}}" + } + ] + } + }, + "response": [] + }, + { + "name": "auth org member TOKEN PARAM", + "request": { + "auth": { + "type": "noauth" + }, + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/{{application}}/auth/org_member?gcube-token={{gcube_token}}", + "host": [ + "{{base_url}}" + ], + "path": [ + "{{application}}", + "auth", + "org_member" + ], + "query": [ + { + "key": "gcube-token", + "value": "{{gcube_token}}" + } + ] + } + }, + "response": [] + }, + { + "name": "auth member TOKEN PARAM", + "request": { + "auth": { + "type": "noauth" + }, + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/{{application}}/auth/member?gcube-token={{gcube_token}}", + "host": [ + "{{base_url}}" + ], + "path": [ + "{{application}}", + "auth", + "member" + ], + "query": [ + { + "key": "gcube-token", + "value": "{{gcube_token}}" + } + ] + } + }, + "response": [] + } + ] + }, + { + "name": "hello", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/{{application}}/hello", + "host": [ + "{{base_url}}" + ], + "path": [ + "{{application}}", + "hello" + ] + } + }, + "response": [] + }, + { + "name": "details", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/{{application}}/details", + "host": [ + "{{base_url}}" + ], + "path": [ + "{{application}}", + "details" + ] + } + }, + "response": [] + }, + { + "name": "auth org member", + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{uma_token}}", + "type": "string" + } + ] + }, + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/{{application}}/auth/org_member", + "host": [ + "{{base_url}}" + ], + "path": [ + "{{application}}", + "auth", + "org_member" + ] + } + }, + "response": [] + }, + { + "name": "auth member", + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{uma_token}}", + "type": "string" + } + ] + }, + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/{{application}}/auth/member", + "host": [ + "{{base_url}}" + ], + "path": [ + "{{application}}", + "auth", + "member" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "No Auth Required", + "item": [ + { + "name": "guest", + "request": { + "auth": { + "type": "noauth" + }, + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/{{application}}/guest", + "host": [ + "{{base_url}}" + ], + "path": [ + "{{application}}", + "guest" + ] + } + }, + "response": [] + }, + { + "name": "404 Not Found", + "request": { + "auth": { + "type": "noauth" + }, + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/{{application}}/guest/not-found", + "host": [ + "{{base_url}}" + ], + "path": [ + "{{application}}", + "guest", + "not-found" + ] + } + }, + "response": [] + }, + { + "name": "400 Bad Request", + "request": { + "auth": { + "type": "noauth" + }, + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/{{application}}/guest/bad-request", + "host": [ + "{{base_url}}" + ], + "path": [ + "{{application}}", + "guest", + "bad-request" + ] + } + }, + "response": [] + }, + { + "name": "PURGE with 204 No Content", + "request": { + "auth": { + "type": "noauth" + }, + "method": "PURGE", + "header": [], + "url": { + "raw": "{{base_url}}/{{application}}/guest/test-purge", + "host": [ + "{{base_url}}" + ], + "path": [ + "{{application}}", + "guest", + "test-purge" + ] + } + }, + "response": [] + } + ] + } + ] + } + ], + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{access_token}}", + "type": "string" + } + ] + }, + "event": [ + { + "listen": "prerequest", + "script": { + "type": "text/javascript", + "packages": {}, + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "type": "text/javascript", + "packages": {}, + "exec": [ + "" + ] + } + } + ], + "variable": [ + { + "key": "base_url", + "value": "http://localhost:8080", + "type": "string" + }, + { + "key": "role_name", + "value": "Member" + }, + { + "key": "application", + "value": "hello-world-service", + "type": "string" + }, + { + "key": "base_url_marco", + "value": "http://146.48.85.179:9999", + "type": "string" + }, + { + "key": "base_url_local", + "value": "http://localhost:8080", + "type": "string" + } + ] +} \ No newline at end of file diff --git a/documentation/postman/Smartgears4 helloword.postman_collection.json b/documentation/postman/Smartgears4 helloword.postman_collection.json deleted file mode 100644 index e6d644a..0000000 --- a/documentation/postman/Smartgears4 helloword.postman_collection.json +++ /dev/null @@ -1,1458 +0,0 @@ -{ - "info": { - "_postman_id": "442a8fd2-cf69-4f21-af2d-698028f25ce9", - "name": "Helloword SM4", - "description": "An example collection that can be used for communicating with gcube services\n\nget TOKEN and at UMA_TOKEN from url: [https://next.dev.d4science.org/group/gcube/home](https://next.dev.d4science.org/group/gcube/home)\n\nupdate the collection's variables gcube_token and uma_token", - "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", - "_exporter_id": "32856827" - }, - "item": [ - { - "name": "LOGIN", - "item": [ - { - "name": "clear context Copy", - "event": [ - { - "listen": "prerequest", - "script": { - "exec": [ - "console.log(\"executing clear script\");", - "", - "variables = [", - " 'token',", - " 'access_token',", - " 'refresh_token',", - "", - " 'uma_token',", - " 'uma_refresh',", - "", - " 'profile_token',", - " 'gcube_token',", - " 'oidc_access_token',", - " 'oidc_refresh_token',", - " 'id_token',", - "", - " 'clientId',", - "", - " 'current_username',", - " 'current_password',", - " 'current_context',", - " 'current_url-encoded-context',", - " 'current_iam-url',", - " 'current_client-id',", - " 'current_uma-token',", - " 'current_access-token',", - "", - " 'oidc_token',", - " 'oidc_access_token',", - " 'oidc_refresh_token',", - " 'uma_token',", - " 'exchanged_token'", - "", - "]", - "", - "for (var v of variables) {", - " pm.environment.unset(v);", - " pm.globals.unset(v);", - "}", - "", - " ", - "", - "", - " ", - "" - ], - "type": "text/javascript", - "packages": {} - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "//", - "path": [ - "", - "" - ] - } - }, - "response": [] - }, - { - "name": "[SAT] Obtain OIDC token from a service account Copy", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "var jsonData = JSON.parse(responseBody);", - "", - "// postman.setEnvironmentVariable(\"refresh_token\", jsonData.refresh_token);", - "// postman.setEnvironmentVariable(\"id_token\", jsonData.id_token);", - "", - "postman.setEnvironmentVariable(\"oidc_access_token\", jsonData.access_token);", - "", - "postman.setEnvironmentVariable(\"access_token\", jsonData.access_token);", - "postman.setEnvironmentVariable(\"token\", jsonData.access_token);", - "" - ], - "type": "text/javascript", - "packages": {} - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/x-www-form-urlencoded", - "name": "Content-Type", - "type": "text" - } - ], - "body": { - "mode": "urlencoded", - "urlencoded": [ - { - "key": "client_id", - "value": "{{service_client_id}}", - "type": "text" - }, - { - "key": "client_secret", - "value": "{{service_client_secret}}", - "type": "text" - }, - { - "key": "grant_type", - "value": "client_credentials", - "type": "text" - } - ] - }, - "url": { - "raw": "{{keycloak_url}}/realms/{{realm}}/protocol/openid-connect/token", - "host": [ - "{{keycloak_url}}" - ], - "path": [ - "realms", - "{{realm}}", - "protocol", - "openid-connect", - "token" - ] - }, - "description": "Obtain SAT (service account token)" - }, - "response": [] - }, - { - "name": "[SAT] Obtain alfredo-idm-service-dev OIDC token", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "var jsonData = JSON.parse(responseBody);", - "", - "// postman.setEnvironmentVariable(\"refresh_token\", jsonData.refresh_token);", - "// postman.setEnvironmentVariable(\"id_token\", jsonData.id_token);", - "", - "postman.setEnvironmentVariable(\"oidc_access_token\", jsonData.access_token);", - "", - "postman.setEnvironmentVariable(\"access_token\", jsonData.access_token);", - "postman.setEnvironmentVariable(\"token\", jsonData.access_token);", - "" - ], - "type": "text/javascript", - "packages": {} - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/x-www-form-urlencoded", - "name": "Content-Type", - "type": "text" - } - ], - "body": { - "mode": "urlencoded", - "urlencoded": [ - { - "key": "client_id", - "value": "alfredo-idm-service-dev", - "type": "text" - }, - { - "key": "client_secret", - "value": "979bd3bc-5cc4-11ec-bf63-0242ac130002", - "type": "text" - }, - { - "key": "grant_type", - "value": "client_credentials", - "type": "text" - } - ] - }, - "url": { - "raw": "{{keycloak_url}}/realms/{{realm}}/protocol/openid-connect/token", - "host": [ - "{{keycloak_url}}" - ], - "path": [ - "realms", - "{{realm}}", - "protocol", - "openid-connect", - "token" - ] - }, - "description": "Obtain SAT (service account token)" - }, - "response": [] - }, - { - "name": "[SAT] Obtain CONTEXT access token from a service account Copy", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "var jsonData = JSON.parse(responseBody);", - "", - "// postman.setEnvironmentVariable(\"refresh_token\", jsonData.refresh_token);", - "// postman.setEnvironmentVariable(\"id_token\", jsonData.id_token);", - "", - "postman.setEnvironmentVariable(\"oidc_access_token\", jsonData.access_token);", - "", - "postman.setEnvironmentVariable(\"access_token\", jsonData.access_token);", - "postman.setEnvironmentVariable(\"token\", jsonData.access_token);", - "", - "" - ], - "type": "text/javascript", - "packages": {} - } - } - ], - "request": { - "auth": { - "type": "noauth" - }, - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/x-www-form-urlencoded" - }, - { - "key": "X-D4Science-Context", - "value": "{{encoded_context}}" - } - ], - "body": { - "mode": "urlencoded", - "urlencoded": [ - { - "key": "client_id", - "value": "{{service_client_id}}", - "type": "text" - }, - { - "key": "client_secret", - "value": "{{service_client_secret}}", - "type": "text" - }, - { - "key": "grant_type", - "value": "client_credentials", - "type": "text" - } - ] - }, - "url": { - "raw": "{{keycloak_url}}/realms/{{realm}}/protocol/openid-connect/token", - "host": [ - "{{keycloak_url}}" - ], - "path": [ - "realms", - "{{realm}}", - "protocol", - "openid-connect", - "token" - ] - }, - "description": "Obtain SAT (service account token)" - }, - "response": [] - }, - { - "name": "[UAT] Obtain id token for a user", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "var jsonData = JSON.parse(responseBody);", - "postman.setEnvironmentVariable(\"oidc_access_token\", jsonData.access_token);", - "postman.setEnvironmentVariable(\"oidc_refresh_token\", jsonData.refresh_token);", - "", - "postman.setEnvironmentVariable(\"access_token\", jsonData.access_token);", - "postman.setEnvironmentVariable(\"refresh_token\", jsonData.refresh_token);", - "" - ], - "type": "text/javascript", - "packages": {} - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "function set_user_pass(){", - " var username = pm.variables.get('username');", - "", - " console.log('current username', pm.variables.get('username'));", - "", - " var pwd_key = 'password_' + username;", - " if (pm.variables.has('key_password')) {", - " pwd_key = pm.variables.get('key_password')", - " }", - "", - " if (pm.variables.has(pwd_key)) {", - " password = pm.variables.get(pwd_key);", - " } else {", - " throw new Error(\"missing password for username \" + username + \". Set a global password (type secret) with key \" + pwd_key);", - " }", - " pm.environment.set('current_password', password );", - " console.log('password', password, 'from', pwd_key );", - "", - " pm.environment.set('current_username', username);", - " pm.environment.set('current_password', password);", - "}", - "", - "set_user_pass();" - ], - "type": "text/javascript", - "packages": {} - } - } - ], - "request": { - "auth": { - "type": "noauth" - }, - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/x-www-form-urlencoded", - "name": "Content-Type", - "type": "text" - } - ], - "body": { - "mode": "urlencoded", - "urlencoded": [ - { - "key": "username", - "value": "{{username}}", - "type": "text" - }, - { - "key": "password", - "value": "{{password}}", - "type": "text" - }, - { - "key": "grant_type", - "value": "password", - "type": "text" - }, - { - "key": "client_id", - "value": "{{client-id-user}}", - "type": "text" - }, - { - "key": "client_secret", - "value": "{{service_client_secret}}", - "type": "text" - } - ] - }, - "url": { - "raw": "{{keycloak_url}}/realms/{{realm}}/protocol/openid-connect/token", - "host": [ - "{{keycloak_url}}" - ], - "path": [ - "realms", - "{{realm}}", - "protocol", - "openid-connect", - "token" - ] - }, - "description": "Obtain UAT = user access token from a user in realm" - }, - "response": [] - }, - { - "name": "[UAT] Obtain CONTEXT id token for a user", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "var jsonData = JSON.parse(responseBody);", - "postman.setEnvironmentVariable(\"oidc_access_token\", jsonData.access_token);", - "postman.setEnvironmentVariable(\"oidc_refresh_token\", jsonData.refresh_token);", - "", - "postman.setEnvironmentVariable(\"uma_token\", jsonData.access_token);", - "", - "postman.setEnvironmentVariable(\"access_token\", jsonData.access_token);", - "postman.setEnvironmentVariable(\"refresh_token\", jsonData.refresh_token);", - "" - ], - "type": "text/javascript", - "packages": {} - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "function set_user_pass(){", - " var username = pm.variables.get('username');", - "", - " console.log('current username', pm.variables.get('username'));", - "", - " var pwd_key = 'password_' + username;", - " if (pm.variables.has('key_password')) {", - " pwd_key = pm.variables.get('key_password')", - " }", - "", - " if (pm.variables.has(pwd_key)) {", - " password = pm.variables.get(pwd_key);", - " } else {", - " throw new Error(\"missing password for username \" + username + \". Set a global password (type secret) with key \" + pwd_key);", - " }", - " pm.environment.set('current_password', password );", - " console.log('password', password, 'from', pwd_key );", - "", - " pm.environment.set('current_username', username);", - " pm.environment.set('current_password', password);", - "}", - "", - "set_user_pass();" - ], - "type": "text/javascript", - "packages": {} - } - } - ], - "request": { - "auth": { - "type": "noauth" - }, - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/x-www-form-urlencoded", - "name": "Content-Type", - "type": "text" - }, - { - "key": "X-D4Science-Context", - "value": "{{encoded_context}}", - "type": "text" - } - ], - "body": { - "mode": "urlencoded", - "urlencoded": [ - { - "key": "client_id", - "value": "{{service_client_id}}", - "type": "text" - }, - { - "key": "username", - "value": "{{username}}", - "type": "text" - }, - { - "key": "password", - "value": "{{password}}", - "type": "text" - }, - { - "key": "grant_type", - "value": "password", - "type": "text" - }, - { - "key": "client_secret", - "value": "{{service_client_secret}}", - "type": "text" - } - ] - }, - "url": { - "raw": "{{keycloak_url}}/realms/{{realm}}/protocol/openid-connect/token", - "host": [ - "{{keycloak_url}}" - ], - "path": [ - "realms", - "{{realm}}", - "protocol", - "openid-connect", - "token" - ] - }, - "description": "Obtain UAT = user access token from a user in realm" - }, - "response": [] - }, - { - "name": "[UAT] Obtain Tesrt CONTEXT id token", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "var jsonData = JSON.parse(responseBody);", - "postman.setEnvironmentVariable(\"oidc_access_token\", jsonData.access_token);", - "postman.setEnvironmentVariable(\"oidc_refresh_token\", jsonData.refresh_token);", - "", - "postman.setEnvironmentVariable(\"uma_token\", jsonData.access_token);", - "", - "postman.setEnvironmentVariable(\"access_token\", jsonData.access_token);", - "postman.setEnvironmentVariable(\"refresh_token\", jsonData.refresh_token);", - "" - ], - "type": "text/javascript", - "packages": {} - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "function set_user_pass(){", - " var username = pm.variables.get('username');", - "", - " console.log('current username', pm.variables.get('username'));", - "", - " var pwd_key = 'password_' + username;", - " if (pm.variables.has('key_password')) {", - " pwd_key = pm.variables.get('key_password')", - " }", - "", - " if (pm.variables.has(pwd_key)) {", - " password = pm.variables.get(pwd_key);", - " } else {", - " throw new Error(\"missing password for username \" + username + \". Set a global password (type secret) with key \" + pwd_key);", - " }", - " pm.environment.set('current_password', password );", - " console.log('password', password, 'from', pwd_key );", - "", - " pm.environment.set('current_username', username);", - " pm.environment.set('current_password', password);", - "}", - "", - "set_user_pass();" - ], - "type": "text/javascript", - "packages": {} - } - } - ], - "request": { - "auth": { - "type": "noauth" - }, - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/x-www-form-urlencoded" - }, - { - "key": "X-D4Science-Context", - "value": "{{encoded_context}}" - } - ], - "body": { - "mode": "urlencoded", - "urlencoded": [ - { - "key": "client_id", - "value": "{{service_client_id}}", - "type": "text" - }, - { - "key": "username", - "value": "{{user_test}}", - "type": "text" - }, - { - "key": "password", - "value": "{{pass_test}}", - "type": "text" - }, - { - "key": "grant_type", - "value": "password", - "type": "text" - }, - { - "key": "client_secret", - "value": "{{service_client_secret}}", - "type": "text" - } - ] - }, - "url": { - "raw": "{{keycloak_url}}/realms/{{realm}}/protocol/openid-connect/token", - "host": [ - "{{keycloak_url}}" - ], - "path": [ - "realms", - "{{realm}}", - "protocol", - "openid-connect", - "token" - ] - }, - "description": "Obtain UAT = user access token from a user in realm" - }, - "response": [] - }, - { - "name": "EXCHANGE oidc_access_token", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "var jsonData = JSON.parse(responseBody);", - "", - "postman.setEnvironmentVariable(\"access_token\", jsonData.access_token);", - "postman.setEnvironmentVariable(\"refresh_token\", jsonData.refresh_token);", - "", - "postman.setEnvironmentVariable(\"exchanged_token\", jsonData.access_token);", - "" - ], - "type": "text/javascript", - "packages": {} - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript", - "packages": {} - } - } - ], - "protocolProfileBehavior": { - "disabledSystemHeaders": { - "user-agent": true, - "accept": true, - "accept-encoding": true, - "connection": true - } - }, - "request": { - "auth": { - "type": "noauth" - }, - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/x-www-form-urlencoded", - "name": "Content-Type", - "type": "text", - "disabled": true - }, - { - "key": "X-D4Science-Context", - "value": "{{encoded_context}}", - "type": "text" - } - ], - "body": { - "mode": "urlencoded", - "urlencoded": [ - { - "key": "subject_token", - "value": "{{oidc_access_token}}", - "type": "text" - }, - { - "key": "client_id", - "value": "{{introspect_client}}", - "type": "text" - }, - { - "key": "client_secret", - "value": "{{introspect_secret}}", - "type": "text" - }, - { - "key": "grant_type", - "value": "urn:ietf:params:oauth:grant-type:token-exchange", - "type": "text" - }, - { - "key": "subject_token_type", - "value": "urn:ietf:params:oauth:token-type:access_token", - "type": "text" - }, - { - "key": "requested_token_type", - "value": "urn:ietf:params:oauth:token-type:access_token", - "type": "text" - } - ] - }, - "url": { - "raw": "{{keycloak_url}}/realms/{{realm}}/protocol/openid-connect/token", - "host": [ - "{{keycloak_url}}" - ], - "path": [ - "realms", - "{{realm}}", - "protocol", - "openid-connect", - "token" - ] - }, - "description": "Obtain UAT = user access token from a user in realm" - }, - "response": [] - }, - { - "name": "EXCHANGE oidc_access_token Copy", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "var jsonData = JSON.parse(responseBody);", - "", - "postman.setEnvironmentVariable(\"access_token\", jsonData.access_token);", - "postman.setEnvironmentVariable(\"refresh_token\", jsonData.refresh_token);", - "", - "postman.setEnvironmentVariable(\"exchanged_token\", jsonData.access_token);", - "" - ], - "type": "text/javascript", - "packages": {} - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript", - "packages": {} - } - } - ], - "protocolProfileBehavior": { - "disabledSystemHeaders": { - "user-agent": true, - "accept": true, - "accept-encoding": true, - "connection": true - } - }, - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/x-www-form-urlencoded", - "name": "Content-Type", - "type": "text", - "disabled": true - }, - { - "key": "X-D4Science-Context", - "value": "{{encoded_context}}", - "type": "text" - } - ], - "body": { - "mode": "urlencoded", - "urlencoded": [ - { - "key": "subject_token", - "value": "{{oidc_access_token}}", - "type": "text" - }, - { - "key": "client_id", - "value": "{{introspect_client}}", - "type": "text" - }, - { - "key": "client_secret", - "value": "{{introspect_secret}}", - "type": "text" - }, - { - "key": "grant_type", - "value": "urn:ietf:params:oauth:grant-type:token-exchange", - "type": "text" - }, - { - "key": "subject_token_type", - "value": "urn:ietf:params:oauth:token-type:access_token", - "type": "text" - }, - { - "key": "requested_token_type", - "value": "urn:ietf:params:oauth:token-type:access_token", - "type": "text" - } - ] - }, - "url": { - "raw": "{{keycloak_url}}/realms/{{realm}}/protocol/openid-connect/token", - "host": [ - "{{keycloak_url}}" - ], - "path": [ - "realms", - "{{realm}}", - "protocol", - "openid-connect", - "token" - ] - }, - "description": "Obtain UAT = user access token from a user in realm" - }, - "response": [] - }, - { - "name": "refresh CONTEXT token Copy", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "var jsonData = JSON.parse(responseBody);", - "", - "postman.setEnvironmentVariable(\"access_token\", jsonData.access_token);", - "postman.setEnvironmentVariable(\"refresh_token\", jsonData.refresh_token);", - "" - ], - "type": "text/javascript", - "packages": {} - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "X-D4Science-Context", - "value": "{{encoded_context}}", - "type": "text" - } - ], - "body": { - "mode": "urlencoded", - "urlencoded": [ - { - "key": "grant_type", - "value": "refresh_token", - "type": "text" - }, - { - "key": "client_id", - "value": "{{client-id-user}}", - "type": "text" - }, - { - "key": "refresh_token", - "value": "{{refresh_token}}", - "type": "text" - }, - { - "key": "client_secret", - "value": "{{service_client_secret}}", - "type": "text", - "disabled": true - } - ] - }, - "url": { - "raw": "{{keycloak_url}}/realms/{{realm}}/protocol/openid-connect/token", - "host": [ - "{{keycloak_url}}" - ], - "path": [ - "realms", - "{{realm}}", - "protocol", - "openid-connect", - "token" - ] - } - }, - "response": [] - }, - { - "name": "introspect access token", - "request": { - "auth": { - "type": "noauth" - }, - "method": "POST", - "header": [ - { - "key": "Authorization", - "value": "Basic YWxmcmVkby1pZG0tc2VydmljZS1kZXY6OTc5YmQzYmMtNWNjNC0xMWVjLWJmNjMtMDI0MmFjMTMwMDAy", - "type": "text" - } - ], - "body": { - "mode": "urlencoded", - "urlencoded": [ - { - "key": "token", - "value": "{{access_token}}", - "type": "text" - }, - { - "key": "username\n", - "value": "{{introspect_client}}", - "type": "text", - "disabled": true - }, - { - "key": "password", - "value": "{{introspect_secret}}", - "type": "text", - "disabled": true - }, - { - "key": "client_id", - "value": "{{introspect_client}}", - "type": "text" - }, - { - "key": "client_secret", - "value": "{{introspect_secret}}", - "type": "text" - } - ] - }, - "url": { - "raw": "{{keycloak_url}}/realms/{{realm}}/protocol/openid-connect/token/introspect", - "host": [ - "{{keycloak_url}}" - ], - "path": [ - "realms", - "{{realm}}", - "protocol", - "openid-connect", - "token", - "introspect" - ] - } - }, - "response": [] - }, - { - "name": "New Request", - "request": { - "method": "GET", - "header": [] - }, - "response": [] - } - ] - }, - { - "name": "REST", - "item": [ - { - "name": "hello TOKEN PARAM", - "request": { - "auth": { - "type": "noauth" - }, - "method": "GET", - "header": [ - { - "key": "", - "value": "{{token}}", - "type": "text" - } - ], - "url": { - "raw": "{{base_url}}/{{application}}/hello?gcube-token={{gcube_token}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "{{application}}", - "hello" - ], - "query": [ - { - "key": "gcube-token", - "value": "{{gcube_token}}" - } - ] - } - }, - "response": [] - }, - { - "name": "details TOKEN PARAM", - "request": { - "auth": { - "type": "noauth" - }, - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/{{application}}/details?gcube-token={{gcube_token}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "{{application}}", - "details" - ], - "query": [ - { - "key": "gcube-token", - "value": "{{gcube_token}}" - } - ] - } - }, - "response": [] - }, - { - "name": "test keycloak TOKEN PARAM", - "request": { - "auth": { - "type": "bearer", - "bearer": [ - { - "key": "token", - "value": "{{uma_token}}", - "type": "string" - } - ] - }, - "method": "GET", - "header": [ - { - "key": "gcube-token", - "value": "{{gcube_token}}", - "type": "text", - "disabled": true - } - ], - "url": { - "raw": "{{base_url}}/{{application}}/keycloak?client_secret={{service_client_secret}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "{{application}}", - "keycloak" - ], - "query": [ - { - "key": "client_secret", - "value": "{{service_client_secret}}" - }, - { - "key": "client_id", - "value": "{{current_client-id}}", - "disabled": true - } - ] - } - }, - "response": [] - }, - { - "name": "auth org member TOKEN PARAM", - "request": { - "auth": { - "type": "noauth" - }, - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/{{application}}/auth/org_member?gcube-token={{gcube_token}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "{{application}}", - "auth", - "org_member" - ], - "query": [ - { - "key": "gcube-token", - "value": "{{gcube_token}}" - } - ] - } - }, - "response": [] - }, - { - "name": "auth member TOKEN PARAM Copy", - "request": { - "auth": { - "type": "noauth" - }, - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/{{application}}/auth/member?gcube-token={{gcube_token}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "{{application}}", - "auth", - "member" - ], - "query": [ - { - "key": "gcube-token", - "value": "{{gcube_token}}" - } - ] - } - }, - "response": [] - }, - { - "name": "guest", - "request": { - "auth": { - "type": "noauth" - }, - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/{{application}}/guest", - "host": [ - "{{base_url}}" - ], - "path": [ - "{{application}}", - "guest" - ] - } - }, - "response": [] - }, - { - "name": "hello BEARER", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/{{application}}/hello", - "host": [ - "{{base_url}}" - ], - "path": [ - "{{application}}", - "hello" - ] - } - }, - "response": [] - }, - { - "name": "details BEARER", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/{{application}}/details", - "host": [ - "{{base_url}}" - ], - "path": [ - "{{application}}", - "details" - ] - } - }, - "response": [] - }, - { - "name": "auth org member BEARER Copy", - "request": { - "auth": { - "type": "bearer", - "bearer": [ - { - "key": "token", - "value": "{{uma_token}}", - "type": "string" - } - ] - }, - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/{{application}}/auth/org_member", - "host": [ - "{{base_url}}" - ], - "path": [ - "{{application}}", - "auth", - "org_member" - ] - } - }, - "response": [] - }, - { - "name": "auth member BEARER Copy", - "request": { - "auth": { - "type": "bearer", - "bearer": [ - { - "key": "token", - "value": "{{uma_token}}", - "type": "string" - } - ] - }, - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/{{application}}/auth/member", - "host": [ - "{{base_url}}" - ], - "path": [ - "{{application}}", - "auth", - "member" - ] - } - }, - "response": [] - }, - { - "name": "test keycloak BEARER", - "request": { - "auth": { - "type": "bearer", - "bearer": [ - { - "key": "token", - "value": "{{uma_token}}", - "type": "string" - } - ] - }, - "method": "GET", - "header": [ - { - "key": "gcube-token", - "value": "{{gcube_token}}", - "type": "text", - "disabled": true - } - ], - "url": { - "raw": "{{base_url}}/{{application}}/keycloak?client_secret={{service_client_secret}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "{{application}}", - "keycloak" - ], - "query": [ - { - "key": "client_secret", - "value": "{{service_client_secret}}" - }, - { - "key": "client_id", - "value": "{{current_client-id}}", - "disabled": true - } - ] - } - }, - "response": [] - }, - { - "name": "New Request", - "request": { - "auth": { - "type": "basic", - "basic": [ - { - "key": "password", - "value": "cuberandom321", - "type": "string" - }, - { - "key": "username", - "value": "notifications@d4science.org", - "type": "string" - } - ] - }, - "method": "GET", - "header": [], - "url": { - "raw": "https://next.dev.d4science.org:443/api/jsonws/company/get-company-by-web-id/web-id/liferay.com", - "protocol": "https", - "host": [ - "next", - "dev", - "d4science", - "org" - ], - "port": "443", - "path": [ - "api", - "jsonws", - "company", - "get-company-by-web-id", - "web-id", - "liferay.com" - ] - } - }, - "response": [] - } - ] - } - ], - "auth": { - "type": "bearer", - "bearer": [ - { - "key": "token", - "value": "{{access_token}}", - "type": "string" - } - ] - }, - "event": [ - { - "listen": "prerequest", - "script": { - "type": "text/javascript", - "packages": {}, - "exec": [ - "" - ] - } - }, - { - "listen": "test", - "script": { - "type": "text/javascript", - "packages": {}, - "exec": [ - "" - ] - } - } - ], - "variable": [ - { - "key": "base_url", - "value": "http://localhost:8080", - "type": "string" - }, - { - "key": "uma_token", - "value": "", - "type": "string" - }, - { - "key": "username", - "value": "", - "type": "string" - }, - { - "key": "user_id", - "value": "", - "type": "string" - }, - { - "key": "role_name", - "value": "Member" - }, - { - "key": "social_users_path", - "value": "2/users", - "type": "string" - }, - { - "key": "social_people_path", - "value": "2/people", - "type": "string" - }, - { - "key": "application", - "value": "helloworld", - "type": "string" - }, - { - "key": "base_url_marco", - "value": "http://146.48.85.179:9999", - "type": "string" - }, - { - "key": "base_url_local", - "value": "http://localhost:8080", - "type": "string" - } - ] -} \ No newline at end of file diff --git a/documentation/sphinx/index.rst b/documentation/sphinx/index.rst index 28b9d5d..7883f7a 100644 --- a/documentation/sphinx/index.rst +++ b/documentation/sphinx/index.rst @@ -47,7 +47,7 @@ The most common error statuses a client can obtain are: * **409 Conflict** the request could not be completed due to a conflict with the current state of the target resource (e.g. the name of the resource already exists) ``_; * **500 Internal Server Error** indicate a server failure ``_. -You can find a complete list of HTTP Status at ``_ +You can find a complete list of HTTP Status at ``_ or ``_ If you get a *500 Internal Server Error*, please report it in the `gCube ticketing system `_. diff --git a/src/main/java/org/gcube/service/helloworld/annotation/PURGE.java b/src/main/java/org/gcube/service/helloworld/annotation/PURGE.java new file mode 100644 index 0000000..b6b73ea --- /dev/null +++ b/src/main/java/org/gcube/service/helloworld/annotation/PURGE.java @@ -0,0 +1,17 @@ +package org.gcube.service.helloworld.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import jakarta.ws.rs.HttpMethod; + +/** + * @author Luca Frosini (ISTI - CNR) + */ +@Target({ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@HttpMethod("PURGE") +public @interface PURGE { +} \ No newline at end of file diff --git a/src/main/java/org/gcube/service/helloworld/rest/ExcludeAuthorizationService.java b/src/main/java/org/gcube/service/helloworld/rest/ExcludeAuthorizationService.java index be0cac8..d67720c 100644 --- a/src/main/java/org/gcube/service/helloworld/rest/ExcludeAuthorizationService.java +++ b/src/main/java/org/gcube/service/helloworld/rest/ExcludeAuthorizationService.java @@ -1,5 +1,6 @@ package org.gcube.service.helloworld.rest; +import org.gcube.service.helloworld.annotation.PURGE; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -8,6 +9,8 @@ import jakarta.ws.rs.GET; import jakarta.ws.rs.NotFoundException; import jakarta.ws.rs.Path; import jakarta.ws.rs.WebApplicationException; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.Status; @Path("guest") public class ExcludeAuthorizationService { @@ -44,4 +47,10 @@ public class ExcludeAuthorizationService { throw new NotFoundException(); } + @PURGE + @Path("test-purge") + public Response testPurge() throws WebApplicationException { + return Response.status(Status.NO_CONTENT).build(); + } + }