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,
|
CloudAccount,
|
||||||
Hosting,
|
Hosting,
|
||||||
SSOAccount,
|
SSOAccount,
|
||||||
|
CreateAccount,
|
||||||
|
CreatePassswordAccount,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import _ from "lodash"
|
import _ from "lodash"
|
||||||
|
|
||||||
|
@ -29,6 +31,10 @@ export const account = (): Account => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function selfHostAccount() {
|
||||||
|
return account()
|
||||||
|
}
|
||||||
|
|
||||||
export const cloudAccount = (): CloudAccount => {
|
export const cloudAccount = (): CloudAccount => {
|
||||||
return {
|
return {
|
||||||
...account(),
|
...account(),
|
||||||
|
@ -47,9 +53,9 @@ function provider(): AccountSSOProvider {
|
||||||
return _.sample(Object.values(AccountSSOProvider)) as AccountSSOProvider
|
return _.sample(Object.values(AccountSSOProvider)) as AccountSSOProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ssoAccount(): SSOAccount {
|
export function ssoAccount(account: Account = cloudAccount()): SSOAccount {
|
||||||
return {
|
return {
|
||||||
...cloudAccount(),
|
...account,
|
||||||
authType: AuthType.SSO,
|
authType: AuthType.SSO,
|
||||||
oauth2: {
|
oauth2: {
|
||||||
accessToken: generator.string(),
|
accessToken: generator.string(),
|
||||||
|
@ -61,3 +67,49 @@ export function ssoAccount(): SSOAccount {
|
||||||
thirdPartyProfile: {},
|
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 {
|
import {
|
||||||
GoogleInnerConfig,
|
GoogleInnerConfig,
|
||||||
JwtClaims,
|
JwtClaims,
|
||||||
|
OAuth2,
|
||||||
OIDCInnerConfig,
|
OIDCInnerConfig,
|
||||||
OIDCWellKnownConfig,
|
OIDCWellKnownConfig,
|
||||||
SSOAuthDetails,
|
SSOAuthDetails,
|
||||||
|
@ -14,6 +15,13 @@ import * as shared from "./shared"
|
||||||
import _ from "lodash"
|
import _ from "lodash"
|
||||||
import { user } from "./shared"
|
import { user } from "./shared"
|
||||||
|
|
||||||
|
export function OAuth(): OAuth2 {
|
||||||
|
return {
|
||||||
|
refreshToken: generator.string(),
|
||||||
|
accessToken: generator.string(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function authDetails(userDoc?: User): SSOAuthDetails {
|
export function authDetails(userDoc?: User): SSOAuthDetails {
|
||||||
if (!userDoc) {
|
if (!userDoc) {
|
||||||
userDoc = user()
|
userDoc = user()
|
||||||
|
@ -28,10 +36,7 @@ export function authDetails(userDoc?: User): SSOAuthDetails {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
email: userDoc.email,
|
email: userDoc.email,
|
||||||
oauth2: {
|
oauth2: OAuth(),
|
||||||
refreshToken: generator.string(),
|
|
||||||
accessToken: generator.string(),
|
|
||||||
},
|
|
||||||
profile,
|
profile,
|
||||||
provider,
|
provider,
|
||||||
providerType: providerType(),
|
providerType: providerType(),
|
||||||
|
|
|
@ -48,13 +48,18 @@ export interface User extends Document {
|
||||||
global: boolean
|
global: boolean
|
||||||
}
|
}
|
||||||
password?: string
|
password?: string
|
||||||
status?: string
|
status?: UserStatus
|
||||||
createdAt?: number // override the default createdAt behaviour - users sdk historically set this to Date.now()
|
createdAt?: number // override the default createdAt behaviour - users sdk historically set this to Date.now()
|
||||||
dayPassRecordedAt?: string
|
dayPassRecordedAt?: string
|
||||||
userGroups?: string[]
|
userGroups?: string[]
|
||||||
onboardedAt?: string
|
onboardedAt?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum UserStatus {
|
||||||
|
ACTIVE = "active",
|
||||||
|
INACTIVE = "inactive",
|
||||||
|
}
|
||||||
|
|
||||||
export interface UserRoles {
|
export interface UserRoles {
|
||||||
[key: string]: string
|
[key: string]: string
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue