from time import time
from os import path
-from authconn import AuthException, AuthExceptionUnauthorized
-from authconn_keystone import AuthconnKeystone
-from authconn_internal import AuthconnInternal # Comment out for testing&debugging, uncomment when ready
+from osm_nbi.authconn import AuthException, AuthExceptionUnauthorized
+from osm_nbi.authconn_keystone import AuthconnKeystone
+from osm_nbi.authconn_internal import AuthconnInternal # Comment out for testing&debugging, uncomment when ready
from osm_common import dbmongo
from osm_common import dbmemory
from osm_common.dbbase import DbException
pid = self.create_admin_project()
self.create_admin_user(pid)
+ # self.backend.update_user({"_id": "admin",
+ # "add_project_role_mappings": {"project": "admin", "role": "system_admin"}})
if self.config["authentication"]["backend"] == "keystone":
try:
self.backend.assign_role_to_user("admin", "admin", "system_admin")
if cherrypy.session.get('Authorization'):
del cherrypy.session['Authorization']
cherrypy.response.headers["WWW-Authenticate"] = 'Bearer realm="{}"'.format(e)
+ elif self.config.get("user_not_authorized"):
+ # TODO provide user_id, roles id (not name), project_id
+ return {"id": "fake-token-id-for-test",
+ "project_id": self.config.get("project_not_authorized", "admin"),
+ "username": self.config["user_not_authorized"],
+ "roles": ["system_admin"]}
raise
def new_token(self, token_info, indata, remote):