Skip to content

Commit 6230904

Browse files
Igoranzepboers1988
andauthored
HTTPBearer token is set, Auth button not shown on /api/docs (#758)
* Fix: Authenticate refactor for GraphQL and other * linting * tmp: add remote oauth2-lib branch * fix: add brach oauth2-lib auth-b-shown * Refactor: make it utilize existing class * tmp: Fix lib import and unit test * fix: linting * Fix: linting imports * Fix: failing tests * update pyproject * Fix: HTTPBearerExtractor * Bump version and update oauth2-lib to 2.3.0 * version RC4 * set version pydantic-forms to 1.1.0 since 1.1.1 has breaking changes --------- Co-authored-by: Peter Boers <[email protected]>
1 parent d5f46ba commit 6230904

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 2.8.0rc3
2+
current_version = 2.8.0rc4
33
commit = False
44
tag = False
55
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(rc(?P<build>\d+))?

orchestrator/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
"""This is the orchestrator workflow engine."""
1515

16-
__version__ = "2.8.0rc3"
16+
__version__ = "2.8.0rc4"
1717

1818
from orchestrator.app import OrchestratorCore
1919
from orchestrator.settings import app_settings

orchestrator/security.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@
1414

1515
from authlib.integrations.starlette_client import OAuth
1616
from fastapi import Depends
17+
from fastapi.security.http import HTTPAuthorizationCredentials
1718
from starlette.requests import Request
1819
from starlette.websockets import WebSocket
1920

2021
from nwastdlib.url import URL
21-
from oauth2_lib.fastapi import (
22-
HTTPX_SSL_CONTEXT,
23-
OIDCUserModel,
24-
)
22+
from oauth2_lib.fastapi import HTTPX_SSL_CONTEXT, HttpBearerExtractor, OIDCUserModel
2523
from oauth2_lib.settings import oauth2lib_settings
2624

2725
oauth_client_credentials = OAuth()
@@ -35,9 +33,15 @@
3533
client_kwargs={"verify": HTTPX_SSL_CONTEXT},
3634
)
3735

36+
http_bearer_extractor = HttpBearerExtractor(auto_error=False)
37+
3838

39-
async def authenticate(request: Request) -> OIDCUserModel | None:
40-
return await request.app.auth_manager.authentication.authenticate(request)
39+
async def authenticate(
40+
request: Request,
41+
http_auth_credentials: Annotated[HTTPAuthorizationCredentials | None, Depends(http_bearer_extractor)] = None,
42+
) -> OIDCUserModel | None:
43+
token = http_auth_credentials.credentials if http_auth_credentials else None
44+
return await request.app.auth_manager.authentication.authenticate(request, token)
4145

4246

4347
async def authorize(request: Request, user: Annotated[OIDCUserModel | None, Depends(authenticate)]) -> bool | None:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ dependencies = [
6161
"typer==0.12.5",
6262
"uvicorn[standard]~=0.32.0",
6363
"nwa-stdlib~=1.7.3",
64-
"oauth2-lib~=2.2.0",
64+
"oauth2-lib~=2.3.0",
6565
"tabulate==0.9.0",
6666
"strawberry-graphql==0.232.2",
6767
"pydantic-forms~=1.1.1",

0 commit comments

Comments
 (0)