Allow setting the additionalParams in .authenticate
See original GitHub issueI need to send in the RelayState when asking to login. This relay state is different for each user so I need it to be set when the user requests /login (and then .authenticate()) as opposed to when I start my server and setup passport.use(
.
Basically I would like to:
app.get('/login',
passport.authenticate(config.passport.strategy,
{
additionalParams: {'RelayState': req.url},
failureRedirect: '/loginFail'
})
);
Obviously even the above wouldn’t work since I don’t have access to the req
variable. Perhaps there’s a better way to simply have the user return to the page they were asking for.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:4
- Comments:9
Top Results From Across the Web
Allow setting the additionalParams in .authenticate · Issue #157
Basically I would like to: app.get('/login', passport.authenticate(config.passport.strategy, { additionalParams: {'RelayState': req.url} ...
Read more >How to pass an additional parameter to passport.authenticate
In my case, due to the authentication flow, to set up a variable in req was not working. The second option, set passReqToCallBack:...
Read more >Pass Parameters to Identity Providers - Auth0
You can pass provider-specific parameters to an Identity Provider (IdP) during authentication. The values can either be static per connection or dynamic per ......
Read more >Pass an additional parameter with spring security login page
The simple and easiest option to pass an additional parameter with Spring Security login page is to create a custom filter by extending...
Read more >passport-saml
SAML 2.0 authentication strategy for Passport. ... Additional SAML behaviors; additionalParams : dictionary of additional query params to add to all ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Pro tip: You can wrap the
passport.auhenticate
call inside your own middleware function so you can access the request and response if needed:I got the same problem, that is, not able to pass
additionalParams
in the second argument topassport.authenticate()
. And eventually found the following solution. Note that I am using TypeScript.TypeScript checks the 2nd argument against the
AuthenticateOptions
defined inpassport
, and it does not haveadditionalParams
, so there is a type error. Using theAuthenticateOptions
defined inpassport-saml
solves it. But for JavaScript, it does not have this type checking. So I think it should just work.