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

Support Github as authentication server #4

Closed
soofstad opened this issue Apr 22, 2022 · 6 comments · Fixed by #6
Closed

Support Github as authentication server #4

soofstad opened this issue Apr 22, 2022 · 6 comments · Fixed by #6
Assignees

Comments

@soofstad
Copy link
Owner

Changes that needs to be done:

  • Don't expect access_token to be a JWT
  • Use 'expires_in' from token response for checking expire time (not from JWT)
@soofstad soofstad assigned soofstad and unassigned soofstad Apr 22, 2022
@soofstad
Copy link
Owner Author

Will you have a look at this @eoaksnes?

@bonndan
Copy link

bonndan commented May 8, 2022

There seems to be an additional issue with GitHub: the request to get the access token is blocked (using the release code)

Access to fetch at 'https://github.com/login/oauth/access_token' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

See https://stackoverflow.com/questions/42150075/cors-issue-on-github-oauth isaacs/github#330

@eoaksnes
Copy link

eoaksnes commented May 9, 2022

I enable this in the backend code, allow_origins=[http://localhost, http://localhost:3000,....]

@soofstad
Copy link
Owner Author

soofstad commented May 9, 2022

So my understanding is that Github requires the "client_secret" in the token request. Which can't be added to the SPA web client. Therefore, you must setup your own backend API with the client_secret, that the web app can send the token request to.
The API will then request the token from github with the client_secret, and there should be no CORS error.

Do you have some sample code for endpoint for this backend API @eoaksnes?

@github-actions
Copy link

github-actions bot commented Jul 8, 2022

Stale issue message

@soofstad
Copy link
Owner Author

The latest commits to this PR; #6 adds support for auth via "Gihub OAuth Apps", which is a bit different than "Github Apps".

However they both require you to setup an API to forward the web client requests, with the added "client_secret", to the github API.
There is an example app here; examples/github-auth-provider.
I have tested it quite a bit. And see no further issues.

Let me know if you decide to test this alpha release and happen to find any issues @bonndan.

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 a pull request may close this issue.

3 participants