Skip to content

Commit

Permalink
Merge pull request #71 from PolicyEngine/fix/remove_final_clients
Browse files Browse the repository at this point in the history
Remove final `@clients` from `client_id` parameter of JWT
  • Loading branch information
anth-volk authored Feb 2, 2024
2 parents 3a9b4e5 + f99c938 commit 21ecd1f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ dist/*
**/*.rdb
**/*.h5
**/*.csv.gz
.env
.env
.ds_store
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ install:
pip install -e .[dev]

debug:
FLASK_APP=policyengine_household_api.api FLASK_DEBUG=1 flask run --without-threads -p 5050
FLASK_APP=policyengine_household_api.api FLASK_DEBUG=1 flask run --without-threads

test:
pytest -vv --timeout=150 -rP tests
Expand Down
4 changes: 4 additions & 0 deletions changelog_entry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- bump: patch
changes:
changed:
- Removed the '@clients' parameter from the client_id portion of the JWT
6 changes: 6 additions & 0 deletions policyengine_household_api/decorators/analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ def decorated_function(*args, **kwargs):
token = auth_header.split(" ")[1]
decoded_token = jwt.decode(token, options={"verify_signature": False})
client_id = decoded_token["sub"]
suffix_to_slice = "@clients"
if (
len(client_id) >= len(suffix_to_slice)
and client_id[-len(suffix_to_slice) :] == suffix_to_slice
):
client_id = client_id[: -len(suffix_to_slice)]
new_visit.client_id = client_id

# Set API version
Expand Down

0 comments on commit 21ecd1f

Please sign in to comment.