Skip to content

Commit

Permalink
Merge b494492 into e9f0d48
Browse files Browse the repository at this point in the history
  • Loading branch information
Avantol13 committed Sep 7, 2021
2 parents e9f0d48 + b494492 commit 32bbe86
Show file tree
Hide file tree
Showing 3 changed files with 467 additions and 535 deletions.
26 changes: 0 additions & 26 deletions fence/jwt/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,6 @@ def generate_signed_access_token(
forced_exp_time=None,
client_id=None,
linked_google_email=None,
include_project_access=True,
):
"""
Generate a JWT access token and output a UTF-8
Expand Down Expand Up @@ -422,31 +421,6 @@ def generate_signed_access_token(
if scopes:
claims["aud"] += scopes

if include_project_access:
# NOTE: "THIS IS A TERRIBLE STOP-GAP SOLUTION SO THAT USERS WITH
# MINIMAL ACCESS CAN STILL USE LATEST VERSION OF FENCE
# WITH VERSIONS OF PEREGRINE/SHEEPDOG THAT DO NOT CURENTLY
# SUPPORT AUTHORIZATION CHECKS AGAINST ARBORIST (AND INSTEAD
# RELY ON THE PROJECTS IN THE TOKEN). If the token is too large
# everything breaks. I'm sorry" --See PXP-3717
if len(dict(user.project_access)) < config["TOKEN_PROJECTS_CUTOFF"]:
claims["context"]["user"]["projects"] = dict(user.project_access)
else:
# truncate to configured number of projects in token
projects = dict(user.project_access)
for key in list(projects)[config["TOKEN_PROJECTS_CUTOFF"] :]:
del projects[key]
claims["context"]["user"]["projects"] = projects
logger.warning(
"NOT including project_access = {} in claims for user {} because there are too many projects for the token\n".format(
{
k: dict(user.project_access)[k]
for k in set(dict(user.project_access)) - set(projects)
},
user.username,
)
)

# only add google linkage information if provided
if linked_google_email:
claims["context"]["user"]["google"][
Expand Down
3 changes: 1 addition & 2 deletions fence/oidc/jwt_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ def generate_implicit_response(
scopes=scope,
client_id=client.client_id,
linked_google_email=linked_google_email,
include_project_access=False,
).token
response["access_token"] = access_token

Expand All @@ -119,7 +118,6 @@ def generate_implicit_response(
nonce=nonce,
linked_google_email=linked_google_email,
linked_google_account_exp=linked_google_account_exp,
include_project_access=False,
auth_flow_type=AuthFlowTypes.IMPLICIT,
access_token=access_token if include_access_token else None,
).token
Expand Down Expand Up @@ -196,6 +194,7 @@ def generate_token_response(
nonce=nonce,
linked_google_email=linked_google_email,
linked_google_account_exp=linked_google_account_exp,
include_project_access=False,
auth_flow_type=AuthFlowTypes.CODE,
access_token=access_token,
).token
Expand Down
Loading

0 comments on commit 32bbe86

Please sign in to comment.