From 623c059281496305872a8743e5fa4104ceb372c4 Mon Sep 17 00:00:00 2001 From: Chakravarthi Medicharla Date: Thu, 12 Oct 2023 16:55:43 +0530 Subject: [PATCH 01/12] feat: userroles api spec --- api_spec.yaml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/api_spec.yaml b/api_spec.yaml index 93f5ba2d..c4bc496a 100644 --- a/api_spec.yaml +++ b/api_spec.yaml @@ -19,6 +19,8 @@ tags: description: APIs related to recording telemetry from the dashboard - name: "Multitenancy" description: APIs related to multitenancy + - name: "User Roles and Permissions" + description: APIs related to user roles and permisssions paths: /signin: @@ -1267,6 +1269,38 @@ paths: properties: enabled: type: boolean + /userroles/list: + get: + tags: + - User Roles and Permissions + summary: Get all created roles + responses: + 200: + description: Success + content: + application/json: + schema: + oneOf: + - type: object + properties: + status: + type: string + default: "OK" + roles: + type: array + items: + type: string + example: ["admin", "user"] + - type: object + properties: + status: + type: string + default: "RECIPE_NOT_INITIALISED" + - type: object + properties: + status: + type: string + default: "NO_ROLES_FOUND" servers: # Added by API Auto Mocking Plugin From ce754843545f6e0bd06188bc618c3d33d497f75f Mon Sep 17 00:00:00 2001 From: Chakravarthi Medicharla Date: Fri, 13 Oct 2023 14:49:17 +0530 Subject: [PATCH 02/12] update api spec --- api_spec.yaml | 359 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 357 insertions(+), 2 deletions(-) diff --git a/api_spec.yaml b/api_spec.yaml index c4bc496a..234d8183 100644 --- a/api_spec.yaml +++ b/api_spec.yaml @@ -1269,7 +1269,7 @@ paths: properties: enabled: type: boolean - /userroles/list: + /userroles/roles: get: tags: - User Roles and Permissions @@ -1290,7 +1290,9 @@ paths: type: array items: type: string - example: ["admin", "user"] + example: + - "admin" + - "user" - type: object properties: status: @@ -1301,6 +1303,359 @@ paths: status: type: string default: "NO_ROLES_FOUND" + /userroles/role: + post: + tags: + - User Roles and Permissions + summary: Creates a role with permissions + requestBody: + content: + application/json: + schema: + type: object + properties: + roleName: + type: string + example: "admin" + permissions: + type: array + items: + type: string + example: + - "read" + - "write" + responses: + 200: + description: Success + content: + application/json: + schema: + oneOf: + - type: object + properties: + status: + type: string + default: "OK" + createdNewRole: + type: boolean + 401: + description: Unauthorised access + content: + text/plain: + schema: + type: string + enum: + - Unauthorised access + 400: + description: error code 400 + content: + text/plain: + schema: + type: string + enum: + - Method not supported + delete: + tags: + - User Roles and Permissions + summary: Deletes a role. + parameters: + - name: roleName + in: query + required: true + schema: + type: string + example: admin + + responses: + 200: + description: Success + content: + application/json: + schema: + oneOf: + - type: object + properties: + status: + type: string + default: "OK" + 401: + description: Unauthorised access + content: + text/plain: + schema: + type: string + enum: + - Unauthorised access + 400: + description: error code 400 + content: + text/plain: + schema: + type: string + enum: + - Method not supported + /userroles/role/permissions: + get: + tags: + - User Roles and Permissions + summary: Get permissions associated with a role + parameters: + - name: roleName + in: query + required: true + schema: + type: string + example: "admin" + responses: + 200: + description: Success + content: + application/json: + schema: + oneOf: + - type: object + properties: + status: + type: string + default: "OK" + permissions: + type: array + items: + type: string + example: + - "read" + - "write" + - type: object + properties: + status: + type: string + default: "NO_ROLE_FOUND" + put: + tags: + - User Roles and Permissions + summary: Adds new permissions to a role + requestBody: + content: + application/json: + schema: + type: object + properties: + roleName: + type: string + example: "admin" + permission: + type: string + example: "readonly" + responses: + 200: + description: Success + content: + application/json: + schema: + oneOf: + - type: object + properties: + status: + type: string + default: "OK" + createdNewRole: + type: boolean + example: false + 401: + description: Unauthorised access + content: + text/plain: + schema: + type: string + enum: + - Unauthorised access + 400: + description: error code 400 + content: + text/plain: + schema: + type: string + enum: + - Method not supported + /userroles/role/permissions/remove: + put: + tags: + - User Roles and Permissions + summary: Remove permissions associated with a role + requestBody: + content: + application/json: + schema: + type: object + properties: + roleName: + type: string + example: "admin" + permission: + type: string + example: "readonly" + responses: + 200: + description: Success + content: + application/json: + schema: + oneOf: + - type: object + properties: + status: + type: string + default: "OK" + createdNewRole: + type: boolean + example: false + 401: + description: Unauthorised access + content: + text/plain: + schema: + type: string + enum: + - Unauthorised access + 400: + description: error code 400 + content: + text/plain: + schema: + type: string + enum: + - Method not supported + /userroles//user/roles: + get: + tags: + - User Roles and Permissions + summary: Get all roles that are assigned to a user + parameters: + - name: roleName + in: query + required: true + schema: + type: string + example: "admin" + responses: + 200: + description: Success + content: + application/json: + schema: + oneOf: + - type: object + properties: + status: + type: string + default: "OK" + permissions: + type: array + items: + type: string + example: + - "read" + - "write" + - type: object + properties: + status: + type: string + default: "NO_ROLE_FOUND" + put: + tags: + - User Roles and Permissions + summary: Add a new role to a user + requestBody: + content: + application/json: + schema: + type: object + properties: + userId: + type: string + example: "fa7a0841-b533-4478-95533-0fde890c3483" + roleName: + type: string + example: "admin" + responses: + 200: + description: Success + content: + application/json: + schema: + oneOf: + - type: object + properties: + status: + type: string + default: "OK" + didUserAlreadyHaveRole: + type: boolean + example: false + 401: + description: Unauthorised access + content: + text/plain: + schema: + type: string + enum: + - Unauthorised access + 400: + description: error code 400 + content: + text/plain: + schema: + type: string + enum: + - Method not supported + delete: + tags: + - User Roles and Permissions + summary: Remove a role assigned to a user + parameters: + - name: userId + in: query + required: true + schema: + type: string + example: "fa7a0841-b533-4478-95533-0fde890c3483" + - name: roleName + in: query + required: true + schema: + type: string + example: "admin" + responses: + 200: + description: Success + content: + application/json: + schema: + oneOf: + - type: object + properties: + status: + type: string + default: "OK" + didUserAlreadyHaveRole: + type: boolean + example: false + 401: + description: Unauthorised access + content: + text/plain: + schema: + type: string + enum: + - Unauthorised access + 400: + description: error code 400 + content: + text/plain: + schema: + type: string + enum: + - Method not supported servers: # Added by API Auto Mocking Plugin From 4f4a7ac24a2b8a86cb45e40361c6578a7eeb1aa3 Mon Sep 17 00:00:00 2001 From: Chakravarthi Medicharla Date: Mon, 16 Oct 2023 20:11:12 +0530 Subject: [PATCH 03/12] update api spec --- api_spec.yaml | 115 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 70 insertions(+), 45 deletions(-) diff --git a/api_spec.yaml b/api_spec.yaml index 234d8183..e48e460f 100644 --- a/api_spec.yaml +++ b/api_spec.yaml @@ -1289,20 +1289,21 @@ paths: roles: type: array items: - type: string - example: - - "admin" - - "user" + type: object + properties: + role: + type: string + default: "admin" + permissions: + type: array + items: + type: string + default: "read" - type: object properties: status: type: string - default: "RECIPE_NOT_INITIALISED" - - type: object - properties: - status: - type: string - default: "NO_ROLES_FOUND" + default: "FEATURE_NOT_ENABLED_ERROR" /userroles/role: post: tags: @@ -1314,7 +1315,7 @@ paths: schema: type: object properties: - roleName: + role: type: string example: "admin" permissions: @@ -1336,8 +1337,11 @@ paths: status: type: string default: "OK" - createdNewRole: - type: boolean + - type: object + properties: + status: + type: string + default: "ROLE_ALREADY_EXITS" 401: description: Unauthorised access content: @@ -1359,7 +1363,7 @@ paths: - User Roles and Permissions summary: Deletes a role. parameters: - - name: roleName + - name: role in: query required: true schema: @@ -1378,6 +1382,11 @@ paths: status: type: string default: "OK" + - type: object + properties: + status: + type: string + default: "ROLE_DO_NOT_EXISTS" 401: description: Unauthorised access content: @@ -1400,7 +1409,7 @@ paths: - User Roles and Permissions summary: Get permissions associated with a role parameters: - - name: roleName + - name: role in: query required: true schema: @@ -1422,14 +1431,6 @@ paths: type: array items: type: string - example: - - "read" - - "write" - - type: object - properties: - status: - type: string - default: "NO_ROLE_FOUND" put: tags: - User Roles and Permissions @@ -1440,12 +1441,13 @@ paths: schema: type: object properties: - roleName: + role: type: string example: "admin" - permission: - type: string - example: "readonly" + permissions: + type: array + items: + type: string responses: 200: description: Success @@ -1488,12 +1490,13 @@ paths: schema: type: object properties: - roleName: + role: type: string example: "admin" - permission: - type: string - example: "readonly" + permissions: + type: array + items: + type: string responses: 200: description: Success @@ -1506,9 +1509,11 @@ paths: status: type: string default: "OK" - createdNewRole: - type: boolean - example: false + - type: object + properties: + status: + type: string + default: "UNKNOWN_ROLE_ERROR" 401: description: Unauthorised access content: @@ -1525,18 +1530,24 @@ paths: type: string enum: - Method not supported - /userroles//user/roles: + /userroles/user/roles: get: tags: - User Roles and Permissions summary: Get all roles that are assigned to a user parameters: - - name: roleName + - name: userId in: query required: true schema: type: string - example: "admin" + example: "fa7a0841-b533-4478-95533-0fde890c3483" + - name: tenantId + in: query + required: false + schema: + type: string + example: "public" responses: 200: description: Success @@ -1570,13 +1581,17 @@ paths: application/json: schema: type: object + required: ["userId", "role"] properties: userId: type: string example: "fa7a0841-b533-4478-95533-0fde890c3483" - roleName: + role: type: string example: "admin" + tenantId: + type: string + example: "public" responses: 200: description: Success @@ -1589,9 +1604,16 @@ paths: status: type: string default: "OK" - didUserAlreadyHaveRole: - type: boolean - example: false + - type: object + properties: + status: + type: string + default: "UNKNOWN_ROLE_ERROR" + - type: object + properties: + status: + type: string + default: "ROLE_ALREADY_ASSIGNED" 401: description: Unauthorised access content: @@ -1619,7 +1641,7 @@ paths: schema: type: string example: "fa7a0841-b533-4478-95533-0fde890c3483" - - name: roleName + - name: role in: query required: true schema: @@ -1637,9 +1659,12 @@ paths: status: type: string default: "OK" - didUserAlreadyHaveRole: - type: boolean - example: false + - type: object + properties: + status: + type: string + default: "UNKNOWN_ROLE_ERROR" + 401: description: Unauthorised access content: From 7b803dadcac8ba8ce48bf55a2d2444de385a77b1 Mon Sep 17 00:00:00 2001 From: Chakravarthi Medicharla Date: Wed, 8 Nov 2023 12:47:40 +0530 Subject: [PATCH 04/12] Add Feature not enabled check to all apis and merging creation and updating api for role into one --- api_spec.yaml | 107 +++++++++++++++++++++++++------------------------- 1 file changed, 54 insertions(+), 53 deletions(-) diff --git a/api_spec.yaml b/api_spec.yaml index e48e460f..dcbdb1f5 100644 --- a/api_spec.yaml +++ b/api_spec.yaml @@ -1274,6 +1274,19 @@ paths: tags: - User Roles and Permissions summary: Get all created roles + parameters: + - name: page + in: query + required: true + schema: + type: number + example: "1" + - name: limit + in: query + required: true + schema: + type: number + example: "10" responses: 200: description: Success @@ -1286,6 +1299,9 @@ paths: status: type: string default: "OK" + totalPages: + type: number + default: 5 roles: type: array items: @@ -1305,10 +1321,10 @@ paths: type: string default: "FEATURE_NOT_ENABLED_ERROR" /userroles/role: - post: + put: tags: - User Roles and Permissions - summary: Creates a role with permissions + summary: Creates a role with permissions or Adds permissions to a existing role if already exits requestBody: content: application/json: @@ -1337,11 +1353,14 @@ paths: status: type: string default: "OK" + createdNewRole: + type: boolean + default: true - type: object properties: status: type: string - default: "ROLE_ALREADY_EXITS" + default: "FEATURE_NOT_ENABLED_ERROR" 401: description: Unauthorised access content: @@ -1382,11 +1401,13 @@ paths: status: type: string default: "OK" + didRoleExists: + type: boolean - type: object properties: status: type: string - default: "ROLE_DO_NOT_EXISTS" + default: "FEATURE_NOT_ENABLED_ERROR" 401: description: Unauthorised access content: @@ -1431,54 +1452,17 @@ paths: type: array items: type: string - put: - tags: - - User Roles and Permissions - summary: Adds new permissions to a role - requestBody: - content: - application/json: - schema: - type: object - properties: - role: - type: string - example: "admin" - permissions: - type: array - items: - type: string - responses: - 200: - description: Success - content: - application/json: - schema: - oneOf: + - type: object properties: status: type: string - default: "OK" - createdNewRole: - type: boolean - example: false - 401: - description: Unauthorised access - content: - text/plain: - schema: - type: string - enum: - - Unauthorised access - 400: - description: error code 400 - content: - text/plain: - schema: - type: string - enum: - - Method not supported + default: "UNKNOWN_ROLE_ERROR" + - type: object + properties: + status: + type: string + default: "FEATURE_NOT_ENABLED_ERROR" /userroles/role/permissions/remove: put: tags: @@ -1509,11 +1493,17 @@ paths: status: type: string default: "OK" + - type: object properties: status: type: string default: "UNKNOWN_ROLE_ERROR" + - type: object + properties: + status: + type: string + default: "FEATURE_NOT_ENABLED_ERROR" 401: description: Unauthorised access content: @@ -1560,18 +1550,18 @@ paths: status: type: string default: "OK" - permissions: + roles: type: array items: type: string example: - - "read" - - "write" + - "admin" + - "user" - type: object properties: status: type: string - default: "NO_ROLE_FOUND" + default: "FEATURE_NOT_ENABLED_ERROR" put: tags: - User Roles and Permissions @@ -1604,6 +1594,9 @@ paths: status: type: string default: "OK" + didUserAlreadyHaveRole: + type: string + default: "false" - type: object properties: status: @@ -1613,7 +1606,7 @@ paths: properties: status: type: string - default: "ROLE_ALREADY_ASSIGNED" + default: "FEATURE_NOT_ENABLED_ERROR" 401: description: Unauthorised access content: @@ -1659,11 +1652,19 @@ paths: status: type: string default: "OK" + didUserHaveRole: + type: boolean + default: false - type: object properties: status: type: string default: "UNKNOWN_ROLE_ERROR" + - type: object + properties: + status: + type: string + default: "FEATURE_NOT_ENABLED_ERROR" 401: description: Unauthorised access From fdf6779a1b3cce02c694c62b25c45898f2171541 Mon Sep 17 00:00:00 2001 From: Chakravarthi Medicharla Date: Wed, 8 Nov 2023 13:26:48 +0530 Subject: [PATCH 05/12] revert changes --- .github/PULL_REQUEST_TEMPLATE.md | 53 -------------------------------- 1 file changed, 53 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index b8031715..1d87c823 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -36,59 +36,6 @@ - [ ] Android - [ ] iOS (including iPadOS) -### Feature tests: - -- [ ] Search - - [ ] Search with anything that results in an empty state in the UI (Should show an empty state explaining that there were no results) - - [ ] Search with an empty string (Dashboard should not allow this) - - [ ] Email search - - [ ] Serach for "e" with email tag and then delete the tag (Should show one user initially then show all with pagination enabled) - - [ ] Search for "test" with the email tag (Expect 14 results) - - [ ] Search with "g" for email tag (Expect 3 results) - - [ ] Search with "g" and "p" for email tag (Expect 3 results) - - [ ] Search with "g" and "t" for email tag, then delete "t" (Expect 17 results initially, then 3) - - [ ] Search with "@" for email tag (Expect 0 results (This is because at the time of adding this case we would only check for the start of the email or the domain and not any character inside the full email)) - - [ ] Search for "passwordless+ABC@gmail.com" with email tag (Expect 1 result) - - [ ] Search for "debugging@supertokens.com" with email tag (Expect 3 results) - - [ ] Search for "gmail" with email tag (Expect 3 results) - - [ ] Search for "ABC" with email tag (Expect 0 results) - - [ ] Search for "a" with email tag (Expect 0 results (This is because at the time of adding this we only check if the email starts with the query and not contains)) - - [ ] Search for "team" with email tag (Expect 0 results) - - [ ] Search for "782" with email tag (Expect 1 result) - - [ ] Phone search - - [ ] Search for "1" with phone tag (Expect 3 results) - - [ ] Search for "+1" with phone tag (Expect 3 results) - - [ ] Search for "91" with phone tag (Expect 1 result) - - [ ] Search for "291" with phone tag (Expect 0 results) - - [ ] Search for "+12" with phone tag (Expect 2 results) - - [ ] Search for "5" with phone tag (Expect 0 results) - - [ ] Search for "1(" with phone tag (Expect 0 results (This is because we render phone numbers with brackets so users may end up searching with that)) - - [ ] Provider search - - [ ] Search for "g" with provider tag (Expect 5 results) - - [ ] Search for "gi" with provider tag (Expect 2 results) - - [ ] Search for "t" with provider tag (Expect 0 results) - - [ ] Search for "google" with provider tag (Expect 3 results) - - [ ] Combination testing - - [ ] Search with "g" for email tag and "g" for provider tag (Expect 1 result) - - [ ] Search for "github" with provider tag and "782" with email tag (Expect 1 result) - - [ ] Search for "github" and "google" with provider tag (Expect 5 results) - - [ ] Search for "j" and "g" with email tag (Expect 6 results) - - [ ] Search for "1" and "91" with phone tag (Expect 4 results) - - [ ] Search with "google" for provider tag and "1" for phone tag (Expect 0 results) - - [ ] Search for "g" with email tag and "1" with phone tag (Expect 0 results) - - [ ] Search for "k" with provider and "a", "g", "b" (in that order) for email (Expect 0 resutls) -- [ ] General UI testing - - [ ] Test that emty state renders fine (no overflow, no UI glitches, responsiveness etc) - - [ ] Test that the list renders fine (no overflow, no UI glitches, responsiveness etc) - - [ ] Test that pagination is visiable and usable (There should be at least 2 pages worth of users) - - [ ] Test that the list only shows 10 users at a time - - [ ] Test that for users with no accounts linked the auth method i nthe list is correct - - [ ] Test that for users with multiple login methods, the auth method shows correctly - - [ ] Test that search is visible if the feature is enabled -- [ ] Multi tenant testing - - [ ] Create one tenant (tenant1), and add 3 users to them. In the dashboard, when you switch to that tenant, it should list those users. - - [ ] Create a user in tenant1 and using backend sdk's(Go, Python, Node) associate the user to a different tenant and select that tenant on the dashboard from the tenants dropdown, it should show that user in the list - ## Documentation changes (If relevant, please create a PR in our [docs repo](https://github.com/supertokens/docs), or create a checklist here highlighting the necessary changes) From aa29100164e66b969b1fa6b05e90540ac9c66845 Mon Sep 17 00:00:00 2001 From: Chakravarthi Medicharla Date: Wed, 8 Nov 2023 13:36:14 +0530 Subject: [PATCH 06/12] update api spec to have FEATURE_NOT_ENABLED response every endpoint --- .github/PULL_REQUEST_TEMPLATE.md | 53 --------------- api_spec.yaml | 107 ++++++++++++++++--------------- 2 files changed, 54 insertions(+), 106 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index b8031715..1d87c823 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -36,59 +36,6 @@ - [ ] Android - [ ] iOS (including iPadOS) -### Feature tests: - -- [ ] Search - - [ ] Search with anything that results in an empty state in the UI (Should show an empty state explaining that there were no results) - - [ ] Search with an empty string (Dashboard should not allow this) - - [ ] Email search - - [ ] Serach for "e" with email tag and then delete the tag (Should show one user initially then show all with pagination enabled) - - [ ] Search for "test" with the email tag (Expect 14 results) - - [ ] Search with "g" for email tag (Expect 3 results) - - [ ] Search with "g" and "p" for email tag (Expect 3 results) - - [ ] Search with "g" and "t" for email tag, then delete "t" (Expect 17 results initially, then 3) - - [ ] Search with "@" for email tag (Expect 0 results (This is because at the time of adding this case we would only check for the start of the email or the domain and not any character inside the full email)) - - [ ] Search for "passwordless+ABC@gmail.com" with email tag (Expect 1 result) - - [ ] Search for "debugging@supertokens.com" with email tag (Expect 3 results) - - [ ] Search for "gmail" with email tag (Expect 3 results) - - [ ] Search for "ABC" with email tag (Expect 0 results) - - [ ] Search for "a" with email tag (Expect 0 results (This is because at the time of adding this we only check if the email starts with the query and not contains)) - - [ ] Search for "team" with email tag (Expect 0 results) - - [ ] Search for "782" with email tag (Expect 1 result) - - [ ] Phone search - - [ ] Search for "1" with phone tag (Expect 3 results) - - [ ] Search for "+1" with phone tag (Expect 3 results) - - [ ] Search for "91" with phone tag (Expect 1 result) - - [ ] Search for "291" with phone tag (Expect 0 results) - - [ ] Search for "+12" with phone tag (Expect 2 results) - - [ ] Search for "5" with phone tag (Expect 0 results) - - [ ] Search for "1(" with phone tag (Expect 0 results (This is because we render phone numbers with brackets so users may end up searching with that)) - - [ ] Provider search - - [ ] Search for "g" with provider tag (Expect 5 results) - - [ ] Search for "gi" with provider tag (Expect 2 results) - - [ ] Search for "t" with provider tag (Expect 0 results) - - [ ] Search for "google" with provider tag (Expect 3 results) - - [ ] Combination testing - - [ ] Search with "g" for email tag and "g" for provider tag (Expect 1 result) - - [ ] Search for "github" with provider tag and "782" with email tag (Expect 1 result) - - [ ] Search for "github" and "google" with provider tag (Expect 5 results) - - [ ] Search for "j" and "g" with email tag (Expect 6 results) - - [ ] Search for "1" and "91" with phone tag (Expect 4 results) - - [ ] Search with "google" for provider tag and "1" for phone tag (Expect 0 results) - - [ ] Search for "g" with email tag and "1" with phone tag (Expect 0 results) - - [ ] Search for "k" with provider and "a", "g", "b" (in that order) for email (Expect 0 resutls) -- [ ] General UI testing - - [ ] Test that emty state renders fine (no overflow, no UI glitches, responsiveness etc) - - [ ] Test that the list renders fine (no overflow, no UI glitches, responsiveness etc) - - [ ] Test that pagination is visiable and usable (There should be at least 2 pages worth of users) - - [ ] Test that the list only shows 10 users at a time - - [ ] Test that for users with no accounts linked the auth method i nthe list is correct - - [ ] Test that for users with multiple login methods, the auth method shows correctly - - [ ] Test that search is visible if the feature is enabled -- [ ] Multi tenant testing - - [ ] Create one tenant (tenant1), and add 3 users to them. In the dashboard, when you switch to that tenant, it should list those users. - - [ ] Create a user in tenant1 and using backend sdk's(Go, Python, Node) associate the user to a different tenant and select that tenant on the dashboard from the tenants dropdown, it should show that user in the list - ## Documentation changes (If relevant, please create a PR in our [docs repo](https://github.com/supertokens/docs), or create a checklist here highlighting the necessary changes) diff --git a/api_spec.yaml b/api_spec.yaml index e48e460f..dcbdb1f5 100644 --- a/api_spec.yaml +++ b/api_spec.yaml @@ -1274,6 +1274,19 @@ paths: tags: - User Roles and Permissions summary: Get all created roles + parameters: + - name: page + in: query + required: true + schema: + type: number + example: "1" + - name: limit + in: query + required: true + schema: + type: number + example: "10" responses: 200: description: Success @@ -1286,6 +1299,9 @@ paths: status: type: string default: "OK" + totalPages: + type: number + default: 5 roles: type: array items: @@ -1305,10 +1321,10 @@ paths: type: string default: "FEATURE_NOT_ENABLED_ERROR" /userroles/role: - post: + put: tags: - User Roles and Permissions - summary: Creates a role with permissions + summary: Creates a role with permissions or Adds permissions to a existing role if already exits requestBody: content: application/json: @@ -1337,11 +1353,14 @@ paths: status: type: string default: "OK" + createdNewRole: + type: boolean + default: true - type: object properties: status: type: string - default: "ROLE_ALREADY_EXITS" + default: "FEATURE_NOT_ENABLED_ERROR" 401: description: Unauthorised access content: @@ -1382,11 +1401,13 @@ paths: status: type: string default: "OK" + didRoleExists: + type: boolean - type: object properties: status: type: string - default: "ROLE_DO_NOT_EXISTS" + default: "FEATURE_NOT_ENABLED_ERROR" 401: description: Unauthorised access content: @@ -1431,54 +1452,17 @@ paths: type: array items: type: string - put: - tags: - - User Roles and Permissions - summary: Adds new permissions to a role - requestBody: - content: - application/json: - schema: - type: object - properties: - role: - type: string - example: "admin" - permissions: - type: array - items: - type: string - responses: - 200: - description: Success - content: - application/json: - schema: - oneOf: + - type: object properties: status: type: string - default: "OK" - createdNewRole: - type: boolean - example: false - 401: - description: Unauthorised access - content: - text/plain: - schema: - type: string - enum: - - Unauthorised access - 400: - description: error code 400 - content: - text/plain: - schema: - type: string - enum: - - Method not supported + default: "UNKNOWN_ROLE_ERROR" + - type: object + properties: + status: + type: string + default: "FEATURE_NOT_ENABLED_ERROR" /userroles/role/permissions/remove: put: tags: @@ -1509,11 +1493,17 @@ paths: status: type: string default: "OK" + - type: object properties: status: type: string default: "UNKNOWN_ROLE_ERROR" + - type: object + properties: + status: + type: string + default: "FEATURE_NOT_ENABLED_ERROR" 401: description: Unauthorised access content: @@ -1560,18 +1550,18 @@ paths: status: type: string default: "OK" - permissions: + roles: type: array items: type: string example: - - "read" - - "write" + - "admin" + - "user" - type: object properties: status: type: string - default: "NO_ROLE_FOUND" + default: "FEATURE_NOT_ENABLED_ERROR" put: tags: - User Roles and Permissions @@ -1604,6 +1594,9 @@ paths: status: type: string default: "OK" + didUserAlreadyHaveRole: + type: string + default: "false" - type: object properties: status: @@ -1613,7 +1606,7 @@ paths: properties: status: type: string - default: "ROLE_ALREADY_ASSIGNED" + default: "FEATURE_NOT_ENABLED_ERROR" 401: description: Unauthorised access content: @@ -1659,11 +1652,19 @@ paths: status: type: string default: "OK" + didUserHaveRole: + type: boolean + default: false - type: object properties: status: type: string default: "UNKNOWN_ROLE_ERROR" + - type: object + properties: + status: + type: string + default: "FEATURE_NOT_ENABLED_ERROR" 401: description: Unauthorised access From 0bbebd2bba806c80c16eb7e8ed6b1b536ef39f5e Mon Sep 17 00:00:00 2001 From: Chakravarthi Medicharla Date: Wed, 8 Nov 2023 20:14:44 +0530 Subject: [PATCH 07/12] change response type for roles api --- api_spec.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/api_spec.yaml b/api_spec.yaml index dcbdb1f5..c25e7421 100644 --- a/api_spec.yaml +++ b/api_spec.yaml @@ -1302,6 +1302,9 @@ paths: totalPages: type: number default: 5 + rolesCount: + type: number + default: 50 roles: type: array items: From 4499f77a4a34ef4c63a63db82fcd8a1b15a12e6d Mon Sep 17 00:00:00 2001 From: Chakravarthi Medicharla Date: Thu, 9 Nov 2023 15:34:42 +0530 Subject: [PATCH 08/12] update get all roles api spec --- api_spec.yaml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/api_spec.yaml b/api_spec.yaml index c25e7421..c482f182 100644 --- a/api_spec.yaml +++ b/api_spec.yaml @@ -1277,13 +1277,13 @@ paths: parameters: - name: page in: query - required: true + required: false schema: type: number example: "1" - name: limit in: query - required: true + required: false schema: type: number example: "10" @@ -1318,6 +1318,19 @@ paths: items: type: string default: "read" + - type: object + properties: + status: + type: string + default: "OK" + roles: + type: array + items: + type: string + example: + - "admin" + - "user" + - type: object properties: status: From 60f1db03fdf615a77d0b0808d47d68eeef1a85ac Mon Sep 17 00:00:00 2001 From: Chakravarthi Medicharla Date: Wed, 15 Nov 2023 12:18:36 +0530 Subject: [PATCH 09/12] update rolesCount to totalRolesCount --- api_spec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api_spec.yaml b/api_spec.yaml index c482f182..6186a9f2 100644 --- a/api_spec.yaml +++ b/api_spec.yaml @@ -1302,7 +1302,7 @@ paths: totalPages: type: number default: 5 - rolesCount: + totalRolesCount: type: number default: 50 roles: From f49e3e2ef62904022f4669789cfaba1871a03867 Mon Sep 17 00:00:00 2001 From: Chakravarthi Medicharla Date: Thu, 16 Nov 2023 14:42:08 +0530 Subject: [PATCH 10/12] update api spec --- api_spec.yaml | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git a/api_spec.yaml b/api_spec.yaml index 6186a9f2..1a57b206 100644 --- a/api_spec.yaml +++ b/api_spec.yaml @@ -1274,19 +1274,6 @@ paths: tags: - User Roles and Permissions summary: Get all created roles - parameters: - - name: page - in: query - required: false - schema: - type: number - example: "1" - - name: limit - in: query - required: false - schema: - type: number - example: "10" responses: 200: description: Success @@ -1294,30 +1281,6 @@ paths: application/json: schema: oneOf: - - type: object - properties: - status: - type: string - default: "OK" - totalPages: - type: number - default: 5 - totalRolesCount: - type: number - default: 50 - roles: - type: array - items: - type: object - properties: - role: - type: string - default: "admin" - permissions: - type: array - items: - type: string - default: "read" - type: object properties: status: From a306aefb36c642d618402984908ebd45fc4137da Mon Sep 17 00:00:00 2001 From: Chakravarthi Medicharla Date: Wed, 22 Nov 2023 17:33:39 +0530 Subject: [PATCH 11/12] fix: edit api spec with tenantId's --- api_spec.yaml | 120 +++++++++++++++++++++++++------------------------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/api_spec.yaml b/api_spec.yaml index 1a57b206..020f0cb9 100644 --- a/api_spec.yaml +++ b/api_spec.yaml @@ -23,7 +23,7 @@ tags: description: APIs related to user roles and permisssions paths: - /signin: + /dashboard/api/signin: post: tags: - User Authentication @@ -92,7 +92,7 @@ paths: type: string enum: - Not Found - /signout: + /dashboard/api/signout: post: tags: - User Authentication @@ -127,7 +127,7 @@ paths: type: string enum: - Not Found - /users: + //dashboard/api/users: get: tags: - User Management @@ -273,7 +273,7 @@ paths: type: string enum: - Not Found - /users/count: + //dashboard/api/users/count: get: tags: - User Management @@ -322,7 +322,7 @@ paths: type: string enum: - Not Found - /user: + /dashboard/api/user: get: tags: - User Details @@ -612,7 +612,7 @@ paths: type: string enum: - Not Found - /user/unlink: + /dashboard/api/user/unlink: get: tags: - User Details @@ -663,12 +663,12 @@ paths: type: string enum: - Not Found - /user/email/verify: - get: + //dashboard/api/user/email/verify: + put: tags: - User Details - summary: Check if a user's email is verified - operationId: getUserEmailVerified + summary: Set a user's email as verified + operationId: userEmailVerifyPut parameters: - name: authorization in: header @@ -676,31 +676,27 @@ paths: schema: type: string example: "Bearer API_KEY" - - name: userId - in: query - required: true - schema: - type: string + requestBody: + content: + application/json: + schema: + type: object + properties: + userId: + type: string + verified: + type: boolean responses: 200: description: Success content: application/json: schema: - oneOf: - - type: object - properties: - status: - type: string - default: "OK" - isVerified: - type: boolean - default: true - - type: object - properties: - status: - type: string - default: "FEATURE_NOT_ENABLED_ERROR" + type: object + properties: + status: + type: string + default: "OK" 400: description: error code 400 content: @@ -723,11 +719,12 @@ paths: type: string enum: - Not Found - put: + /dashboard/api/user/email/verify: + get: tags: - User Details - summary: Set a user's email as verified - operationId: userEmailVerifyPut + summary: Check if a user's email is verified + operationId: getUserEmailVerified parameters: - name: authorization in: header @@ -735,27 +732,31 @@ paths: schema: type: string example: "Bearer API_KEY" - requestBody: - content: - application/json: - schema: - type: object - properties: - userId: - type: string - verified: - type: boolean + - name: userId + in: query + required: true + schema: + type: string responses: 200: description: Success content: application/json: schema: - type: object - properties: - status: - type: string - default: "OK" + oneOf: + - type: object + properties: + status: + type: string + default: "OK" + isVerified: + type: boolean + default: true + - type: object + properties: + status: + type: string + default: "FEATURE_NOT_ENABLED_ERROR" 400: description: error code 400 content: @@ -778,7 +779,7 @@ paths: type: string enum: - Not Found - /user/email/verify/token: + //dashboard/api/user/email/verify/token: post: tags: - User Details @@ -838,7 +839,7 @@ paths: type: string enum: - Not Found - /user/metadata: + /dashboard/api/user/metadata: get: tags: - User Details @@ -960,7 +961,7 @@ paths: type: string enum: - Not Found - /user/password: + //dashboard/api/user/password: put: tags: - User Details @@ -1024,7 +1025,7 @@ paths: type: string enum: - Not Found - /user/sessions: + /dashboard/api/user/sessions: get: tags: - User Details @@ -1153,7 +1154,7 @@ paths: type: string enum: - Not Found - /api/analytics: + /dashboard/api/analytics: post: tags: - Telemetry @@ -1211,7 +1212,7 @@ paths: type: string enum: - Not Found - /search/tags: + /dashboard/api/search/tags: get: tags: - Search @@ -1228,8 +1229,7 @@ paths: type: array items: type: string - - /tenants/list: + /dashboard/api/tenants/list: get: tags: - Multitenancy @@ -1269,7 +1269,7 @@ paths: properties: enabled: type: boolean - /userroles/roles: + /dashboard/api/userroles/roles: get: tags: - User Roles and Permissions @@ -1299,7 +1299,7 @@ paths: status: type: string default: "FEATURE_NOT_ENABLED_ERROR" - /userroles/role: + /dashboard/api/userroles/role: put: tags: - User Roles and Permissions @@ -1403,7 +1403,7 @@ paths: type: string enum: - Method not supported - /userroles/role/permissions: + /dashboard/api/userroles/role/permissions: get: tags: - User Roles and Permissions @@ -1442,7 +1442,7 @@ paths: status: type: string default: "FEATURE_NOT_ENABLED_ERROR" - /userroles/role/permissions/remove: + /dashboard/api/userroles/role/permissions/remove: put: tags: - User Roles and Permissions @@ -1499,7 +1499,7 @@ paths: type: string enum: - Method not supported - /userroles/user/roles: + //dashboard/api/userroles/user/roles: get: tags: - User Roles and Permissions From d3cc14beeba7572fb4520778d2a1a36054dd713e Mon Sep 17 00:00:00 2001 From: Chakravarthi Medicharla Date: Thu, 23 Nov 2023 11:36:23 +0530 Subject: [PATCH 12/12] update note --- api_spec.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/api_spec.yaml b/api_spec.yaml index 020f0cb9..8515bba8 100644 --- a/api_spec.yaml +++ b/api_spec.yaml @@ -3,8 +3,10 @@ openapi: 3.0.0 info: version: 0.0.0 title: Dashboard Interface - description: Interface for dashboard and backend SDK to communicate with each other. All APIs must be prefixed by `{apiDomain}/{apiBasePath}` - note: "All the POST api's would give 403 status code back when user permissions are enabled." + description: | + Interface for dashboard and backend SDK to communicate with each other. All APIs must be prefixed by `{apiDomain}/{apiBasePath}` + + `Note:` All the POST api's would give 403 status code back when user permissions are enabled. tags: - name: "User Authentication"