Skip to content

Commit

Permalink
Merge 3a16e6d into dbedbf6
Browse files Browse the repository at this point in the history
  • Loading branch information
Avantol13 committed Sep 8, 2021
2 parents dbedbf6 + 3a16e6d commit d953129
Show file tree
Hide file tree
Showing 3 changed files with 466 additions and 534 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
1 change: 0 additions & 1 deletion 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 Down

0 comments on commit d953129

Please sign in to comment.