-
Notifications
You must be signed in to change notification settings - Fork 0
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
[REF] Manually verify ID token using PyJWT instead of google_auth #139
Conversation
Reviewer's Guide by SourceryThis PR replaces Google authentication with PyJWT for ID token verification, transitioning from Google Auth to Auth0 as the identity provider. The implementation involves manual verification of ID tokens using PyJWT library, which provides more direct control over the token verification process. The changes primarily affect the security module, with updates to token verification logic, test cases, and dependencies. Sequence diagram for ID token verification processsequenceDiagram
participant Client
participant Server
participant Auth0
Client->>Server: Send request with ID token
Server->>Auth0: Fetch public keys from JWKS endpoint
Auth0-->>Server: Return public keys
Server->>Server: Extract token from authorization header
Server->>Server: Verify token using PyJWT
Server-->>Client: Return response based on token validity
Updated class diagram for security moduleclassDiagram
class Security {
+check_client_id()
+extract_token(token: str) str
+verify_token(token: str) str
}
class PyJWKClient {
+get_signing_key_from_jwt(jwt: str)
}
class PyJWTError
Security --> PyJWKClient
Security --> PyJWTError
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #139 +/- ##
==========================================
+ Coverage 97.13% 97.17% +0.04%
==========================================
Files 23 23
Lines 697 707 +10
==========================================
+ Hits 677 687 +10
Misses 20 20 ☔ View full report in Codecov by Sentry. |
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.
Hey @alyssadai - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 2 issues found
- 🟡 Security: 1 issue found
- 🟡 Testing: 3 issues found
- 🟡 Complexity: 1 issue found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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.
This looks good @alyssadai, thanks a lot! Two points:
- Unless I missed it, we don't seem to have a "happy path" test for token validation. I.e. "I provide a valid token and don't get an error from the validation function". I think it'd be good to add such a test by mocking out the 3rd party pyJWT validation method, just to make sure that our code is happy if pyJWT is happy
- mildly in favour of the caching idea the bot suggests. But I belive that cache wouldn't carry over to our tests. Not sure if we want our tests to fail if the network requests for the certificates fail.
Take a look, and 🧑🍳
neurobagel/query-tool#380 is merged, @alyssadai you can merge this too |
🚀 PR was released in |
Changes proposed in this pull request:
Checklist
This section is for the PR reviewer
[ENH]
,[FIX]
,[REF]
,[TST]
,[CI]
,[MNT]
,[INF]
,[MODEL]
,[DOC]
) (see our Contributing Guidelines for more info)skip-release
(to be applied by maintainers only)Closes #XXXX
For new features:
For bug fixes:
Summary by Sourcery
Replace the Google authentication library with PyJWT for manual ID token verification, enhancing the security module. Update the project dependencies to include PyJWT and cryptography.
Enhancements:
Build:
Summary by Sourcery
Switch to using PyJWT for manual ID token verification, replacing the google_auth library, and update dependencies to include PyJWT and cryptography.
Enhancements:
Build: