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

application doesn't authenticate correctly #1

Open
deven367 opened this issue Sep 19, 2023 · 12 comments
Open

application doesn't authenticate correctly #1

deven367 opened this issue Sep 19, 2023 · 12 comments

Comments

@deven367
Copy link

Hey @n4bb12, thanks for creating this neat utility. I have currently configured this to work with my docusaurus site, but I get this error.

image

Here is my config
image

Can you please help me out here? TIA!

@n4bb12
Copy link
Owner

n4bb12 commented Sep 19, 2023

What's your vercel-github-oauth-proxy version and your config.githubOrgName?

@deven367
Copy link
Author

deven367 commented Sep 19, 2023

The version is "vercel-github-oauth-proxy": "^1.2.3" and config.githubOrgName: github.iu.edu

@n4bb12
Copy link
Owner

n4bb12 commented Sep 20, 2023

GitHub enterprise is not supported yet. But you're welcome to create a PR.

@deven367
Copy link
Author

Ah, in that case, I might have a workaround for this, if I put my config.githubOrgName as github.com, would it work? Or I can just create a dummy org and add members to that org, so that oauth can work?

@n4bb12
Copy link
Owner

n4bb12 commented Sep 20, 2023

Or I can just create a dummy org and add members to that org, so that oauth can work?

Yes, if it's an org on github.com. The OAuth app, client credentals, etc also need to be created on github.com.

@deven367
Copy link
Author

@n4bb12 I tried the changing the org to a GitHub based org, but I still get the same error.
I have the org name set to 'githubOrgName': 'techfanatics',

@n4bb12
Copy link
Owner

n4bb12 commented Sep 20, 2023

Could you update to the latest version and share the details of the error that's logged on the server?

@deven367
Copy link
Author

I upgraded to 1.2.6. Here are the logs,

image

@n4bb12
Copy link
Owner

n4bb12 commented Sep 20, 2023

I can't do much with that, the messages are cut off 😅

@deven367
Copy link
Author

ah my bad,

{"level":30,"time":1695240732103,"pid":8,"hostname":"169.254.248.165","reqId":"req-3","req":{"method":"GET","url":"/oauth2/callback?state=%7B%22randomToken%22%3A%22YYnDQ-DSXBIn75T4RIYM7%22%2C%22path%22%3A%22%2F%22%7D.FTMjpm2IVbW0mR%2FvWAsMkGZJcgj6%2F7DfCNZAXxgGHKU&code=e1e5f198e57dac27aa6f","hostname":"deven-phd-notes.vercel.app","remoteAddress":"127.0.0.1","remotePort":41642},"msg":"incoming request"}
Error: State mismatch
    at retrieveState (/var/task/node_modules/vercel-github-oauth-proxy/dist/github-oauth.js:136:19)
    at Object.<anonymous> (/var/task/node_modules/vercel-github-oauth-proxy/dist/github-oauth.js:176:27)
    at hookIterator (/var/task/node_modules/fastify/lib/hooks.js:409:10)
    at next (/var/task/node_modules/fastify/lib/hooks.js:243:18)
    at hookRunner (/var/task/node_modules/fastify/lib/hooks.js:265:5)
    at handler (/var/task/node_modules/fastify/lib/handleRequest.js:68:7)
    at handleRequest (/var/task/node_modules/fastify/lib/handleRequest.js:24:5)
    at runPreParsing (/var/task/node_modules/fastify/lib/route.js:568:5)
    at next (/var/task/node_modules/fastify/lib/hooks.js:237:9)
    at Object.fastifyCookieHandler (/var/task/node_modules/@fastify/cookie/plugin.js:68:7)
{"level":30,"time":1695240732107,"pid":8,"hostname":"169.254.248.165","reqId":"req-3","res":{"statusCode":302},"responseTime":3.7812100000446662,"msg":"request completed"}
[
  {
    "level": 40,
    "time": 1695240731509,
    "pid": 8,
    "hostname": "169.254.248.165",
    "msg": "\"root\" path \"/var/task/build\" must exist"
  },
  {
    "level": 30,
    "time": 1695240731515,
    "pid": 8,
    "hostname": "169.254.248.165",
    "reqId": "req-1",
    "req": {
      "method": "GET",
      "url": "/",
      "hostname": "deven-phd-notes-4yvu29dzd-deven367.vercel.app",
      "remoteAddress": "127.0.0.1",
      "remotePort": 41626
    },
    "msg": "incoming request"
  },
  {
    "level": 30,
    "time": 1695240731531,
    "pid": 8,
    "hostname": "169.254.248.165",
    "reqId": "req-1",
    "res": {
      "statusCode": 302
    },
    "responseTime": 15.615247000008821,
    "msg": "request completed"
  }
]

@n4bb12
Copy link
Owner

n4bb12 commented Sep 20, 2023

Error: State mismatch

means the state cookie does not match the state URL parameter.

The only reason I can think of why this might happen is that you initiate sign-in from a different domain.

This is also supported by the two different hostnames I see in your logs:

  • deven-phd-notes.vercel.app
  • deven-phd-notes-4yvu29dzd-deven367.vercel.app

Did you initiate the flow from https://deven-phd-notes.vercel.app?

@deven367
Copy link
Author

Did you initiate the flow from https://deven-phd-notes.vercel.app?

Yes

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

2 participants