def token_from_id(self, token_id): try: tokens = identity.token_driver() if (identity.auth_driver().__class__.__name__ != "NoAuthDriver"): raise exceptions.InvalidTokenError( 'Auth-driver must be NoAuthDriver') auth = identity.auth_driver().authenticate(None) if auth is None: raise exceptions.Unauthorized('Unauthorized credentials') token = tokens.create_token(None, auth) return token except (TypeError, ValueError): raise exceptions.InvalidTokenError('Malformed token')
def on_post(self, req, resp): body = req.stream.read().decode() credentials = json.loads(body) tokens = identity.token_driver() auth = identity.auth_driver().authenticate(credentials) if auth is None: raise Unauthorized('Unauthorized credentials') token = tokens.create_token(credentials, auth) tok_id = identity.token_id_driver().create_token_id(token) access = get_access(tok_id, token) # Add catalog to the access data raw_catalog = self._get_catalog(tokens.tenant_id(token), tokens.user_id(token)) 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}
def on_post(self, req, resp): body = req.stream.read().decode() credentials = json.loads(body) tokens = identity.token_driver() auth = identity.auth_driver().authenticate(credentials) if auth is None: raise exceptions.Unauthorized('Unauthorized credentials') token = tokens.create_token(credentials, auth) tok_id = identity.token_id_driver().create_token_id(token) access = get_access(tok_id, token) # Add catalog to the access data raw_catalog = self._get_catalog(tokens.tenant_id(token), tokens.user_id(token)) 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}
def on_post(self, req, resp): body = req.stream.read().decode() credentials = json.loads(body) tokens = identity.token_driver() auth = identity.auth_driver().authenticate(credentials) if auth is None: raise exceptions.Unauthorized('Unauthorized credentials') token = tokens.create_token(credentials, auth) tok_id = identity.token_id_driver().create_token_id(token) access = get_access(tok_id, token) # Add catalog to the access data self._add_catalog_to_access(access, token) resp.status = 200 resp.body = {'access': access}
def on_post(self, req, resp): body = req.stream.read().decode() credentials = json.loads(body) tokens = identity.token_driver() auth = identity.auth_driver().authenticate(credentials) if auth is None: raise Unauthorized("Unauthorized credentials") token = tokens.create_token(credentials, auth) tok_id = identity.token_id_driver().create_token_id(token) access = get_access(tok_id, token) # Add catalog to the access data raw_catalog = self._get_catalog(tokens.tenant_id(token), tokens.user_id(token)) 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}