MCPcopy
hub / github.com/FlowiseAI/Flowise / IdentityManager

Class IdentityManager

packages/server/src/IdentityManager.ts:39–549  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37
38const allSSOProviders = ['azure', 'google', 'auth0', 'github']
39export class IdentityManager {
40 private static instance: IdentityManager
41 private stripeManager?: StripeManager
42 licenseValid: boolean = false
43 permissions: Permissions
44 ssoProviderName: string = ''
45 currentInstancePlatform: Platform = Platform.OPEN_SOURCE
46 // create a map to store the sso provider name and the sso provider instance
47 ssoProviders: Map<string, SSOBase> = new Map()
48
49 public static async getInstance(): Promise<IdentityManager> {
50 if (!IdentityManager.instance) {
51 IdentityManager.instance = new IdentityManager()
52 await IdentityManager.instance.initialize()
53 }
54 return IdentityManager.instance
55 }
56
57 public async initialize() {
58 await this._validateLicenseKey()
59 this.permissions = new Permissions()
60 if (process.env.STRIPE_SECRET_KEY) {
61 this.stripeManager = await StripeManager.getInstance()
62 }
63 }
64
65 public getPlatformType = () => {
66 return this.currentInstancePlatform
67 }
68
69 public getPermissions = () => {
70 return this.permissions
71 }
72
73 public isEnterprise = () => {
74 return this.currentInstancePlatform === Platform.ENTERPRISE
75 }
76
77 public isCloud = () => {
78 return this.currentInstancePlatform === Platform.CLOUD
79 }
80
81 public isOpenSource = () => {
82 return this.currentInstancePlatform === Platform.OPEN_SOURCE
83 }
84
85 public isLicenseValid = () => {
86 return this.licenseValid
87 }
88
89 private _offlineVerifyLicense(licenseKey: string): any {
90 try {
91 const publicKey = fs.readFileSync(path.join(__dirname, '../', 'src/enterprise/license/public.pem'), 'utf8')
92 const decoded = jwt.verify(licenseKey, publicKey, {
93 algorithms: ['RS256']
94 })
95 return decoded
96 } catch (error) {

Callers

nothing calls this directly

Calls 9

_offlineVerifyLicenseMethod · 0.95
initializeEmptySSOMethod · 0.95
initializeSsoProviderMethod · 0.95
getRunningExpressAppFunction · 0.90
readOrganizationMethod · 0.80
parseMethod · 0.65
connectMethod · 0.45

Tested by

no test coverage detected