auth-module
auth-module copied to clipboard
Saved original guarded route does not include query parameters
Version
module: 5.0.0 nuxt: 2.14.12
Nuxt configuration
mode:
- [X] universal
- [ ] spa
Nuxt configuration
auth: {
localStorage: true,
rewriteRedirects: true,
strategies: {
ping: {
scheme: 'oauth2',
endpoints: {
authorization: process.env.OAUTH_ISSUER + '/as/authorization.oauth2',
token: process.env.OAUTH_ISSUER + '/as/token.oauth2',
userInfo: process.env.OAUTH_ISSUER + '/idp/userinfo.openid',
logout: process.env.OAUTH_ISSUER + '/idp/startSLO.ping'
},
token: {
property: 'access_token',
type: 'Bearer',
maxAge: 1800
},
responseType: 'code',
grantType: 'authorization_code',
clientId: process.env.OAUTH_CLIENT_ID,
scope: ['openid', 'profile', 'email'],
codeChallengeMethod: 'S256',
autoLogout: true,
redirectUri: process.env.SITEMAP_URL + '/sso-callback'
}
},
redirect: {
login: '/login',
logout: '/logout',
callback: '/sso-callback',
home: '/'
}
Reproduction
:warning: without a minimal reproduction we won't be able to look into your issue
What is expected?
After login, user should be redirected back to the original URL including any query string parameters.
What is actually happening?
User is redirected to original URL without query string parameters
Steps to reproduce
- Add the authentication middleware to any page
- Navigate to the page with a query string parameter
- Login
Additional information
This is due to this code from auth.ts
only saving the route path or full path without the query
const from = this.options.fullPathRedirect ? this.ctx.route.fullPath : this.ctx.route.path
let to = this.options.redirect[name]
if (!to) {
return
}
// Apply rewrites
if (this.options.rewriteRedirects) {
if (name === 'login' && isRelativeURL(from) && !isSameURL(to, from)) {
this.$storage.setUniversal('redirect', from)
}
if (name === 'home') {
const redirect = this.$storage.getUniversal('redirect')
this.$storage.setUniversal('redirect', null)
if (isRelativeURL(redirect)) {
to = redirect
}
}
}
Checklist
- [ ] I have tested with the latest Nuxt version and the issue still occurs
- [X] I have tested with the latest module version and the issue still occurs
- [X] I have searched the issue tracker and this issue hasn't been reported yet
Steps to reproduce
What is expected?
What is actually happening?
Performance analysis?
i have the same problem.
nuxt.config.js
fullPathRedirect: true
begin input url: https://xxxxx/preview?id=1
after login url is changed,id=1 is disappeared. https://xxxxx/preview