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 |
sam-holmes2
left a comment
There was a problem hiding this comment.
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! |
Fixes #905.
This PR aims to add an optional security layer by using a JWT check for
/repo,/user, and/pushAPI endpoints.If
jwtauth method is present,enabledin the proxy.config.json ANDJWT_SECRETenvironment variable is set:jwtConfiginproxy.config.json.clientID,authorityURL(and potentially, theexpectedAudience) provided in the configIf
jwtis notenabledORJWT_SECRETis 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:{ "type": "jwt", "enabled": true, "jwtConfig": { "clientID": "1009968223893-u92qq6itk7ej5008o4174gjubs5lhorg.apps.googleusercontent.com", "authorityURL": "https://accounts.google.com" } }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
codeas a query parameter:AUTHORIZATION_CODEbelow 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 typeBearerand 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