Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(audit): initial, untested attempt to update the user(name) after … #1158

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions fence/blueprints/data/indexd.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ def _get_client_id():

return client_id


def prepare_presigned_url_audit_log(protocol, indexed_file):
"""
Store in `flask.g.audit_data` the data needed to record an audit log.
Expand Down Expand Up @@ -520,6 +521,9 @@ def get_signed_url(
)
raise Unauthorized(msg)
authorized_user = users_from_passports.get(authorized_username)
if not authorized_user:
db_session = current_app.scoped_session()
authorized_user = query_for_user(session=db_session, username=username)
else:
if self.public_acl and action == "upload":
raise Unauthorized(
Expand Down Expand Up @@ -661,14 +665,21 @@ def get_authorized_with_username(self, action, usernames_from_passports=None):
# public data, we still make the request to Arborist
token = None

is_authorized = flask.current_app.arborist.auth_request(
jwt=token,
service="fence",
methods=action,
resources=self.index_document["authz"],
)

username = None
if token:
auth_info = _get_auth_info_for_id_or_from_request(sub_type=int)
username = auth_info["username"]

return (
flask.current_app.arborist.auth_request(
jwt=token,
service="fence",
methods=action,
resources=self.index_document["authz"],
),
None,
is_authorized,
username,
)

@cached_property
Expand Down
Loading