-
Notifications
You must be signed in to change notification settings - Fork 136
feat(auth): Add JWT auth for API routes #967
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
feat(auth): Add JWT auth for API routes #967
Conversation
✅ Deploy Preview for endearing-brigadeiros-63f9d0 canceled.
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #967 +/- ##
==========================================
- Coverage 49.14% 48.70% -0.44%
==========================================
Files 52 53 +1
Lines 2110 2166 +56
Branches 241 242 +1
==========================================
+ Hits 1037 1055 +18
- Misses 1036 1074 +38
Partials 37 37 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Free license according to FSF (https://www.gnu.org/licenses/license-list.html#SILOFL)
Seems there's an issue with the licenses in the
Here's an explanation on why the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great contribution, thanks! Left a few minor comments, main concern is the initial hardcoded client ID and secret. Also believe a lot of these changes have already been approved / merged from your other PRs so may be some conflicts to resolve
Pinging @JamieSlome for thoughts on this and #963 (which is the parent branch). Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 🍰
Fixes #905.
This PR aims to add an optional security layer by using a JWT check for
/repo
,/user
, and/push
API endpoints.If
jwt
auth method is present,enabled
in the proxy.config.json ANDJWT_SECRET
environment variable is set:jwtConfig
inproxy.config.json
.clientID
,authorityURL
(and potentially, theexpectedAudience
) provided in the configIf
jwt
is notenabled
ORJWT_SECRET
is not present, it works as it used to.To activate the JWT check, you must fill in the JWT details in
proxy.config.json
. The following will let you verify against my Google OIDC testing app:You can manually generate a sample JWT by following these steps:
code
:Upon successful login, it will redirect to a URL that contains an authorization
code
as a query parameter:AUTHORIZATION_CODE
below with the code obtained in 1):Note that the generated JWT has a 1-hour expiry date.
id_token
, which starts withey
. If using Postman, this can be tested by adding an Auth header of typeBearer
and pasting the token:If successful, submitting that request will return the list of repos. If there is a problem with either the JWT setup, or the token validity, it will throw an error like this:
Note: Although my Google app secrets are exposed, only registered emails can use them. Let me know if you'd like to test it out, and I can add your email to the app!
Changelog