Skip to content

Commit db3325b

Browse files
committed
Stop the machines complaining
1 parent e04a77b commit db3325b

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

src/blueapi/service/authorization.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ async def check(self, endpoint: str, data: Mapping[str, Any]):
4242
raise
4343

4444
async def require_tiled_service_account(self, token: str):
45-
await self.check(
46-
self._conf.tiled_service_account_check, {"token": token}
47-
)
45+
await self.check(self._conf.tiled_service_account_check, {"token": token})
4846

4947
async def submit_plan_check(self, token: str, instrument_session: str):
5048
if not (match := INSTRUMENT_SESSION_RE.match(instrument_session)):

src/blueapi/service/main.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from contextlib import asynccontextmanager
55
from typing import Annotated, Any, cast
66

7-
from fastapi.security.utils import get_authorization_scheme_param
87
import jwt
98
from fastapi import (
109
APIRouter,
@@ -20,7 +19,7 @@
2019
from fastapi.datastructures import Address
2120
from fastapi.middleware.cors import CORSMiddleware
2221
from fastapi.responses import RedirectResponse, StreamingResponse
23-
from fastapi.security import OAuth2AuthorizationCodeBearer
22+
from fastapi.security.utils import get_authorization_scheme_param
2423
from observability_utils.tracing import (
2524
add_span_attributes,
2625
get_tracer,
@@ -42,6 +41,7 @@
4241
from blueapi.worker import TrackableTask, WorkerState
4342
from blueapi.worker.event import TaskStatusEnum
4443

44+
from .authorization import OpaClient, OpaUserClient
4545
from .model import (
4646
DeviceModel,
4747
DeviceResponse,
@@ -58,7 +58,6 @@
5858
TasksListResponse,
5959
WorkerTask,
6060
)
61-
from .authorization import OpaClient, OpaUserClient
6261
from .runner import WorkerDispatcher
6362

6463
RUNNER: WorkerDispatcher | None = None
@@ -181,8 +180,10 @@ def inner(request: Request, access_token: Annotated[str, Depends(bearer_token)])
181180
async def opa(
182181
request: Request, token: Annotated[str, Depends(bearer_token)]
183182
) -> OpaUserClient | None:
184-
if client := cast(OpaClient | None, getattr(request.app.state, "authz", None)):
183+
if client := cast(OpaClient, getattr(request.app.state, "authz", None)):
185184
return client.for_token(token)
185+
return None
186+
186187

187188
async def submit_permission(
188189
task_request: Annotated[TaskRequest, Body()],

0 commit comments

Comments
 (0)