Skip to content

Commit

Permalink
fix token audience/scopes validation
Browse files Browse the repository at this point in the history
  • Loading branch information
paulineribeyre committed Jan 27, 2023
1 parent be159a9 commit 0f76865
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
6 changes: 5 additions & 1 deletion sheepdog/blueprint/routes/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ def get_programs():
}
"""
if flask.current_app.config.get("AUTH_SUBMISSION_LIST", True) is True:
auth.validate_request(aud={"openid"}, purpose=None)
auth.validate_request(
scope={"openid"},
audience=flask.current_app.config.get("BASE_URL"),
purpose=None,
)
with flask.current_app.db.session_scope():
programs = current_app.db.nodes(models.Program.name).all()
links = [flask.url_for(".get_projects", program=p[0]) for p in programs]
Expand Down
6 changes: 5 additions & 1 deletion sheepdog/blueprint/routes/views/program/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ def get_projects(program):
}
"""
if flask.current_app.config.get("AUTH_SUBMISSION_LIST", True) is True:
auth.validate_request(aud={"openid"}, purpose=None)
auth.validate_request(
scope={"openid"},
audience=flask.current_app.config.get("BASE_URL"),
purpose=None,
)
with flask.current_app.db.session_scope():
matching_programs = flask.current_app.db.nodes(models.Program).props(
name=program
Expand Down
12 changes: 10 additions & 2 deletions sheepdog/blueprint/routes/views/program/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ def get_project_dictionary(program=None, project=None):
403: Unauthorized request.
"""
if flask.current_app.config.get("AUTH_SUBMISSION_LIST", True) is True:
auth.validate_request(aud={"openid"}, purpose=None)
auth.validate_request(
scope={"openid"},
audience=flask.current_app.config.get("BASE_URL"),
purpose=None,
)
keys = list(dictionary.schema.keys()) + ["_all"]
links = [
flask.url_for(
Expand Down Expand Up @@ -228,7 +232,11 @@ def get_project_dictionary_entry(program, project, entry):
403: Unauthorized request.
"""
if flask.current_app.config.get("AUTH_SUBMISSION_LIST", True) is True:
auth.validate_request(aud={"openid"}, purpose=None)
auth.validate_request(
scope={"openid"},
audience=flask.current_app.config.get("BASE_URL"),
purpose=None,
)
return get_dictionary_entry(entry)


Expand Down

0 comments on commit 0f76865

Please sign in to comment.