Thinkmill / Thinkmill/keystatic

allow explicitly providing redirect_uri for github sign in

Open
#1,022 6 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
TypeScript
Stars
2.4k
Forks
159
Avg merge
21h 41m
Merged PRs (30d)
2

Description

when trying to deploy keystatic on our infrastructure, i am running into an issue with the redirect_uri setting for github sign in.

the callback uri in the github app is configured to use the /api/keystatic/github/oauth/callback route on the domain the app is deployed to, however the redirect_uri actually used by keystatic is using a hostname internal to our cluster infra. (in our case, the correct hostname would be only on x-forwarded-host header)

which means i cannot sign in, but instead see this error:

An error occurred when trying to authenticate with GitHub:
The redirect_uri MUST match the registered callback URL for this application.

the redirect_uri query param is constructed here by keystatic:

https://github.com/Thinkmill/keystatic/blob/bcc3c69638c3affd758215289f572ac22afadfa5/packages/keystatic/src/api/generic.ts#L375-L378

allowing to set the redirect url explicitly via environment variable would work around this issue i think.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in packages/keystatic/src/api/generic.ts at the redirect_uri construction around lines 375-378, and trace how the GitHub OAuth configuration is read. Add an explicit configuration path for the deployment-provided callback URL, then verify that sign-in sends the configured public URL instead of the internal hostname.

Written by the indexing model from the issue text.

Assessment

Tech stack
github, typescript
Domain
authentication
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.