From b24ff7cd5a80d5aaf172f55af7aaaf9a85f80a72 Mon Sep 17 00:00:00 2001 From: Ioannis Igoumenos Date: Mon, 23 Oct 2023 10:27:14 +0300 Subject: [PATCH] distinct names for oauth object and client instances --- app/routers/authenticate.py | 8 ++++---- app/utils/globalMethods.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/routers/authenticate.py b/app/routers/authenticate.py index 1f3f072..e2a99be 100644 --- a/app/routers/authenticate.py +++ b/app/routers/authenticate.py @@ -27,7 +27,7 @@ def initializeAuthOb(): oauth = OAuth() oauth.register( - g.tenant + '.' + g.environment + '.rciam', + g.tenant + '_' + g.environment + '_rciam_ob', client_id=oidc_config['client_id'], client_secret=oidc_config['client_secret'], server_metadata_url=oidc_config['issuer'] + "/.well-known/openid-configuration", @@ -46,7 +46,7 @@ async def login_endpoint( request: Request, oauth_ob= Depends(initializeAuthOb), server_config= Depends(getServerConfig)): - rciam = oauth_ob.create_client(g.tenant + '.' + g.environment + '.rciam') + rciam = oauth_ob.create_client(g.tenant + '_' + g.environment + '_rciam_client') redirect_uri = server_config['protocol'] + "://" + server_config['host'] + server_config['api_path'] + "/auth" return await rciam.authorize_redirect(request, redirect_uri) @@ -71,7 +71,7 @@ async def authorize_rciam( response = RedirectResponse(url=urllib.parse.unquote(login_start_url)) response.delete_cookie("login_start") - rciam = oauth_ob.create_client(g.tenant + '.' + g.environment + '.rciam') + rciam = oauth_ob.create_client(g.tenant + '_' + g.environment + '_rciam_client') try: token = await rciam.authorize_access_token(request) except OAuthError as error: @@ -148,7 +148,7 @@ async def logout( oauth_ob= Depends(initializeAuthOb), server_config=Depends(getServerConfig) ): - rciam = oauth_ob.create_client(g.tenant + '.' + g.environment + '.rciam') + rciam = oauth_ob.create_client(g.tenant + '_' + g.environment + '_rciam_client') metadata = await rciam.load_server_metadata() # todo: Fix this after we complete the multitenacy redirect_uri = server_config['protocol'] + "://" + server_config['client'] +"/metrics" diff --git a/app/utils/globalMethods.py b/app/utils/globalMethods.py index d0b234f..e35c7ea 100644 --- a/app/utils/globalMethods.py +++ b/app/utils/globalMethods.py @@ -31,7 +31,7 @@ async def __call__(self, request: Request, response: Response): self.logger.debug("""{0}.{1}: Config File Name: {2}""".format(g.tenant, g.environment, config_file)) self.oauth.register( - g.tenant + '.' + g.environment + '.rciam', + g.tenant + '_' + g.environment + '_rciam_ob', client_id=oidc_config['client_id'], client_secret=oidc_config['client_secret'], server_metadata_url=oidc_config['issuer'] + "/.well-known/openid-configuration", @@ -42,7 +42,7 @@ async def __call__(self, request: Request, response: Response): # permissions calculation access_token = request.headers.get('x-access-token') - rciam = self.oauth.create_client(g.tenant + '.' + g.environment + '.rciam') + rciam = self.oauth.create_client(g.tenant + '_' + g.environment + '_rciam_client') metadata = await rciam.load_server_metadata() headers = {'Authorization': f'Bearer {access_token}'}