Skip to content
Snippets Groups Projects
Commit 36f9bd64 authored by Mohammad Torkashvand's avatar Mohammad Torkashvand
Browse files

add client_id to the user_info sent to opa

parent 3f267ddd
No related branches found
No related tags found
No related merge requests found
Pipeline #86192 failed
...@@ -11,6 +11,7 @@ FastAPI to ensure secure API development. ...@@ -11,6 +11,7 @@ FastAPI to ensure secure API development.
import re import re
import ssl import ssl
from collections.abc import AsyncGenerator, Awaitable, Callable, Mapping from collections.abc import AsyncGenerator, Awaitable, Callable, Mapping
from enum import StrEnum
from http import HTTPStatus from http import HTTPStatus
from json import JSONDecodeError from json import JSONDecodeError
from typing import Any, ClassVar, cast from typing import Any, ClassVar, cast
...@@ -92,6 +93,11 @@ class OIDCUserModel(dict): ...@@ -92,6 +93,11 @@ class OIDCUserModel(dict):
return self.get(key) return self.get(key)
raise error from None raise error from None
@property
def client_id(self) -> str:
"""Return the token owner."""
return self.get("client_id")
@property @property
def user_name(self) -> str: def user_name(self) -> str:
"""Return the username of the user.""" """Return the username of the user."""
...@@ -236,6 +242,8 @@ class OIDCUser(HTTPBearer): ...@@ -236,6 +242,8 @@ class OIDCUser(HTTPBearer):
user_info = await self.userinfo(async_request, token) user_info = await self.userinfo(async_request, token)
user_info['client_id'] = intercepted_token.get("client_id")
logger.debug("OIDCUserModel object.", intercepted_token=intercepted_token) logger.debug("OIDCUserModel object.", intercepted_token=intercepted_token)
return user_info return user_info
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment