Account portal no passwords sso (#9861)
* Structures and types updates for account-portal-no-passwords-sso * lint
This commit is contained in:
parent
76b6c97084
commit
699c21a042
|
@ -8,6 +8,8 @@ import {
|
|||
CloudAccount,
|
||||
Hosting,
|
||||
SSOAccount,
|
||||
CreateAccount,
|
||||
CreatePassswordAccount,
|
||||
} from "@budibase/types"
|
||||
import _ from "lodash"
|
||||
|
||||
|
@ -29,6 +31,10 @@ export const account = (): Account => {
|
|||
}
|
||||
}
|
||||
|
||||
export function selfHostAccount() {
|
||||
return account()
|
||||
}
|
||||
|
||||
export const cloudAccount = (): CloudAccount => {
|
||||
return {
|
||||
...account(),
|
||||
|
@ -47,9 +53,9 @@ function provider(): AccountSSOProvider {
|
|||
return _.sample(Object.values(AccountSSOProvider)) as AccountSSOProvider
|
||||
}
|
||||
|
||||
export function ssoAccount(): SSOAccount {
|
||||
export function ssoAccount(account: Account = cloudAccount()): SSOAccount {
|
||||
return {
|
||||
...cloudAccount(),
|
||||
...account,
|
||||
authType: AuthType.SSO,
|
||||
oauth2: {
|
||||
accessToken: generator.string(),
|
||||
|
@ -61,3 +67,49 @@ export function ssoAccount(): SSOAccount {
|
|||
thirdPartyProfile: {},
|
||||
}
|
||||
}
|
||||
|
||||
export const cloudCreateAccount: CreatePassswordAccount = {
|
||||
email: "cloud@budibase.com",
|
||||
tenantId: "cloud",
|
||||
hosting: Hosting.CLOUD,
|
||||
authType: AuthType.PASSWORD,
|
||||
password: "Password123!",
|
||||
tenantName: "cloud",
|
||||
name: "Budi Armstrong",
|
||||
size: "10+",
|
||||
profession: "Software Engineer",
|
||||
}
|
||||
|
||||
export const cloudSSOCreateAccount: CreateAccount = {
|
||||
email: "cloud-sso@budibase.com",
|
||||
tenantId: "cloud-sso",
|
||||
hosting: Hosting.CLOUD,
|
||||
authType: AuthType.SSO,
|
||||
tenantName: "cloudsso",
|
||||
name: "Budi Armstrong",
|
||||
size: "10+",
|
||||
profession: "Software Engineer",
|
||||
}
|
||||
|
||||
export const selfCreateAccount: CreatePassswordAccount = {
|
||||
email: "self@budibase.com",
|
||||
tenantId: "self",
|
||||
hosting: Hosting.SELF,
|
||||
authType: AuthType.PASSWORD,
|
||||
password: "Password123!",
|
||||
tenantName: "self",
|
||||
name: "Budi Armstrong",
|
||||
size: "10+",
|
||||
profession: "Software Engineer",
|
||||
}
|
||||
|
||||
export const selfSSOCreateAccount: CreateAccount = {
|
||||
email: "self-sso@budibase.com",
|
||||
tenantId: "self-sso",
|
||||
hosting: Hosting.SELF,
|
||||
authType: AuthType.SSO,
|
||||
tenantName: "selfsso",
|
||||
name: "Budi Armstrong",
|
||||
size: "10+",
|
||||
profession: "Software Engineer",
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import {
|
||||
GoogleInnerConfig,
|
||||
JwtClaims,
|
||||
OAuth2,
|
||||
OIDCInnerConfig,
|
||||
OIDCWellKnownConfig,
|
||||
SSOAuthDetails,
|
||||
|
@ -14,6 +15,13 @@ import * as shared from "./shared"
|
|||
import _ from "lodash"
|
||||
import { user } from "./shared"
|
||||
|
||||
export function OAuth(): OAuth2 {
|
||||
return {
|
||||
refreshToken: generator.string(),
|
||||
accessToken: generator.string(),
|
||||
}
|
||||
}
|
||||
|
||||
export function authDetails(userDoc?: User): SSOAuthDetails {
|
||||
if (!userDoc) {
|
||||
userDoc = user()
|
||||
|
@ -28,10 +36,7 @@ export function authDetails(userDoc?: User): SSOAuthDetails {
|
|||
|
||||
return {
|
||||
email: userDoc.email,
|
||||
oauth2: {
|
||||
refreshToken: generator.string(),
|
||||
accessToken: generator.string(),
|
||||
},
|
||||
oauth2: OAuth(),
|
||||
profile,
|
||||
provider,
|
||||
providerType: providerType(),
|
||||
|
|
|
@ -48,13 +48,18 @@ export interface User extends Document {
|
|||
global: boolean
|
||||
}
|
||||
password?: string
|
||||
status?: string
|
||||
status?: UserStatus
|
||||
createdAt?: number // override the default createdAt behaviour - users sdk historically set this to Date.now()
|
||||
dayPassRecordedAt?: string
|
||||
userGroups?: string[]
|
||||
onboardedAt?: string
|
||||
}
|
||||
|
||||
export enum UserStatus {
|
||||
ACTIVE = "active",
|
||||
INACTIVE = "inactive",
|
||||
}
|
||||
|
||||
export interface UserRoles {
|
||||
[key: string]: string
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue