Exemplo n.º 1
0
    def on_post(self, req, resp):
        body = req.stream.read().decode()
        credentials = json.loads(body)
        token_details, user = get_new_token(credentials)
        token_id = base64.b64encode(encode_aes(json.dumps(token_details)))

        access = get_access(token_id, token_details, user)

        # Add catalog to the access data
        raw_catalog = self._get_catalog(token_details['tenant_id'], user['id'])
        catalog = []
        for services in raw_catalog.values():
            for service_type, service in services.items():
                d = {
                    'type': service_type,
                    'name': service.get('name', 'Unknown'),
                    'endpoints': [{
                        'region': service.get('region', 'RegionOne'),
                        'publicURL': service.get('publicURL'),
                        'privateURL': service.get('privateURL'),
                        'adminURL': service.get('adminURL'),
                    }],
                    'endpoint_links': [],
                }
                catalog.append(d)

        access['serviceCatalog'] = catalog

        resp.status = 200
        resp.body = {'access': access}
Exemplo n.º 2
0
    def on_post(self, req, resp):
        body = req.stream.read().decode()
        credentials = json.loads(body)
        token_details, user = auth.get_new_token_v3(credentials)
        token_id = base64.b64encode(aes.encode_aes(json.dumps(token_details)))

        access = get_access_v3(token_id, token_details, user)
        # Add catalog to the access data
        catalog = self._build_catalog(token_details, user)
        access['token']['catalog'] = catalog

        resp.status = 200
        resp.set_header('X-Subject-Token', str(token_id))
        # V2 APIs return the body in 'access' keypair but V3 APIs do not
        # resp.body = {'access': access}
        resp.body = access
Exemplo n.º 3
0
    def on_post(self, req, resp):
        body = req.stream.read().decode()
        credentials = json.loads(body)
        token_details, user = auth.get_new_token_v3(credentials)
        token_id = base64.b64encode(aes.encode_aes(json.dumps(token_details)))

        access = get_access_v3(token_id, token_details, user)
        # Add catalog to the access data
        catalog = self._build_catalog(token_details, user)
        access['token']['catalog'] = catalog

        resp.status = 200
        resp.set_header('X-Subject-Token', str(token_id))
        # V2 APIs return the body in 'access' keypair but V3 APIs do not
        # resp.body = {'access': access}
        resp.body = access
Exemplo n.º 4
0
 def create_token_id(self, token):
     return base64.b64encode(aes.encode_aes(json.dumps(token)))
Exemplo n.º 5
0
 def create_token_id(self, token):
     # Doesn't matter how we encode, since decode will always give
     # same result no matter what input, but for now do the same as our
     # default driver
     return base64.b64encode(aes.encode_aes(json.dumps(token)))
Exemplo n.º 6
0
 def create_token_id(self, token):
     return base64.b64encode(aes.encode_aes(json.dumps(token)))
Exemplo n.º 7
0
 def create_token_id(self, token):
     # Doesn't matter how we encode, since decode will always give
     # same result no matter what input, but for now do the same as our
     # default driver
     return base64.b64encode(aes.encode_aes(json.dumps(token)))