Open
Conversation
ChrOertlin
commented
Feb 6, 2025
ChrOertlin
commented
Feb 6, 2025
… into feat-keycloak
|
Vince-janv
reviewed
May 13, 2025
Comment on lines
+45
to
+47
| self.keycloak_client: KeycloakClient = keycloak_client | ||
| self.keycloak_backend_user = config["trailblazer"]["keycloak_backend_user"] | ||
| self.keycloak_backend_user_password = config["trailblazer"][ |
Member
Vince-janv
reviewed
May 13, 2025
Comment on lines
+129
to
+130
| keycloak_backend_user: str | ||
| keycloak_backend_user_password: str |
Member
There was a problem hiding this comment.
Remove and use client_secret_key instead
Vince-janv
reviewed
May 13, 2025
Comment on lines
+56
to
+65
| def check_role(roles: list[str]) -> None: | ||
| """Check the user roles. | ||
| Currently set to a single permissable role, expand if needed. | ||
| Args: | ||
| roles (list[str]): The user roles received from the RealmAccess. | ||
| Raises: | ||
| UserRoleError: if required role not present | ||
| """ | ||
| if not "cg-employee" in roles: | ||
| raise UserRoleError("The user does not have the required role to access this service.") |
Member
There was a problem hiding this comment.
Good implementation. Will depend on how our user groups are set-up. Likely to change in some degree
Vince-janv
reviewed
May 13, 2025
| if code: | ||
| token = keycloak_client.get_token_by_authorisation_code(code) | ||
| parsed_token = TokenResponseModel(**token) | ||
| LOG.info(f"access_token: {parsed_token.access_token}") |
Member
There was a problem hiding this comment.
remove logging the access token
Vince-janv
reviewed
May 13, 2025
Comment on lines
+25
to
+26
|
|
||
| LOG = logging.getLogger(__name__) |
Member
There was a problem hiding this comment.
unsure why the logging is needed
Vince-janv
reviewed
May 13, 2025
Comment on lines
+49
to
+50
| keycloak_backend_user: str = "user" | ||
| keycloak_backend_user_password: str = "password" |
Vince-janv
reviewed
May 15, 2025
Comment on lines
-31
to
-37
| if not logged_in(): | ||
| return redirect(url_for("admin.index")) | ||
|
|
||
|
|
||
| def logged_in(): | ||
| user = db.get_user_by_email(email=session.get("user_email")) | ||
| return google.authorized and user and user.is_admin |
Member
There was a problem hiding this comment.
For phase one we could keep the database check and start relying on roles in phase 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Description
Implements keycloak as authirsation and verification provider for CG
Added
AuthenticationService
Handles logic pertaining to authentication and token verification of users
UserService
handles fetching of users from the database - introduced to reduce coupling of database to endpoints
New endpoints:
auth/login
auth/callback
auth/logout
New config settings in the Flask AppConfig to initiate the authentication service
Changed
Moved app.route("/") to its own blueprint to cleanup the _register_blueprint() function. Increased code clarity
Removed google oauth flow from front end
Fixed
closes: #4159
How to prepare for test
uspaxaHow to test
Expected test outcome
Review
Thanks for filling in who performed the code review and the test!
This version is a
Implementation Plan