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

46 auth flow #48

Closed
wants to merge 17 commits into from
Closed

46 auth flow #48

wants to merge 17 commits into from

Conversation

alishaevn
Copy link
Contributor

@alishaevn alishaevn commented Feb 1, 2024

Story

Refs #issuenumber

Expected Behavior Before Changes

Expected Behavior After Changes

Screenshots / Video

Testing

  1. go to https://store.phenovista.com/browse (url points at store)
  2. click "sign in" (url points at store)
  3. allow access (throws OAUTH_CALLBACK_ERROR from below)

Notes

initial `OAUTH_CALLBACK_ERROR`
[next-auth][error][OAUTH_CALLBACK_ERROR] 
2024-02-01T22:56:06.679601169Z https://next-auth.js.org/errors#oauth_callback_error State cookie was missing. {
2024-02-01T22:56:06.679605473Z   error: TypeError: State cookie was missing.
2024-02-01T22:56:06.679609271Z       at Object.use (/home/node/app/node_modules/next-auth/core/lib/oauth/checks.js:103:23)
      at oAuthCallback (/home/node/app/node_modules/next-auth/core/lib/oauth/callback.js:89:25)
2024-02-01T22:56:06.679617221Z       at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
2024-02-01T22:56:06.679623279Z       at async Object.callback (/home/node/app/node_modules/next-auth/core/routes/callback.js:52:11)
      at async AuthHandler (/home/node/app/node_modules/next-auth/core/index.js:201:28)
2024-02-01T22:56:06.679632839Z       at async NextAuthHandler (/home/node/app/node_modules/next-auth/next/index.js:24:19)
      at async /home/node/app/node_modules/next-auth/next/index.js:60:32
2024-02-01T22:56:06.679640357Z       at async /home/node/app/node_modules/@sentry/nextjs/cjs/server/wrapApiHandlerWithSentry.js:144:33
2024-02-01T22:56:06.679643687Z       at async Object.apiResolver (/home/node/app/node_modules/next/dist/server/api-utils/node.js:366:9)
2024-02-01T22:56:06.679647291Z       at async NextNodeServer.runApi (/home/node/app/node_modules/next/dist/server/next-server.js:481:9) {
2024-02-01T22:56:06.679651951Z     name: 'OAuthCallbackError',
2024-02-01T22:56:06.679655769Z     code: undefined
2024-02-01T22:56:06.679659157Z   },
2024-02-01T22:56:06.679662531Z   providerId: 'phenovista',
2024-02-01T22:56:06.679666209Z   message: 'State cookie was missing.'
2024-02-01T22:56:06.679669621Z }
second `OAUTH_CALLBACK_ERROR`
[next-auth][error][OAUTH_CALLBACK_ERROR] 
2024-02-01T23:17:11.132096985Z https://next-auth.js.org/errors#oauth_callback_error state mismatch, expected EuXYivZXzE0UUhlMdOYniiVP-RsH3ussEgA8Cq-ODKE, got: Ypcr9p98W92lsO_wFuFl7EkJvb1FAG4AbNf7rXFUkGs {
  error: RPError: state mismatch, expected EuXYivZXzE0UUhlMdOYniiVP-RsH3ussEgA8Cq-ODKE, got: Ypcr9p98W92lsO_wFuFl7EkJvb1FAG4AbNf7rXFUkGs
2024-02-01T23:17:11.132105235Z       at Client.oauthCallback (/home/node/app/node_modules/openid-client/lib/client.js:532:13)
2024-02-01T23:17:11.132108985Z       at oAuthCallback (/home/node/app/node_modules/next-auth/core/lib/oauth/callback.js:111:29)
2024-02-01T23:17:11.132113172Z       at async Object.callback (/home/node/app/node_modules/next-auth/core/routes/callback.js:52:11)
2024-02-01T23:17:11.132116665Z       at async AuthHandler (/home/node/app/node_modules/next-auth/core/index.js:201:28)
      at async NextAuthHandler (/home/node/app/node_modules/next-auth/next/index.js:24:19)
2024-02-01T23:17:11.132123781Z       at async /home/node/app/node_modules/next-auth/next/index.js:60:32
2024-02-01T23:17:11.132127196Z       at async /home/node/app/node_modules/@sentry/nextjs/cjs/server/wrapApiHandlerWithSentry.js:144:33
2024-02-01T23:17:11.132130826Z       at async Object.apiResolver (/home/node/app/node_modules/next/dist/server/api-utils/node.js:366:9)
2024-02-01T23:17:11.132134504Z       at async NextNodeServer.runApi (/home/node/app/node_modules/next/dist/server/next-server.js:481:9)
2024-02-01T23:17:11.132137655Z       at async Object.fn (/home/node/app/node_modules/next/dist/server/next-server.js:735:37) {
    name: 'OAuthCallbackError',
2024-02-01T23:17:11.132145832Z     code: undefined
2024-02-01T23:17:11.132149121Z   },
2024-02-01T23:17:11.132152291Z   providerId: 'phenovista',
2024-02-01T23:17:11.132155847Z   message: 'state mismatch, expected EuXYivZXzE0UUhlMdOYniiVP-RsH3ussEgA8Cq-ODKE, got: Ypcr9p98W92lsO_wFuFl7EkJvb1FAG4AbNf7rXFUkGs'
}

this new variable will be necessary so that redirects happen properly
when the client is using their own domain, but pointing it to the
softserv.cloud instance.

- ref: #46
Copy link

vercel bot commented Feb 1, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
phenovista ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 7, 2024 4:11am

@alishaevn alishaevn linked an issue Feb 1, 2024 that may be closed by this pull request
@alishaevn alishaevn mentioned this pull request Feb 1, 2024
when this branch was deployed to staging, I received and internal server error
while trying to sign in. after allowing access, I was redirected back to
https://phenovista-staging.softserv.cloud/api/auth/error.

I found the initial code for `redirect` at
https://github.com/nextauthjs/next-auth/blob/main/packages/core/src/lib/init.ts#L38-L42.
I'm adding it in hopes to bypass the server error so I can continue testing on staging.
new error: "https://next-auth.js.org/errors#oauth_callback_error PKCE code_verifier cookie was missing. {  error: TypeError: PKCE code_verifier cookie was missing."

- ref: nextauthjs/next-auth#7491 (comment)
- I added a new domain to vercel to point at this branch preview url.
I'm adding test language to the browse page to confirm it works.
going to deploy this code to staging and see if I can force
it to redirect to vercel on redirect after signing in.
when starting at https://phenovista-staging.softserv.cloud/, I pressed "sign in"
and was taken to the sign in page. clicking "allow" redirected me to
https://phenovista-test.vercel.app/ as expected. however, I was not signed
in. going back to phenovista-staging showed I was signed in there though. 🤔
update the production `appBaseUrl` and `nextAuthUrl` variables
to point at pheno's domain instead of softservs. attempting to fix
the redirect still.
@alishaevn
Copy link
Contributor Author

closing in favor of #55. I wanted to keep the code for knowledge's sake.

@alishaevn alishaevn closed this Feb 7, 2024
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

Successfully merging this pull request may close these issues.

Authorization Flow Issues
1 participant