Skip to content

Commit

Permalink
feat(user-rbac-info): add user policies in info
Browse files Browse the repository at this point in the history
  • Loading branch information
Rudyard Richter committed Apr 1, 2019
1 parent cde6567 commit 0d71e53
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions fence/rbac/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def __init__(self, logger=None, arborist_base_url="http://arborist-service/"):
self._policy_url = self._base_url + "/policy/"
self._resource_url = self._base_url + "/resource"
self._role_url = self._base_url + "/role/"
self._user_url = self._base_url + "/user"

def healthy(self):
"""
Expand Down Expand Up @@ -137,6 +138,14 @@ def get_resource(self, resource_path):
return None
return response.json()

@_arborist_retry()
def list_policies_for_user(self, username):
"""
Args:
username (str)
"""
response = _request_get_json(requests.get(self._user_url + "/" + username))

@_arborist_retry()
def list_policies(self):
"""
Expand Down
4 changes: 4 additions & 0 deletions fence/resources/user/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ def get_user_info(current_session, username):
"message": "",
}

if hasattr(flask.current_app, "arborist"):
policies = flask.current_app.arborist.list_policies_for_user(user.username)
info["policies"] = policies

if user.tags is not None and len(user.tags) > 0:
info["tags"] = {tag.key: tag.value for tag in user.tags}

Expand Down

0 comments on commit 0d71e53

Please sign in to comment.