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

Feat: Make 5 minute cookie expiration for login process customizable #55

Closed
AsbDaryaee opened this issue Sep 21, 2024 · 6 comments
Closed
Labels
enhancement New feature or request

Comments

@AsbDaryaee
Copy link

AsbDaryaee commented Sep 21, 2024

Screenshot 2024-09-21 183434

Hi, I've been using nuxt-oidc-auth for a while and everything seems fine, but some users have trouble with authentication.
When user is done with authentication and redirects to the redirectUri, the error appears.

I Checked the console and the error below was there:

Screenshot 2024-09-21 185552

Also this message was in my terminal:
WARN [Vue Router warn]: No match found for location with path "/auth/oidc/login"

Can anyone help me figure it out and fix the problem?

@itpropro
Copy link
Owner

Can you first check if you have the most current version and if you use Nuxt SSR? There were some changes in route handling in the last few versions.
For further troubleshooting I would need your oidc nuxt config and .env (if applies) of course without secrets and other sensitive info.

@AsbDaryaee
Copy link
Author

I use v0.12.0 and Yes I do use SSR for my project.

And this is my config from nuxt.config.ts file:

  oidc: {
    defaultProvider: "oidc",
    providers: {
      oidc: {
        clientId: [Client ID],
        clientSecret: [Client Secret],
        redirectUri: "[Address]/auth/oidc/callback",
        scope: [
          "openid",
          "profile",
          "offline_access",
          "page_api",
        ],
        responseMode: "query",
        responseType: "code",
        authorizationUrl: "[address]/connect/authorize",
        tokenUrl: "[Address]/connect/token",
        userinfoUrl: "[Address]/connect/userinfo",
        logoutUrl: "[Address]/connect/endsession",
        pkce: true,
        tokenRequestType: "form-urlencoded",
        exposeAccessToken: true,
      },
    },
    middleware: {
      globalMiddlewareEnabled: false,
      customLoginPage: false,
    },
    session: {
      expirationCheck: true,
      automaticRefresh: true,
      maxAge: 3600 * 24 * 2, // 2 Days
    },
  },

@itpropro
Copy link
Owner

itpropro commented Sep 22, 2024

Please update to the most current version and verify, if the problems are still the same. Which oidc provider do you use, so I can check if I am able to reproduce?
If your OIDC provider doesn't support the state challenge, you can disable that. There are 3 significant settings provided in nuxt-oidc-auth for this:

Option Type Default Description
pkce boolean (optional) false Use PKCE (Proof Key for Code Exchange)
state boolean (optional) true Use state parameter with a random value. If state is not used, the nonce parameter is used to identify the flow.
nonce boolean (optional) false Use nonce parameter with a random value.

@AsbDaryaee
Copy link
Author

After updating to the latest version, I no longer receive reports about this issue. However, I was able to reproduce the error under specific conditions:
If a user takes a long time to log in (approximately 5 minutes), the cookie that library creates expires. When the user finally returns to the callback page, they encounter an error.
It seems that the library might occasionally fail to initialize correctly or handle the deletion of the old cookie, which leads to this error.

@itpropro
Copy link
Owner

After updating to the latest version, I no longer receive reports about this issue. However, I was able to reproduce the error under specific conditions: If a user takes a long time to log in (approximately 5 minutes), the cookie that library creates expires. When the user finally returns to the callback page, they encounter an error. It seems that the library might occasionally fail to initialize correctly or handle the deletion of the old cookie, which leads to this error.

Hi @AsbDaryaee,
this is currently by design, as 5 minutes should be more than enough to return to the callback page in case you are doing a registration etc..
This will be a configurable setting in one of the later version.

@AsbDaryaee
Copy link
Author

Thank you @itpropro

@itpropro itpropro added enhancement New feature or request and removed pending triage Triage in progress needs reproduction labels Oct 19, 2024
@itpropro itpropro changed the title "State mismatch" Error After Login Feat: Make 5 minute cookie expiration for login process customizable Oct 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants