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

feat/arborist #608

Merged
merged 71 commits into from
May 20, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
e6b37d1
feat(user-rbac-info): add user policies in info
Apr 1, 2019
7fa5a3f
feat(sleek-jwts): remove policies
Apr 2, 2019
6fca959
feat(sleek-jwts): add migration to drop policies
Apr 2, 2019
a010e9e
Merge pull request #604 from uc-cdis/feat/user-rbac-info
rudyardrichter Apr 3, 2019
45f9b95
feat(download-auth): use arborist for data download check
Apr 3, 2019
b3734dc
feat(download-auth): userdatamodel pin
Apr 3, 2019
bbbfdb1
feat(sleek-jwts): remove policy from models
Apr 3, 2019
d21254a
feat(sleek-jwts): remove unused policies endpoints
Apr 5, 2019
644910c
feat(download-auth): userdatamodel pin
Apr 3, 2019
542db3a
Merge branch 'feat/sleek-jwts' into feat/download-auth
Apr 5, 2019
c96f8e3
feat(download-auth): remove unused imports
Apr 5, 2019
aafa11a
feat(download-auth): fix drop commands
Apr 5, 2019
c7424ab
feat(download-auth): remove more policies references
Apr 5, 2019
8e656d6
feat(download-auth): add test for download endpoint using rbac
Apr 11, 2019
b26eb62
feat(download-auth): correct methods
Apr 12, 2019
3c5158c
feat(download-auth): run formatter
Apr 12, 2019
fe48f1c
feat(arborist-sync): update sync for new RBAC
Apr 9, 2019
5c431a0
feat(arborist-sync): CRFs, add group create
Apr 25, 2019
2830ca0
Update client.py
Avantol13 Apr 25, 2019
8e2ea49
feat(arborist-sync): add arborist client checks
Apr 25, 2019
129934b
feat(download-auth): add new userdatamodel pin
Apr 26, 2019
6dc8851
feat(download-auth): add migration
Apr 26, 2019
8223657
feat(download-auth): fix param in arborist request
Apr 26, 2019
3d7b717
chore(deps): point back to branch for userdatamodel
Avantol13 May 1, 2019
3ff6fee
Merge branch 'feat/arborist' into feat/arborist-sync
Avantol13 May 6, 2019
2fb58c4
feat(arborist-client-create)
fantix Apr 8, 2019
6df6af0
add client-modify --policies
fantix May 1, 2019
fe49500
update_client: update, or create if missing
fantix May 3, 2019
4ab365e
fix Black
fantix May 6, 2019
6edb42b
Merge pull request #619 from uc-cdis/feat/arborist-client-create-br
fantix May 6, 2019
ba772f2
Merge branch 'master' into feat/arborist
Avantol13 May 6, 2019
b9ec596
feat(arborist-sync): fix user handling in sync
May 6, 2019
16ea297
fix(requirements): pin userdatamodel to remove policy branch commit
Avantol13 May 6, 2019
f6dcf97
feat(arborist-sync): fix user handling in sync
May 6, 2019
8fc3546
Merge branch 'feat/arborist' into feat/arborist-sync
Avantol13 May 6, 2019
43dc1d4
Merge branch 'feat/arborist-sync' of github.com:uc-cdis/fence into fe…
Avantol13 May 6, 2019
ecf0075
feat(download-auth): add migration
Apr 26, 2019
d294f60
fix(imports): add missing import for syncing
Avantol13 May 6, 2019
c7244de
fix(fence-create): correctly pass in ArboristClient
Avantol13 May 6, 2019
59396f0
feat(arborist-sync): overwrite policy if necessary
May 6, 2019
cce4ea9
feat(arborist-sync): clean up logging
May 6, 2019
35bc481
Merge branch 'feat/arborist-sync' into feat/download-auth
May 7, 2019
135c17c
feat(download-auth): tmp userdatamodel pin
May 7, 2019
da19122
feat(arborist-sync): change to * permission
May 7, 2019
fafe1e2
feat(arborist-sync): change to * permission
May 7, 2019
b8cc27d
feat(arborist-sync): support user policy list
May 7, 2019
c73f70c
feat(arborist-sync): leave warning if group exists
May 7, 2019
3ecb1ee
feat(arborist-sync): support user policy list
May 7, 2019
81b4e5b
feat(arborist): user policies -> resources list
May 9, 2019
6e7ee91
feat(sleek-jwts): remove policy from models
Apr 3, 2019
6877e6f
Merge pull request #606 from uc-cdis/feat/download-auth
rudyardrichter May 9, 2019
166c1c3
feat(arborist): handle error for resource list
May 9, 2019
925518f
feat(signed-url): check authz field instead of rbac for new indexd ch…
Avantol13 May 9, 2019
baa0860
Merge remote-tracking branch 'origin/feat/arborist' into feat/arborist
Avantol13 May 9, 2019
91a3641
fix(tests): rbac to authz indexd field
Avantol13 May 9, 2019
3d78781
feat(arborist-sync): run formatter
May 10, 2019
a1ce22f
Merge branch 'feat/arborist' into feat/arborist-sync
May 10, 2019
ed45d84
Merge pull request #613 from uc-cdis/feat/arborist-sync
rudyardrichter May 10, 2019
ed7e556
feat(arborist): overwrite groups during sync
May 10, 2019
27e65f5
feat(arborist): remove rbac blueprint from docs
May 13, 2019
624f63f
feat(builtin-groups): support builtin groups in user.yaml
May 14, 2019
45aff9c
feat(builtin-groups): fix typo
rudyardrichter May 14, 2019
edeba8f
feat(builtin-groups): fix error handle
May 14, 2019
fdbb000
feat(arborist): fix status code for user create
May 14, 2019
578274a
feat(builtin-groups): run formatter
May 14, 2019
bcd0259
Merge branch 'master' into feat/arborist
Avantol13 May 14, 2019
098f610
feat(arborist): run formatter
May 14, 2019
1173697
Merge pull request #625 from uc-cdis/feat/builtin-groups
rudyardrichter May 14, 2019
e9a6eea
Merge branch 'master' into feat/arborist
Avantol13 May 16, 2019
1e90cb7
feat(arborist): overwrite policies in user.yaml
May 16, 2019
14bb60b
chore(userdatamodel): pin to updated version from pypi
Avantol13 May 17, 2019
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
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
3 changes: 1 addition & 2 deletions fence/resources/openid/idp_oauth2.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ def get_value_from_discovery_doc(self, key, default_value):
Given a key return a value by the recommended method of
using their discovery url.
"""

return_value = default_value

if self.discovery_doc.status_code == requests.codes.ok:
Expand Down Expand Up @@ -120,4 +119,4 @@ def get_user_id(self, code):
Must implement in inheriting class. Should return dictionary with "email" field
for successfully logged in user OR "error" field with details of the error.
"""
raise NotImplementedError()
raise NotImplementedError()
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
6 changes: 4 additions & 2 deletions tests/admin/test_admin_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ def test_add_project_to_group_updates_users(db_session, awg_users, awg_groups):


def test_delete_group_updates_user_projects(
db_session, awg_users, awg_groups, oauth_client
db_session, awg_users, awg_groups, oauth_client, mock_arborist_requests
):
mock_arborist_requests()
user = db_session.query(User).filter_by(username="awg_user").first()
user_projects = {
db_session.query(Project).filter_by(id=item.project_id).first().name
Expand Down Expand Up @@ -150,8 +151,9 @@ def test_remove_project_from_group(db_session, awg_groups):


def test_remove_project_from_group_updates_user(
db_session, awg_users, awg_groups, oauth_client
db_session, awg_users, awg_groups, oauth_client, mock_arborist_requests
):
mock_arborist_requests()
user = db_session.query(User).filter_by(username="awg_user").first()
user_projects = {
db_session.query(Project).filter_by(id=item.project_id).first().name
Expand Down
8 changes: 7 additions & 1 deletion tests/admin/test_admin_users.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import pytest

import fence.resources.admin as adm
from fence.models import User, AccessPrivilege, Project, UserToGroup, Group
import pytest
from fence.errors import NotFound, UserError


@pytest.fixture(autouse=True)
def mock_arborist(mock_arborist_requests):
mock_arborist_requests()


def test_get_user(db_session, awg_users):
info = adm.get_user_info(db_session, "awg_user")
assert info["name"] == "awg_user"
Expand Down
5 changes: 5 additions & 0 deletions tests/admin/test_admin_users_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ def encoded_admin_jwt(kid, rsa_private_key):
return jwt.encode(claims, key=rsa_private_key, headers=headers, algorithm="RS256")


@pytest.fixture(autouse=True)
def mock_arborist(mock_arborist_requests):
mock_arborist_requests()


# GET /users/<username> tests


Expand Down
5 changes: 3 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,9 @@ def kid_2():
return "test-keypair-2"


@pytest.fixture(scope="session")
@pytest.fixture(scope="function")
def mock_arborist_requests(request):

def do_patch(urls_to_responses=None):
urls_to_responses = urls_to_responses or {}
defaults = {"arborist/health": {"GET": ("", 200)}}
Expand Down Expand Up @@ -221,7 +222,7 @@ def response(url):


@pytest.fixture(scope="session")
def app(kid, rsa_private_key, rsa_public_key, mock_arborist_requests):
def app(kid, rsa_private_key, rsa_public_key):
"""
Flask application fixture.
"""
Expand Down
8 changes: 8 additions & 0 deletions tests/oidc/core/user_info/test_userinfo.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
""" test /user endpoint and UserInfo Requests/Response"""
import json

import pytest

from fence.models import UserGoogleAccount


@pytest.fixture(autouse=True)
def mock_arborist(mock_arborist_requests):
mock_arborist_requests()


def test_userinfo_standard_claims_get(client, encoded_creds_jwt):

encoded_credentials_jwt = encoded_creds_jwt["jwt"]
Expand Down
5 changes: 5 additions & 0 deletions tests/scripting/test_fence-create.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
ROOT_DIR = "./"


@pytest.fixture(autouse=True)
def mock_arborist(mock_arborist_requests):
mock_arborist_requests()


def test_client_delete(app, db_session, cloud_manager, test_user_a):
"""
Test that the client delete function correctly cleans up the client's
Expand Down
7 changes: 7 additions & 0 deletions tests/session/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
from mock import patch
from mock import call

import pytest


@pytest.fixture(autouse=True)
def mock_arborist(mock_arborist_requests):
mock_arborist_requests()


def test_session_cookie_creation(app):
# Test that when we don't modify the session, a
Expand Down