Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OAuth2 URL may already contain query parameters #1831

Open
1 of 5 tasks
ekkekuru2 opened this issue Feb 21, 2023 · 2 comments
Open
1 of 5 tasks

OAuth2 URL may already contain query parameters #1831

ekkekuru2 opened this issue Feb 21, 2023 · 2 comments
Labels

Comments

@ekkekuru2
Copy link

Version

module: 5.0.0-1667386184.dfbbb54
nuxt: 2.15.8

Nuxt configuration

mode:

  • universal
  • spa

Nuxt configuration

auth: {
  redirect: {
    login: '/login',
    logout: '/',
    callback: '/callback',
    home: '/',
  },
  strategies: {
    azureadb2c: {
      scheme: 'openIDConnect',
      clientId: '<MyClientID>',
      endpoints: {
        configuration:
          'https://<MyTenantName>.b2clogin.com/<MyTenantName>.onmicrosoft.com/v2.0/.well-known/openid-configuration?p=<MyFlowName>',
      },
    },
  },
},

Reproduction

What is expected?

In some cases, authorization endpoint URL already contains query parameters. (e.g Azure AD B2C specifies "user flow name" by using query parameters)
If OAuth2 authorization endpoint URL contains '?' (=already has query params), this module should join options generated by this module to given URL with '&' ,not '?'.

const url = this.options.endpoints.authorization + '?' + encodeQuery(opts)

What is actually happening?

Redirect to authorization endpoint fails because authorization URL is like this↓

https://example.com/oauth2/authorize ? given_param=something ? param_generated_by_this_module=something&other_param=...

"?" appears twice

Steps to reproduce

Set up Azure AD B2C and write configuration above

,or just specify authorization endpoint with some query parameters

auth: {
  strategies: {
    social: {
      scheme: 'oauth2',
      endpoints: {
        authorization: 'https://accounts.google.com/o/oauth2/auth?someparameters=...',
        ...

Additional information

Checklist

  • I have tested with the latest Nuxt version and the issue still occurs
  • I have tested with the latest module version and the issue still occurs
  • I have searched the issue tracker and this issue hasn't been reported yet
@jmsfilipe
Copy link

I'm also facing this issue - did you find a workaround?

@ekkekuru2
Copy link
Author

I submitted Pull Request about this issue before.

This PR is not merged yet, but I apply this change to my app by using patch-package (https://www.npmjs.com/package/patch-package)

I hope this will help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants