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

Magpie adapter process visibility #111

Merged
merged 27 commits into from
Oct 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e723b62
fix conflict routes
fmigneault Oct 3, 2018
0ce6323
initial setup magpie adapter for process visibility
fmigneault Oct 2, 2018
efa4df4
instantiate magpie adapter process store
fmigneault Oct 2, 2018
146e794
add input visibility processstore
fmigneault Oct 2, 2018
8bdc29b
adjust permissions verification
fmigneault Oct 2, 2018
31a92d1
filter processes by visibility
fmigneault Oct 2, 2018
e0645a7
more magpie adapter process handling
fmigneault Oct 2, 2018
898fbb4
create/list/delete processes with magpie resources
fmigneault Oct 3, 2018
20fffeb
reapply logging.config import
fmigneault Oct 3, 2018
3d1bc23
remove logging req breaking stuff (?)
fmigneault Oct 3, 2018
d259550
enforce specific gunicorn version
fmigneault Oct 3, 2018
7989367
Merge branch 'magpie-adapter-process-visibility' of https://github.co…
fmigneault Oct 3, 2018
bcbd05b
add debug info
fmigneault Oct 3, 2018
46a02d8
add request headers + more debug
fmigneault Oct 3, 2018
91878b4
revise permissions handling for processstore adapter
fmigneault Oct 3, 2018
4ae8b13
change process resource retrieval to reflect desired visibility results
fmigneault Oct 3, 2018
0ef0d5c
get visible processes by GET request on proxy /processes
fmigneault Oct 3, 2018
ff63f04
move imports to processstore specific usage
fmigneault Oct 4, 2018
cfbcae1
add ssl verify option use from twitcher
fmigneault Oct 4, 2018
b7ab9a6
add service name at end of public url if full url env var is defined
fmigneault Oct 4, 2018
be8d6b6
Merge branch 'fix-twitcher-public-url' into magpie-adapter-process-vi…
fmigneault Oct 4, 2018
0f59998
change adapter process read permission method to avoid circular calls
fmigneault Oct 4, 2018
350bc0a
another attempt at process visibility
fmigneault Oct 4, 2018
42b4188
proper ssl verification off for localhost
fmigneault Oct 4, 2018
a1951af
another method to control adapter process visibility
fmigneault Oct 5, 2018
e4408d3
add visibility param
fmigneault Oct 5, 2018
401d73e
use admin resources, visibility working
fmigneault Oct 5, 2018
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
8 changes: 4 additions & 4 deletions magpie/adapter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from magpie.definitions.ziggurat_definitions import *
from magpie.definitions.twitcher_definitions import *
from magpie.adapter.magpieowssecurity import *
from magpie.adapter.magpieservice import *
from magpie.adapter.magpieservice import MagpieServiceStore
from magpie.models import get_user
from magpie.security import auth_config_from_settings
from magpie.db import *
Expand All @@ -19,9 +19,9 @@ def servicestore_factory(self, registry, headers=None):
return MagpieServiceStore(registry=registry)

def processstore_factory(self, registry):
# no reimplementation of processes on magpie side
# simply return the default twitcher process store
return DefaultAdapter().processstore_factory(registry)
# import here to avoid import errors on default twitcher not implementing processes
from magpie.adapter.magpieprocess import MagpieProcessStore
return MagpieProcessStore(registry=registry)

def jobstore_factory(self, registry):
# no reimplementation of jobs on magpie side
Expand Down
373 changes: 373 additions & 0 deletions magpie/adapter/magpieprocess.py

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions magpie/adapter/magpieservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
LOGGER = logging.getLogger("TWITCHER")

from magpie.definitions.twitcher_definitions import *
from magpie.definitions.pyramid_definitions import ConfigurationError
from magpie.definitions.pyramid_definitions import ConfigurationError, HTTPOk


class MagpieServiceStore(ServiceStore):
Expand Down Expand Up @@ -51,7 +51,7 @@ def list_services(self, request=None):
path = '/users/current/services?inherit=True&cascade=True'
response = requests.get('{url}{path}'.format(url=self.magpie_url, path=path),
cookies=request.cookies)
if response.status_code != 200:
if response.status_code != HTTPOk.code:
raise response.raise_for_status()
services = json.loads(response.text)
for service_type in services['services']:
Expand Down
33 changes: 20 additions & 13 deletions magpie/api/api_rest_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,42 +375,42 @@ class InternalServerErrorResponseSchema(colander.MappingSchema):


class ProvidersListSchema(colander.SequenceSchema):
item = colander.SchemaNode(
provider_name = colander.SchemaNode(
colander.String(),
description="Available login providers.",
example=["ziggurat", "openid"],
example="openid",
)


class ResourceTypesListSchema(colander.SequenceSchema):
item = colander.SchemaNode(
resource_type = colander.SchemaNode(
colander.String(),
description="Available resource type under root service.",
example=["file", "dictionary"],
example="file",
)


class GroupNamesListSchema(colander.SequenceSchema):
item = colander.SchemaNode(
group_name = colander.SchemaNode(
colander.String(),
description="List of groups depending on context.",
example=["anonymous"]
example="administrators"
)


class UserNamesListSchema(colander.SequenceSchema):
item = colander.SchemaNode(
user_name = colander.SchemaNode(
colander.String(),
description="Users registered in the db",
example=["anonymous", "admin", "toto"]
example="bob"
)


class PermissionListSchema(colander.SequenceSchema):
item = colander.SchemaNode(
permission_name = colander.SchemaNode(
colander.String(),
description="Permissions applicable to the service/resource",
example=["read", "write"]
example="read"
)


Expand All @@ -423,7 +423,9 @@ class UserBodySchema(colander.MappingSchema):
colander.String(),
description="Email of the user.",
example="[email protected]")
group_names = GroupNamesListSchema()
group_names = GroupNamesListSchema(
example=['administrators', 'users']
)


class GroupBodySchema(colander.MappingSchema):
Expand All @@ -445,15 +447,20 @@ class GroupBodySchema(colander.MappingSchema):
description="Number of users member of the group.",
example=2,
missing=colander.drop)
user_names = UserNamesListSchema(missing=colander.drop)
user_names = UserNamesListSchema(
example=['alice', 'bob'],
missing=colander.drop
)


class ServiceBodySchema(colander.MappingSchema):
resource_id = colander.SchemaNode(
colander.Integer(),
description="Resource identification number",
)
permission_names = PermissionListSchema()
permission_names = PermissionListSchema(
example=['read', 'write']
)
service_name = colander.SchemaNode(
colander.String(),
description="Name of the service",
Expand Down
2 changes: 1 addition & 1 deletion magpie/api/management/user/user_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def get_user_inherited_services_view(request):
@LoggedUserServiceInheritedPermissionsAPI.get(schema=UserServicePermissions_GET_RequestSchema,
tags=[LoggedUserTag], api_security=SecurityEveryoneAPI,
response_schemas=LoggedUserServicePermissions_GET_responses)
@view_config(route_name=UserServicePermissionsAPI.name, request_method='GET', permission=NO_PERMISSION_REQUIRED)
@view_config(route_name=UserServiceInheritedPermissionsAPI.name, request_method='GET', permission=NO_PERMISSION_REQUIRED)
def get_user_service_inherited_permissions_view(request):
"""List all permissions a user has on a service using all his inherited user and groups permissions."""
LOGGER.warn("Route deprecated: [{0}], Instead Use: [{1}]"
Expand Down
1 change: 1 addition & 0 deletions magpie/definitions/pyramid_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
HTTPUnprocessableEntity,
HTTPInternalServerError,
)
from pyramid.settings import asbool
from pyramid.interfaces import IAuthenticationPolicy, IAuthorizationPolicy
from pyramid.response import Response, FileResponse
from pyramid.view import (
Expand Down
2 changes: 1 addition & 1 deletion magpie/definitions/twitcher_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from twitcher.owsproxy import owsproxy
from twitcher.owssecurity import OWSSecurityInterface
from twitcher.owsexceptions import OWSAccessForbidden
from twitcher.utils import parse_service_name
from twitcher.utils import parse_service_name, get_twitcher_url
from twitcher.esgf import fetch_certificate, ESGF_CREDENTIALS
from twitcher.datatype import Service
from twitcher.store.base import ServiceStore
Expand Down
1 change: 1 addition & 0 deletions magpie/magpiectl.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import time
import warnings
import logging
import logging.config
LOGGER = logging.getLogger(__name__)

# -- Definitions
Expand Down
23 changes: 12 additions & 11 deletions magpie/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,18 +163,19 @@ def get_magpie_url():


def get_twitcher_protected_service_url(magpie_service_name, hostname=None):
hostname = hostname or get_constant('HOSTNAME')
twitcher_proxy_url = get_constant('TWITCHER_PROTECTED_URL', raise_not_set=False)
if twitcher_proxy_url:
return twitcher_proxy_url
twitcher_proxy = get_constant('TWITCHER_PROTECTED_PATH', raise_not_set=False)
if not twitcher_proxy.endswith('/'):
twitcher_proxy = twitcher_proxy + '/'
if not twitcher_proxy.startswith('/'):
twitcher_proxy = '/' + twitcher_proxy
if not twitcher_proxy.startswith('/twitcher'):
twitcher_proxy = '/twitcher' + twitcher_proxy
return "https://{0}{1}{2}".format(hostname, twitcher_proxy, magpie_service_name)
if not twitcher_proxy_url:
twitcher_proxy = get_constant('TWITCHER_PROTECTED_PATH', raise_not_set=False)
if not twitcher_proxy.endswith('/'):
twitcher_proxy = twitcher_proxy + '/'
if not twitcher_proxy.startswith('/'):
twitcher_proxy = '/' + twitcher_proxy
if not twitcher_proxy.startswith('/twitcher'):
twitcher_proxy = '/twitcher' + twitcher_proxy
hostname = hostname or get_constant('HOSTNAME')
twitcher_proxy_url = "https://{0}{1}".format(hostname, twitcher_proxy)
twitcher_proxy_url.rstrip('/')
return "{0}/{1}".format(twitcher_proxy_url, magpie_service_name)


def register_services(register_service_url, services_dict, cookies,
Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ pluggy
flake8==3.5.0
coverage==4.0
Sphinx==1.3.1
logging
#cryptography==1.9
PyYAML>=3.11
pyramid==1.8.3
Expand All @@ -22,7 +21,7 @@ lxml>=3.7
bcrypt==3.1.3
futures==3.1.1
zope.sqlalchemy
gunicorn
gunicorn==19.8.1
alembic==0.9.6
paste
python-dotenv
Expand Down