Skip to content

Commit

Permalink
Fixes authentication to be configuration driven
Browse files Browse the repository at this point in the history
  • Loading branch information
elijahbenizzy committed May 3, 2024
1 parent 1c08fe2 commit d91e6b8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/hamilton-ui-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ jobs:
PGUSER: postgres
HAMILTON_BLOB_STORE: local
HAMILTON_LOCAL_BLOB_DIR: ./blob_data
HAMILTON_AUTH_MODE: integration_tests
run: |
cd ui/backend/server
python manage.py sqlcreate
Expand All @@ -78,6 +79,7 @@ jobs:
PGUSER: postgres
HAMILTON_BLOB_STORE: local
HAMILTON_LOCAL_BLOB_DIR: ./blob_data
HAMILTON_AUTH_MODE: integration_tests
run: |
cd ui/backend/server
python -m pytest tests/${{ matrix.testdir }} -vvvvv
8 changes: 4 additions & 4 deletions ui/backend/server/server/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
from trackingserver_run_tracking import api as run_tracking_api
from trackingserver_template import api as template_api

env = settings.HAMILTON_ENV
auth_mode = settings.HAMILTON_AUTH_MODE

if env == "local":
if auth_mode == "permissive":
api = NinjaAPI(auth=[LocalAPIAuthenticator()])
elif env == "integration_tests":
elif auth_mode == "integration_tests":
api = NinjaAPI(auth=[TestAPIAuthenticator()])
else:
elif auth_mode == "propelauth":
propel_auth_instance = propelauth.init()
api = NinjaAPI(
auth=[
Expand Down
4 changes: 4 additions & 0 deletions ui/backend/server/server/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ def get_from_env(

HAMILTON_ENV = get_from_env("HAMILTON_ENV", ["integration_tests", "local", "dev", "prod"])

HAMILTON_AUTH_MODE = get_from_env(
"HAMILTON_AUTH_MODE", ["permissive", "integration_tests", "propelauth"]
)

PROPEL_AUTH_API_KEY = get_from_env("PROPEL_AUTH_API_KEY", allow_missing=True)
PROPEL_AUTH_URL = get_from_env("PROPEL_AUTH_URL", allow_missing=True)

Expand Down

0 comments on commit d91e6b8

Please sign in to comment.