-
Notifications
You must be signed in to change notification settings - Fork 19
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
Feature: SSO Migration - DESENG #408 #2333
Changes from all commits
f3db3c4
2db901d
11205ee
f71a408
46a428e
ae67c76
4182082
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,16 +67,10 @@ def flush(self): | |
db.session.flush() | ||
return self | ||
|
||
def add_to_session(self): | ||
"""Save and flush.""" | ||
return self.flush() | ||
|
||
def save(self): | ||
"""Save and commit.""" | ||
self._set_tenant_id() | ||
db.session.add(self) | ||
db.session.flush() | ||
db.session.commit() | ||
self.flush() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The first argument to a method of a class (called |
||
self.commit() | ||
|
||
def _set_tenant_id(self): | ||
# add tenant id to the model if the child model has tenant id column | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,12 +21,13 @@ def check_auth(**kwargs): | |
"""Check if user is authorized to perform action on the service.""" | ||
skip_tenant_check = current_app.config.get('IS_SINGLE_TENANT_ENVIRONMENT') | ||
user_from_context: UserContext = kwargs['user_context'] | ||
user_from_db = StaffUserModel.get_user_by_external_id(user_from_context.sub) | ||
token_roles = set(user_from_context.roles) | ||
permitted_roles = set(kwargs.get('one_of_roles', [])) | ||
has_valid_roles = token_roles & permitted_roles | ||
if has_valid_roles: | ||
if not skip_tenant_check: | ||
user_tenant_id = user_from_context.tenant_id | ||
user_tenant_id = user_from_db.tenant_id | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I understand correctly, you switched accessing the "current" user from app context to pulling that user from the DB. Was the former solution causing issues? |
||
_validate_tenant(kwargs.get('engagement_id'), user_tenant_id) | ||
return | ||
|
||
|
@@ -47,8 +48,8 @@ def _validate_tenant(eng_id, tenant_id): | |
return | ||
engagement_tenant_id = EngagementModel.find_tenant_id_by_id(eng_id) | ||
if engagement_tenant_id and str(tenant_id) != str(engagement_tenant_id): | ||
current_app.logger.debug(f'Aborting . Tenant Id on Engagement and user context Mismatch' | ||
f'engagement_tenant_id:{engagement_tenant_id} ' | ||
current_app.logger.debug(f'Aborting . Tenant Id on Engagement and user context Mismatch\n' | ||
f'engagement_tenant_id:{engagement_tenant_id}\n' | ||
f'tenant_id: {tenant_id}') | ||
|
||
abort(HTTPStatus.FORBIDDEN) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
# Keycloak auth endpoint | ||
REACT_APP_KEYCLOAK_URL=https://dev.loginproxy.gov.bc.ca/auth | ||
REACT_APP_KEYCLOAK_REALM=standard | ||
|
||
# Resource identifier for the Keycloak client | ||
REACT_APP_KEYCLOAK_CLIENT=modern-engagement-tools-4787 | ||
# Keycloak auth | ||
# Copy from 'GDX MET web (public)-installation-*.json' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice helpful notes to aid in gathering those env variables |
||
# https://bcgov.github.io/sso-requests | ||
REACT_APP_KEYCLOAK_URL= # auth-server-url | ||
REACT_APP_KEYCLOAK_REALM= # realm | ||
REACT_APP_KEYCLOAK_CLIENT= # resource | ||
|
||
# The role needed to be considered an admin | ||
# TODO: Allocate a dedicated role for this on SSO | ||
|
@@ -14,5 +15,10 @@ REACT_APP_API_URL=http://localhost:5000/api | |
|
||
# `analytics-api` endpoint | ||
REACT_APP_ANALYTICS_API_URL=http://localhost:5001/api | ||
|
||
# Default tenant to assign when signing in for the first time | ||
REACT_APP_DEFAULT_TENANT=eao | ||
REACT_APP_DEFAULT_TENANT=eao | ||
|
||
# Whether to skip certain auth checks. Should be false in production. | ||
# Must match the value set for IS_SINGLE_TENANT_ENVIRONMENT in the API. | ||
REACT_APP_IS_SINGLE_TENANT_ENVIRONMENT=false |
This file was deleted.
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.
Nice touch with the customizable path. Will be nice to have while we're in this transition period between auth providers.