mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	Allow auth cookie name to be customised
This commit is contained in:
		| @@ -182,6 +182,10 @@ function genericStrategy(adminApp,strategy) { | ||||
|             maxAge: null, | ||||
|             ...settings.httpAdminCookieOptions | ||||
|         } | ||||
|         if (sessionOptions.cookie.name){ | ||||
|             sessionOptions.name = sessionOptions.cookie.name | ||||
|             delete sessionOptions.cookie.name | ||||
|         } | ||||
|     } | ||||
|     adminApp.use(session(sessionOptions)); | ||||
|     //TODO: all passport references ought to be in ./auth | ||||
| @@ -217,10 +221,10 @@ function genericStrategy(adminApp,strategy) { | ||||
|     adminApp.get('/auth/strategy', | ||||
|         passport.authenticate(strategy.name, { | ||||
|             session:false, | ||||
|             failureMessage: true, | ||||
|             failureRedirect: settings.httpAdminRoot + '?session_message=Login Failed' | ||||
|             failWithError: true, | ||||
|             failureMessage: true | ||||
|         }), | ||||
|         completeGenerateStrategyAuth, | ||||
|         completeGenericStrategyAuth, | ||||
|         handleStrategyError | ||||
|     ); | ||||
|  | ||||
| @@ -232,14 +236,14 @@ function genericStrategy(adminApp,strategy) { | ||||
|         passport.authenticate(strategy.name, { | ||||
|             session:false, | ||||
|             failureMessage: true, | ||||
|             failureRedirect: settings.httpAdminRoot + '?session_message=Login Failed' | ||||
|             failWithError: true | ||||
|         }), | ||||
|         completeGenerateStrategyAuth, | ||||
|         completeGenericStrategyAuth, | ||||
|         handleStrategyError | ||||
|     ); | ||||
|  | ||||
| } | ||||
| function completeGenerateStrategyAuth(req,res) { | ||||
| function completeGenericStrategyAuth(req,res) { | ||||
|     var tokens = req.user.tokens; | ||||
|     delete req.user.tokens; | ||||
|     // Successful authentication, redirect home. | ||||
| @@ -249,6 +253,8 @@ function handleStrategyError(err, req, res, next) { | ||||
|     if (res.headersSent) { | ||||
|         return next(err) | ||||
|     } | ||||
|     // Remove the header that passport auto-adds as we don't need it | ||||
|     res.removeHeader('WWW-Authenticate') | ||||
|     log.audit({event: "auth.login.fail.oauth",error:err.toString()}); | ||||
|     res.redirect(settings.httpAdminRoot + '?session_message='+err.toString()); | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user