-
Notifications
You must be signed in to change notification settings - Fork 6
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
Adding oauthn #655
Adding oauthn #655
Conversation
671b390
to
6bb482a
Compare
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.
Looks mostly right, we'll talk tomorrow about how it's been going
edaa4f5
to
3a6db83
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #655 +/- ##
==========================================
+ Coverage 92.56% 93.12% +0.56%
==========================================
Files 35 36 +1
Lines 1654 1862 +208
==========================================
+ Hits 1531 1734 +203
- Misses 123 128 +5 ☔ View full report in Codecov by Sentry. |
This commit refactors the authentication process in the Blueapi RestClient and service. It removes the explicit specification of the authentication type and instead uses the default authentication type. Additionally, it adds logic to handle token verification and refreshing in the RestClient. The service code is also updated to use the PKCE authentication type.
b4d7c26
to
be76510
Compare
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.
Bunch of little nits because I am a bad person
tests/unit_tests/client/test_rest.py
Outdated
with open(tmp_path / "token", "w") as token_file: | ||
# base64 encoded token | ||
token_file.write( | ||
base64.b64encode( | ||
b'{"access_token":"token","refresh_token":"refresh_token"}' | ||
).decode("utf-8") | ||
) |
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.
These parts of this ficture really want to be seperated so we can test with auth and with requiring login and with auth and already logged in.
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.
Mostly just nits, but if you don't do them I'll go back and change them later
This reverts commit d553095.
Reverts #655 Will be merged after build is fixed
This pull request introduces a new authentication mechanism using OAuth2 and JWT tokens, along with various related changes across multiple files to integrate this functionality.
Authentication Integration:
Authentication
andAuthenticationType
classes to handle OAuth2 device flow and PKCE authentication, including methods for token management (src/blueapi/service/authentication.py
).main.py
to include OAuth2 authorization code flow and token validation using the newAuthentication
class (src/blueapi/service/main.py
).CLI Enhancements:
login
command to the CLI to initiate the device flow authentication (src/blueapi/cli/cli.py
).REST Client Updates:
src/blueapi/client/rest.py
).Dependency Additions:
PyJWT
andpython-multipart
to the project dependencies (pyproject.toml
).Alternative to the authentication were investigated:-
Client Libraries
In the end I decided to not use them as we just need to make 2 requests and there is not that much error handling required as well ... We can look into integrating on of the above mentioned alternatives for the OAuth device flow integration.
For the PKCE Flow I have used the FastAPI support to implement the OAuth2