Exemplo n.º 1
0
class JointClient():
    def __init__(self, url, credentials):
        parsed_url = urlparse(url)
        server = '{}://{}'.format(parsed_url.scheme, parsed_url.netloc)

        self._umbrella_client = UmbrellaClient(server, credentials['token'],
                                               credentials['key'])

        self._keystone_client = KeystoneClient()
        self._keystone_client.set_resource_url(url)
        self._keystone_client.set_app_id(credentials['app_id'])

    def check_role(self, role):
        self._umbrella_client.check_role(role)
        self._keystone_client.check_role(role)

    def grant_permission(self, customer, role):
        self._umbrella_client.grant_permission(customer, role)
        self._keystone_client.grant_permission(customer, role)

    def revoke_permission(self, customer, role):
        self._umbrella_client.revoke_permission(customer, role)
        self._keystone_client.revoke_permission(customer, role)
Exemplo n.º 2
0
    def _get_keystone_client(self, credentials):
        keystone_client = KeystoneClient()
        keystone_client.set_app_id(credentials['app_id'])

        return keystone_client
Exemplo n.º 3
0
    def _get_keystone_client(self, url, credentials):
        keystone_client = KeystoneClient()
        keystone_client.set_resource_url(url)
        keystone_client.set_app_id(credentials['app_id'])

        return keystone_client