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

Token Request Error in Safari #1474

Open
synapxe-siang13 opened this issue Oct 8, 2024 · 8 comments
Open

Token Request Error in Safari #1474

synapxe-siang13 opened this issue Oct 8, 2024 · 8 comments

Comments

@synapxe-siang13
Copy link

synapxe-siang13 commented Oct 8, 2024

Issue and Steps to Reproduce

Random error when using Safari browser to try the https://black-rock-0dc6b0d03.1.azurestaticapps.net/profile-secure-component

Step to produce

  1. Go to https://black-rock-0dc6b0d03.1.azurestaticapps.net/profile-secure-component
  2. Enter login info
  3. If login is successful, logout again and repeat steps 1 and 2.

Versions

7.22.32

Screenshots

Screenshot 2024-10-08 at 12 19 01 PM

Expected

No authentication error

Actual

Authentication error in service worker mode.

Additional Details

  • code_verifier is not replaced by the Service worker.
@baesslerpa
Copy link

@synapxe-siang13 did you manage to solve this issue?
I am having the exact same problem. The Error randomly occurs in Safari.
response from token route is { “error”: “invalid_grant”, “error_description”: “grant request is invalid” }
the server is logging PKCE verification failed.

We noticed an extra _default attached to the code verifier param which seems also been attached in @synapxe-siang13 request
code_verifier=CODE_VERIFIER_SECURED_BY_OIDC_SERVICE_WORKER_default_default

@synapxe-siang13
Copy link
Author

@baesslerpa not able to resolve.

@guillaume-chervet Can help to verify this issue?

@guillaume-chervet
Copy link
Contributor

Hi @synapxe-siang13 , do you have more details about your issue. For example your configuration and service worker configuration and some code?
Does it happen sometime or everytime?

@synapxe-siang13
Copy link
Author

@guillaume-chervet Hi, the issue happened randomly in Safari. From what I have observed, this issue does not occur in Chrome. You may verify this issue with https://black-rock-0dc6b0d03.1.azurestaticapps.net/profile-secure-component, I tested with the above demo URL, this issue happened as well. But I am not sure the configuration with your demo URL.

@baesslerpa
Copy link

baesslerpa commented Nov 4, 2024

function App() {
  const config: OidcConfiguration = {
    client_id: import.meta.env.VITE_CLIENT_ID,
    redirect_uri: import.meta.env.VITE_REDIRECT_URI,
    silent_redirect_uri: import.meta.env.VITE_SILENT_REDIRECT_URI,
    scope: "openid profile email ecapi offline_access",
    authority: import.meta.env.VITE_AUTHORITY,
    demonstrating_proof_of_possession: false,
    service_worker_relative_url: `/OidcServiceWorker.js?v=${axaPackage.version}`,
    service_worker_only: false,
  };
  return (
    <>
      <HelmetProvider>
        <OidcProvider
          configuration={config}>
          <RouterProvider router={router} />
        </OidcProvider>
      </HelmetProvider>
    </>
  );
}

Service worker files are not modified

    "postinstall": "node ./node_modules/@axa-fr/react-oidc/bin/copy-service-worker-files.mjs ./public",

this is the configuration we are running.
as @synapxe-siang13 mentioned the error appears randomly in Safari (Mac and IOS) but appears like every second or third try.

@baesslerpa
Copy link

function PageError() {
  // show loader while ios bug is not fixed
  useEffect(() => {
    setTimeout(() => {
      console.log("navigating to root");
      window.location.href = "/";
    }, 1000);
  }, []);

  return (
    <div className="w-screen h-screen flex items-center justify-center flex-col">
      <Spinner />
    </div>
  );
}

this works as a temporary fix

@guillaume-chervet
Copy link
Contributor

I have missed the message with the extra default @baesslerpa @synapxe-siang13 , i have may be an idea . I will take a look next week.
Your safari is on mobile or desktop ?

@baesslerpa
Copy link

@guillaume-chervet happens on both platforms, I even had this bug once on chromium based browser (Arc)

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

No branches or pull requests

3 participants