Skip to content

Commit

Permalink
it is a real introspection, not mock
Browse files Browse the repository at this point in the history
  • Loading branch information
byewokko committed Oct 25, 2024
1 parent 8c3359c commit eb7dfdd
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions asab/web/auth/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ def _prepare_mock_mode(self):
"""
Try to set up direct introspection. In not available, set up static mock userinfo.
"""
mock_introspection_url = Config.get("auth", "mock_introspection_url", fallback=None)
if mock_introspection_url is not None:
self.MockIntrospectionUrl = mock_introspection_url
introspection_url = Config.get("auth", "introspection_url", fallback=None)
if introspection_url is not None:
self.IntrospectionUrl = introspection_url
L.warning(
"AuthService is running in MOCK MODE. Web requests will be authorized with direct introspection "
"call to {!r}.".format(self.MockIntrospectionUrl)
"call to {!r}.".format(self.IntrospectionUrl)
)
return

Expand Down Expand Up @@ -271,12 +271,12 @@ async def get_bearer_token_from_authorization_header(self, request):
Validate the Authorizetion header and extract the Bearer token value
"""
if self.Mode == AuthMode.MOCK:
if not self.MockIntrospectionUrl:
if not self.IntrospectionUrl:
return "MOCK"

# Send the request headers for introspection
async with aiohttp.ClientSession() as session:
async with session.post(self.MockIntrospectionUrl, headers=request.headers) as response:
async with session.post(self.IntrospectionUrl, headers=request.headers) as response:
if response.status != 200:
L.warning("Access token introspection failed.")
raise aiohttp.web.HTTPUnauthorized()
Expand Down

0 comments on commit eb7dfdd

Please sign in to comment.