MCPcopy Create free account
hub / github.com/FlowiseAI/Flowise / initialize

Method initialize

packages/server/src/enterprise/sso/Auth0SSO.ts:95–137  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

93 }
94
95 initialize() {
96 this.setSSOConfig(this.ssoConfig)
97
98 this.app.get(Auth0SSO.LOGIN_URI, (req, res, next?) => {
99 if (!this.getSSOConfig()) {
100 return res.status(400).json({ error: 'Auth0 SSO is not configured.' })
101 }
102 passport.authenticate('auth0', {
103 scope: 'openid profile email' // Request scopes for profile and email information
104 })(req, res, next)
105 })
106
107 this.app.get(Auth0SSO.CALLBACK_URI, (req, res, next?) => {
108 if (!this.getSSOConfig()) {
109 return res.status(400).json({ error: 'Auth0 SSO is not configured.' })
110 }
111 passport.authenticate('auth0', async (err: any, user: LoggedInUser) => {
112 try {
113 if (err || !user) {
114 if (err?.name == 'SSO_LOGIN_FAILED') {
115 const error = { message: err.message }
116 const signinUrl = `/signin?error=${encodeURIComponent(JSON.stringify(error))}`
117 return res.redirect(signinUrl)
118 }
119 return next ? next(err) : res.status(401).json(err)
120 }
121
122 req.session.regenerate((regenerateErr) => {
123 if (regenerateErr) {
124 return next ? next(regenerateErr) : res.status(500).json({ message: 'Session regeneration failed' })
125 }
126
127 req.login(user, { session: true }, async (error) => {
128 if (error) return next ? next(error) : res.status(401).json(error)
129 return setTokenOrCookies(res, user, true, req, true, true)
130 })
131 })
132 } catch (error) {
133 return next ? next(error) : res.status(401).json(error)
134 }
135 })(req, res, next)
136 })
137 }
138
139 static async testSetup(ssoConfig: any) {
140 const { domain, clientID, clientSecret } = ssoConfig

Callers 5

initializeSsoProviderMethod · 0.95
runMethod · 0.45
prepareDataMethod · 0.45
authorizeCustomMcpServerFunction · 0.45

Calls 5

setSSOConfigMethod · 0.95
setTokenOrCookiesFunction · 0.90
stringifyMethod · 0.80
loginMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected