Closed Mahan-F closed 3 years ago
It should be possible to set the redirect URL based on some data from the incoming request by doing something like this. I realize this is really similar the answer in #308 and as far as I can see it should work from version 3.0.5 and up. Make sure you're actually using redirect_uri
, something different wouldn't work if I see these lines. I successfully implemented this solution in a Nest.js project.
app.get('/login',
(req, res, next) =>
passport.authenticate('azure-ad', {
extraAuthReqQueryParams: {
redirect_uri: `https://${req.headers.host}/login/callback`,
},
})(req, res, next)
);
Closing as #308 seems to resolve this issue. Please raise a new issue in our mono repo if the given solution isn't feasible for any of your use cases.
@nino-vrijman Hello, I am using this solution and do need to set redirect url at callback request ?
router.post( "/openid/return", (req, res, next) => { passport.authenticate("azuread-openidconnect", { response: res, // required failureRedirect: "/auth/reset", extraTokenReqQueryParams: { redirect_uri:
https://${req.headers.host}/openid/return, }, })(req, res, next); }, (req, res) => { res.status(200).redirect("/menu"); } );
I have already looked at #308 #487 and #498 and i cant seem to find a solution to use a dynamic redirectUrl.
I have setup my AAD application to support redirect URL for two different domains.
https://domainOne.com/auth/openid/return
https://domainTwo.com/auth/openid/return
Both these domains are pointing to the same server and same Node.js web application.
I need to be able to use the
req
(Express request object) to see theHost
byreq.get('Host')
and then from there change theredirectUrl
of passport accordingly so that users authenticating withdomainOne
are returned todomainOne.com
domain and the same fordomainTwo
users.Looking at the other issues I linked above, it seems like others are having the same issue but I didn't manage to find a solid working answers. Is this something that's possible?