Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add bulk import APIs #90

Open
wants to merge 4 commits into
base: 5.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
327 changes: 322 additions & 5 deletions api_spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ info:

Those that do not have `<tenantId>` 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: [email protected]
Expand All @@ -25,6 +25,8 @@ tags:
- name: Dashboard Recipe
- name: Totp Recipe
- name: Account Linking Recipe
- name: JWT Recipe
- name: Bulk Import

paths:
/appid-<appId>/recipe/accountlinking/user/primary/check:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -5950,6 +5950,168 @@ paths:
'500':
$ref: '#/components/responses/500'

/appid-<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'

/appid-<appId>/bulk-import/users/remove:
post:
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:
Expand Down Expand Up @@ -6144,6 +6306,11 @@ components:
type: string
example: val1,val2,val3..

bulkImportUserStatus:
name: status
in: query
schema:
$ref: '#/components/schemas/bulkImportUserStatus'

responses:
500:
Expand Down Expand Up @@ -6701,3 +6868,153 @@ 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:
recipeId:
type: string
example: "emailpassword"
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:
recipeId:
type: string
example: "thirdparty"
thirdPartyId:
$ref: '#/components/schemas/thirdPartyId'
thirdPartyUserId:
$ref: '#/components/schemas/thirdPartyUserId'
required:
- thirdPartyId
- thirdPartyUserId

bulkImportUserPasswordlessLoginMethod:
allOf:
- $ref: '#/components/schemas/bulkImportUserLoginMethodFields'
- type: object
properties:
recipeId:
type: string
example: "passwordless"
oneOf:
- $ref: '#/components/schemas/email'
- $ref: '#/components/schemas/phoneNumber'

bulkImportUser:
type: object
properties:
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:
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
Loading