Skip to content

Commit 32f04cd

Browse files
committed
Fixing pre-commit errors
1 parent 72b9aaa commit 32f04cd

5 files changed

Lines changed: 17 additions & 33 deletions

File tree

bluesky_httpserver/app.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from fastapi.middleware.cors import CORSMiddleware
1616
from fastapi.openapi.utils import get_openapi
1717

18-
from .protocols import ExternalAuthenticator, InternalAuthenticator
1918
from .authenticators import ProxiedOIDCAuthenticator
2019
from .console_output import (
2120
CollectPublishedConsoleOutput,
@@ -24,6 +23,7 @@
2423
)
2524
from .core import PatchedStreamingResponse
2625
from .database.core import purge_expired
26+
from .protocols import ExternalAuthenticator, InternalAuthenticator
2727
from .resources import SERVER_RESOURCES as SR
2828
from .routers import core_api
2929
from .settings import get_settings
@@ -163,9 +163,9 @@ def build_app(authentication=None, api_access=None, resource_access=None, server
163163
logger.info("All custom routers are included successfully.")
164164

165165
from .authentication import (
166-
base_authentication_router,
167-
add_internal_routes,
168166
add_external_routes,
167+
add_internal_routes,
168+
base_authentication_router,
169169
oauth2_scheme,
170170
)
171171

bluesky_httpserver/authentication.py

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747

4848
from . import schemas
4949
from .authorization._defaults import _DEFAULT_ANONYMOUS_PROVIDER_NAME
50-
from .protocols import InternalAuthenticator
5150
from .core import json_or_msgpack
5251
from .database import orm
5352
from .database.core import (
@@ -59,6 +58,7 @@
5958
lookup_valid_pending_session_by_user_code,
6059
lookup_valid_session,
6160
)
61+
from .protocols import InternalAuthenticator
6262
from .settings import get_sessionmaker, get_settings
6363
from .utils import (
6464
API_KEY_COOKIE_NAME,
@@ -676,9 +676,7 @@ async def auth_code(
676676
return auth_code
677677

678678

679-
def add_internal_routes(
680-
router: APIRouter, provider: str, authenticator: InternalAuthenticator
681-
):
679+
def add_internal_routes(router: APIRouter, provider: str, authenticator: InternalAuthenticator):
682680
"Register a handle_credentials route function for this Authenticator."
683681

684682
@router.post(f"/provider/{provider}/token")
@@ -715,36 +713,21 @@ async def handle_credentials(
715713

716714
return handle_credentials
717715

718-
def add_external_routes(
719-
router: APIRouter, provider: str, authenticator: InternalAuthenticator
720-
):
721-
router.get(f"/provider/{provider}/code")(
722-
build_auth_code_route(authenticator, provider)
723-
)
724-
router.post(f"/provider/{provider}/code")(
725-
build_auth_code_route(authenticator, provider)
726-
)
716+
717+
def add_external_routes(router: APIRouter, provider: str, authenticator: InternalAuthenticator):
718+
router.get(f"/provider/{provider}/code")(build_auth_code_route(authenticator, provider))
719+
router.post(f"/provider/{provider}/code")(build_auth_code_route(authenticator, provider))
727720
# Device code flow routes for CLI/headless clients
728721
# GET /authorize - redirects browser to OIDC provider
729-
router.get(f"/provider/{provider}/authorize")(
730-
build_authorize_route(authenticator, provider)
731-
)
722+
router.get(f"/provider/{provider}/authorize")(build_authorize_route(authenticator, provider))
732723
# POST /authorize - initiates device code flow (returns device_code, user_code, etc.)
733-
router.post(f"/provider/{provider}/authorize")(
734-
build_device_code_authorize_route(authenticator, provider)
735-
)
724+
router.post(f"/provider/{provider}/authorize")(build_device_code_authorize_route(authenticator, provider))
736725
# GET /device_code - shows user code entry form
737-
router.get(f"/provider/{provider}/device_code")(
738-
build_device_code_form_route(authenticator, provider)
739-
)
726+
router.get(f"/provider/{provider}/device_code")(build_device_code_form_route(authenticator, provider))
740727
# POST /device_code - handles user code submission after browser auth
741-
router.post(f"/provider/{provider}/device_code")(
742-
build_device_code_submit_route(authenticator, provider)
743-
)
728+
router.post(f"/provider/{provider}/device_code")(build_device_code_submit_route(authenticator, provider))
744729
# POST /token - CLI client polls this for tokens
745-
router.post(f"/provider/{provider}/token")(
746-
build_device_code_token_route(authenticator, provider)
747-
)
730+
router.post(f"/provider/{provider}/token")(build_device_code_token_route(authenticator, provider))
748731
# Warn if the operator forgot to configure a redirect target
749732
# for successful browser-based logins. Without it the user
750733
# will get a page of raw JSON instead of being sent to the UI.

bluesky_httpserver/tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
from cryptography.hazmat.primitives.asymmetric import rsa
1212
from jose.backends import RSAKey
1313
from respx import MockRouter
14-
from xprocess import ProcessStarter
1514
from sqlalchemy import create_engine
1615
from sqlalchemy.orm import sessionmaker
16+
from xprocess import ProcessStarter
1717

1818
import bluesky_httpserver.server as bqss
1919
from bluesky_httpserver.database.base import Base

bluesky_httpserver/tests/test_database.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
import uuid
44
from datetime import timedelta
55

6-
76
from bluesky_httpserver import schemas
87
from bluesky_httpserver.database import orm as db_orm
98
from bluesky_httpserver.database.core import (
109
create_user,
1110
get_or_create_principal,
1211
)
1312

13+
1414
def test_principal_carries_access_token_field():
1515
"""Externally-authenticated principals attach the raw OIDC access token
1616
so downstream services can perform OBO exchanges."""

bluesky_httpserver/tests/test_oidc_proxied_authenticators.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from bluesky_httpserver.authenticators import ProxiedOIDCAuthenticator
88

9+
910
@pytest.mark.filterwarnings("ignore::DeprecationWarning")
1011
class TestProxiedOIDCAuthenticator:
1112
"""Tests for ProxiedOIDCAuthenticator class."""

0 commit comments

Comments
 (0)