auth0 / auth0-vue

Auth0 authentication SDK for Vue.js apps
Other
140 stars 27 forks source link

Incorrectly redirecting when both code and state search params are set #326

Closed Petri-Oosthuizen closed 12 months ago

Petri-Oosthuizen commented 12 months ago

Checklist

Description

The auth0-vue plugin redirects when both code and state are specified as URL search parameters.

I have another callback URL using those parameters which has nothing to do with auth0.

Reproduction

Please find a working reproduction here: codesandbox.

Keep an eye on the URL while clicking on the following links in the sandbox:

  1. Navigate to /example?code=a -> the URL is changed correctly
  2. Navigate to /example?state=r -> the URL is changed correctly
  3. Navigate to /example?code=a&state=r -> redirects to "/"

Additional context

No response

auth0-vue version

2.3.2

Vue version

3.3.9

Which browsers have you tested in?

Chrome, Firefox

frederikprijck commented 12 months ago

Thanks for reaching out, you can set skipRedirectCallback: window.location.pathname === '/other-callback' to ensure we do not read the param in certain scenarios.

More info here: https://auth0.github.io/auth0-vue/interfaces/Auth0PluginOptions.html#skipRedirectCallback

Closing, let me know if that wouldnt work and we can reopen as needed.

Petri-Oosthuizen commented 12 months ago

Thank you. Out of curiosity, why is this behaviour opt-out and not opt-in?

frederikprijck commented 12 months ago

Because it was added in a non breaking way based on feedback like your scenario, initially we handled every request.

Petri-Oosthuizen commented 12 months ago

Ok thank you. Just as an aside, the documentation you linked to is incorrect with the usage:

createAuth0({
  skipRedirectCallback: window.location.pathname === '/other-callback' // <- not a clientOption
})

it should instead be:

  createAuth0(
    {
      ...
    },
    {
      skipRedirectCallback: window.location.pathname === "/other-callback", <- a plugin option
    },
  );
frederikprijck commented 12 months ago

Thanks, fixed in https://github.com/auth0/auth0-vue/pull/327