diff options
author | Frederick Muriuki Muriithi | 2024-10-09 16:33:58 -0500 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2024-10-09 16:53:50 -0500 |
commit | 6445b327f77726bd70e38268393b57d7a8042182 (patch) | |
tree | 14eac55576adef4fa1d1b2ba3cb954d01f6a81b0 /gn_auth/auth/authorisation/users/masquerade/views.py | |
parent | e856c43aa538c03afddb1b9424a0bac7408639d5 (diff) | |
download | gn-auth-6445b327f77726bd70e38268393b57d7a8042182.tar.gz |
Fix masquerading logic
Update the code to actually use JWT bearer tokens that the older plain
authorisation tokens that were previously used.
Diffstat (limited to 'gn_auth/auth/authorisation/users/masquerade/views.py')
-rw-r--r-- | gn_auth/auth/authorisation/users/masquerade/views.py | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/gn_auth/auth/authorisation/users/masquerade/views.py b/gn_auth/auth/authorisation/users/masquerade/views.py index 68f19ee..8b897f2 100644 --- a/gn_auth/auth/authorisation/users/masquerade/views.py +++ b/gn_auth/auth/authorisation/users/masquerade/views.py @@ -28,22 +28,17 @@ def masquerade() -> Response: masq_user = with_db_connection(partial( user_by_id, user_id=masqueradee_id)) + def __masq__(conn): new_token = masquerade_as(conn, original_token=token, masqueradee=masq_user) return new_token - def __dump_token__(tok): - return { - key: value for key, value in asdict(tok).items() - if key in ("access_token", "refresh_token", "expires_in", - "token_type") - } + return jsonify({ "original": { - "user": asdict(token.user), - "token": __dump_token__(token) + "user": asdict(token.user) }, "masquerade_as": { "user": asdict(masq_user), - "token": __dump_token__(with_db_connection(__masq__)) + "token": with_db_connection(__masq__) } }) |