Skip to content

Commit

Permalink
use the dependancy injection
Browse files Browse the repository at this point in the history
  • Loading branch information
pboers1988 committed Jan 17, 2023
1 parent 629d8ff commit fbf4f7f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.2.0
current_version = 1.2.1
commit = False
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+)(?P<build>\d+))?
Expand Down
2 changes: 1 addition & 1 deletion oauth2_lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@

"""This is the SURF Oauth2 module that interfaces with the oauth2 setup."""

__version__ = "1.2.0"
__version__ = "1.2.1"
6 changes: 4 additions & 2 deletions oauth2_lib/fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,8 @@ def opa_graphql_decision(
) -> Callable[[str, OIDCUserModel], Coroutine[Any, Any, bool | None]]:
async def _opa_decision(
path: str,
oidc_user: OIDCUserModel,
oidc_user: OIDCUserModel = Depends(_oidc_security),
async_request: AsyncClient = Depends(async_client),
) -> bool | None:
"""
Check OIDCUserModel against the OPA policy.
Expand All @@ -389,6 +390,7 @@ async def _opa_decision(
Args:
path: the graphql path that will be checked against the permissions of the oidc_user
oidc_user: The OIDCUserModel object that will be checked
aysnc_request: The httpx client.
"""
if enabled:
opa_input = {
Expand All @@ -403,7 +405,7 @@ async def _opa_decision(
logger.debug("Posting input json to Policy agent", input=opa_input)

try:
result = await AsyncClient(http1=True).post(opa_url, json=opa_input)
result = await async_request.post(opa_url, json=opa_input)
except (NetworkError, TypeError):
raise HTTPException(status_code=HTTPStatus.SERVICE_UNAVAILABLE, detail="Policy agent is unavailable")

Expand Down

0 comments on commit fbf4f7f

Please sign in to comment.