application doesn't authenticate correctly
Hey @n4bb12, thanks for creating this neat utility. I have currently configured this to work with my docusaurus site, but I get this error.
Here is my config
Can you please help me out here? TIA!
What's your vercel-github-oauth-proxy version and your config.githubOrgName?
The version is "vercel-github-oauth-proxy": "^1.2.3" and config.githubOrgName: github.iu.edu
GitHub enterprise is not supported yet. But you're welcome to create a PR.
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?
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.
@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',
Could you update to the latest version and share the details of the error that's logged on the server?
I upgraded to 1.2.6. Here are the logs,
I can't do much with that, the messages are cut off 😅
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"
}
]
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?
Did you initiate the flow from https://deven-phd-notes.vercel.app?
Yes