From 9614107f9e69975edb0b98eab5193c3e47874243 Mon Sep 17 00:00:00 2001 From: Ankit Tiwari Date: Tue, 9 Apr 2024 12:40:09 +0530 Subject: [PATCH 1/4] feat: Add bulk import APIs --- api_spec.yaml | 321 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 316 insertions(+), 5 deletions(-) diff --git a/api_spec.yaml b/api_spec.yaml index 9b354d4..5426d1a 100644 --- a/api_spec.yaml +++ b/api_spec.yaml @@ -7,7 +7,7 @@ info: Those that do not have `` in the path will enforce that the API is called from `public` tenant only. - version: 5.0.0 + version: 5.1.0 title: Core Driver Interface contact: email: team@supertokens.io @@ -25,6 +25,8 @@ tags: - name: Dashboard Recipe - name: Totp Recipe - name: Account Linking Recipe + - name: JWT Recipe + - name: Bulk Import paths: /appid-/recipe/accountlinking/user/primary/check: @@ -2062,11 +2064,9 @@ paths: email: $ref: '#/components/schemas/email' passwordHash: - type: string - example: "passwordHash" + $ref: '#/components/schemas/passwordHash' hashingAlgorithm: - type: string - enum: ["argon2", "bcrypt", "firebase_scrypt"] + $ref: '#/components/schemas/hashingAlgorithm' responses: @@ -5950,6 +5950,167 @@ paths: '500': $ref: '#/components/responses/500' + /appid-/bulk-import/users: + get: + tags: + - Bulk Import + operationId: getBulkImportUsers + description: | + Paginated API to get bulk import users + parameters: + - $ref: '#/components/parameters/api-key' + - $ref: '#/components/parameters/cdi-version' + - $ref: '#/components/parameters/paginationToken' + - $ref: '#/components/parameters/limit' + - $ref: '#/components/parameters/bulkImportUserStatus' + + responses: + '200': + description: Paginated Bulk Import Users + content: + application/json: + schema: + type: object + properties: + status: + $ref: '#/components/schemas/statusOK' + users: + type: array + items: + $ref: '#/components/schemas/bulkImportUserResponse' + nextPaginationToken: + $ref: '#/components/schemas/paginationToken' + '400': + $ref: '#/components/responses/400' + + '401': + $ref: '#/components/responses/401' + + '404': + $ref: '#/components/responses/404' + + '500': + $ref: '#/components/responses/500' + + post: + tags: + - Bulk Import + operationId: addBulkImportUsers + description: | + Add users for bulk import. Maximum 10000 users can be added in one request. + parameters: + - $ref: '#/components/parameters/api-key' + - $ref: '#/components/parameters/cdi-version' + requestBody: + content: + application/json: + schema: + type: object + properties: + users: + type: array + items: + $ref: '#/components/schemas/bulkImportUser' + required: + - users + responses: + '200': + description: Bulk Import Users added successfully + content: + application/json: + schema: + type: object + properties: + status: + $ref: '#/components/schemas/statusOK' + '400': + description: One or more users have invalid schema + content: + application/json: + schema: + type: object + properties: + error: + type: string + example: "Data has missing or invalid fields. Please check the users field for more details." + users: + type: array + items: + type: object + properties: + index: + type: number + example: 0 + description: "Index of the user in the users array that has invalid schema" + errors: + type: array + items: + type: string + description: "List of errors for the user" + example: "Invalid recipeId for loginMethod. Pass one of emailpassword, thirdparty or, passwordless!" + + '401': + $ref: '#/components/responses/401' + + '404': + $ref: '#/components/responses/404' + + '500': + $ref: '#/components/responses/500' + + delete: + tags: + - Bulk Import + operationId: deleteBulkImportUsers + description: | + Delete bulk import users by id. Multiple ids can be passed in the request body. + parameters: + - $ref: '#/components/parameters/api-key' + - $ref: '#/components/parameters/cdi-version' + requestBody: + content: + application/json: + schema: + type: object + properties: + ids: + type: array + description: List of bulk import user ids to be deleted + items: + $ref: '#/components/schemas/bulkImportUserId' + required: + - ids + responses: + '200': + description: Bulk Import Users deleted successfully + content: + application/json: + schema: + type: object + properties: + deletedIds: + type: array + description: List of ids that were successfully deleted + items: + $ref: '#/components/schemas/bulkImportUserId' + invalidIds: + type: array + description: List of ids that were invalid + items: + $ref: '#/components/schemas/bulkImportUserId' + example: [] + + '400': + $ref: '#/components/responses/400' + + '401': + $ref: '#/components/responses/401' + + '404': + $ref: '#/components/responses/404' + + '500': + $ref: '#/components/responses/500' components: parameters: @@ -6144,6 +6305,11 @@ components: type: string example: val1,val2,val3.. + bulkImportUserStatus: + name: status + in: query + schema: + $ref: '#/components/schemas/bulkImportUserStatus' responses: 500: @@ -6701,3 +6867,148 @@ components: $ref: '#/components/schemas/requiredSecondaryFactors' coreConfig: type: object + + passwordHash: + type: string + example: "$argon2d$v=19$m=12,t=3,p=1$aGI4enNvMmd0Zm0wMDAwMA$r6p7qbr6HD+8CD7sBi4HVw" + hashingAlgorithm: + type: string + enum: ["argon2", "bcrypt", "firebase_scrypt"] + + bulkImportUserId: + type: string + example: "fa7a0841-b533-4478-9253-0fde890c576" + + bulkImportUserStatus: + type: string + enum: ["NEW", "PROCESSING", "FAILED"] + + bulkImportUserRole: + type: object + properties: + role: + $ref: '#/components/schemas/role' + tenantIds: + type: array + items: + $ref: '#/components/schemas/tenantId' + required: + - role + - tenantIds + + bulkImportTotpDevice: + type: object + properties: + secretKey: + type: string + example: "2PRXZWZAYYDAWCD" + skew: + type: number + example: 0 + period: + type: number + example: 30 + deviceName: + type: string + example: "My Authy App" + required: + - secretKey + + bulkImportUserLoginMethodFields: + type: object + properties: + tenantIds: + type: array + description: List of tenant IDs this login method is associated with + items: + $ref: '#/components/schemas/tenantId' + isVerified: + type: boolean + description: Indicates whether the email is verified + isPrimary: + type: boolean + description: Indicates whether the login method is the primary login method + timeJoinedInMSSinceEpoch: + type: integer + description: Time joined in milliseconds since the epoch + + bulkImportUserEmailPasswordLoginMethod: + allOf: + - $ref: '#/components/schemas/bulkImportUserLoginMethodFields' + - type: object + properties: + email: + $ref: '#/components/schemas/email' + passwordHash: + $ref: '#/components/schemas/passwordHash' + hashingAlgorithm: + $ref: '#/components/schemas/hashingAlgorithm' + required: + - email + - passwordHash + - hashingAlgorithm + + bulkImportUserThirdPartyLoginMethod: + allOf: + - $ref: '#/components/schemas/bulkImportUserLoginMethodFields' + - type: object + properties: + thirdPartyId: + $ref: '#/components/schemas/thirdPartyId' + thirdPartyUserId: + $ref: '#/components/schemas/thirdPartyUserId' + required: + - thirdPartyId + - thirdPartyUserId + + bulkImportUserPasswordlessLoginMethod: + allOf: + - $ref: '#/components/schemas/bulkImportUserLoginMethodFields' + - type: object + properties: + email: + $ref: '#/components/schemas/email' + phoneNumber: + $ref: '#/components/schemas/phoneNumber' + oneOf: + - required: ["email"] + - required: ["phoneNumber"] + + bulkImportUser: + type: object + properties: + id: + $ref: '#/components/schemas/bulkImportUserId' + externalUserId: + $ref: '#/components/schemas/userId' + userMetadata: + type: array + items: + $ref: '#/components/schemas/userMetadata' + userRoles: + type: array + items: + $ref: '#/components/schemas/bulkImportUserRole' + totpDevices: + type: array + items: + $ref: '#/components/schemas/bulkImportTotpDevice' + loginMethods: + type: array + items: + anyOf: + - $ref: '#/components/schemas/bulkImportUserEmailPasswordLoginMethod' + - $ref: '#/components/schemas/bulkImportUserThirdPartyLoginMethod' + - $ref: '#/components/schemas/bulkImportUserPasswordlessLoginMethod' + + bulkImportUserResponse: + allOf: + - $ref: '#/components/schemas/bulkImportUser' + - type: object + properties: + status: + $ref: '#/components/schemas/bulkImportUserStatus' + createdAt: + $ref: '#/components/schemas/timeJoined' + updatedAt: + $ref: '#/components/schemas/timeJoined' From 0aa771c03545e35010bf7b5175cc0441b8de940d Mon Sep 17 00:00:00 2001 From: Ankit Tiwari Date: Tue, 16 Apr 2024 13:07:08 +0530 Subject: [PATCH 2/4] fix: PR changes --- api_spec.yaml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/api_spec.yaml b/api_spec.yaml index 5426d1a..438118b 100644 --- a/api_spec.yaml +++ b/api_spec.yaml @@ -6977,8 +6977,6 @@ components: bulkImportUser: type: object properties: - id: - $ref: '#/components/schemas/bulkImportUserId' externalUserId: $ref: '#/components/schemas/userId' userMetadata: @@ -7002,13 +7000,15 @@ components: - $ref: '#/components/schemas/bulkImportUserPasswordlessLoginMethod' bulkImportUserResponse: + properties: + id: + $ref: '#/components/schemas/bulkImportUserId' + status: + $ref: '#/components/schemas/bulkImportUserStatus' + createdAt: + $ref: '#/components/schemas/timeJoined' + updatedAt: + $ref: '#/components/schemas/timeJoined' allOf: - $ref: '#/components/schemas/bulkImportUser' - type: object - properties: - status: - $ref: '#/components/schemas/bulkImportUserStatus' - createdAt: - $ref: '#/components/schemas/timeJoined' - updatedAt: - $ref: '#/components/schemas/timeJoined' From 8382362623bb4772ca2652cdc365cd81a00da735 Mon Sep 17 00:00:00 2001 From: Ankit Tiwari Date: Thu, 18 Apr 2024 12:28:03 +0530 Subject: [PATCH 3/4] fix: PR changes --- api_spec.yaml | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/api_spec.yaml b/api_spec.yaml index 438118b..837c98e 100644 --- a/api_spec.yaml +++ b/api_spec.yaml @@ -6937,6 +6937,9 @@ components: - $ref: '#/components/schemas/bulkImportUserLoginMethodFields' - type: object properties: + recipeId: + type: string + example: "emailpassword" email: $ref: '#/components/schemas/email' passwordHash: @@ -6953,6 +6956,9 @@ components: - $ref: '#/components/schemas/bulkImportUserLoginMethodFields' - type: object properties: + recipeId: + type: string + example: "thirdparty" thirdPartyId: $ref: '#/components/schemas/thirdPartyId' thirdPartyUserId: @@ -6966,13 +6972,12 @@ components: - $ref: '#/components/schemas/bulkImportUserLoginMethodFields' - type: object properties: - email: - $ref: '#/components/schemas/email' - phoneNumber: - $ref: '#/components/schemas/phoneNumber' - oneOf: - - required: ["email"] - - required: ["phoneNumber"] + recipeId: + type: string + example: "passwordless" + oneOf: + - $ref: '#/components/schemas/email' + - $ref: '#/components/schemas/phoneNumber' bulkImportUser: type: object From fd7a72570303338de5ed6090506008c6c87379db Mon Sep 17 00:00:00 2001 From: Ankit Tiwari Date: Mon, 29 Apr 2024 15:58:53 +0530 Subject: [PATCH 4/4] fix: update path for deleteBulkImportUsers --- api_spec.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api_spec.yaml b/api_spec.yaml index 837c98e..ed9685b 100644 --- a/api_spec.yaml +++ b/api_spec.yaml @@ -6058,7 +6058,8 @@ paths: '500': $ref: '#/components/responses/500' - delete: + /appid-/bulk-import/users/remove: + post: tags: - Bulk Import operationId: deleteBulkImportUsers