|
2 | 2 | import logging |
3 | 3 | import urllib.request |
4 | 4 | from dataclasses import dataclass, field |
5 | | -from typing import Annotated, Any, Callable, Dict, Optional, Sequence, TypedDict |
| 5 | +from typing import Annotated, Any, Callable, Dict, Optional, Sequence |
6 | 6 |
|
7 | 7 | import jwt |
8 | 8 | from fastapi import HTTPException, Security, routing, security, status |
9 | 9 | from fastapi.dependencies.utils import get_parameterless_sub_dependant |
10 | 10 | from fastapi.security.base import SecurityBase |
11 | 11 | from pydantic import AnyHttpUrl |
12 | | -from pydantic_settings import BaseSettings |
13 | | - |
14 | | -logger = logging.getLogger(__name__) |
15 | | - |
16 | | - |
17 | | -__version__ = "0.1.0" |
18 | | - |
19 | | - |
20 | | -class Scope(TypedDict, total=False): |
21 | | - """More strict version of Starlette's Scope.""" |
22 | | - |
23 | | - # https://github.com/encode/starlette/blob/6af5c515e0a896cbf3f86ee043b88f6c24200bcf/starlette/types.py#L3 |
24 | | - path: str |
25 | | - method: str |
26 | | - type: Optional[str] |
27 | 12 |
|
| 13 | +from .types import OidcFetchError |
28 | 14 |
|
29 | | -class AuthSettings(BaseSettings): |
30 | | - # Swagger UI config for Authorization Code Flow |
31 | | - client_id: str = "" |
32 | | - use_pkce: bool = True |
33 | | - openid_configuration_url: Optional[AnyHttpUrl] = None |
34 | | - openid_configuration_internal_url: Optional[AnyHttpUrl] = None |
35 | | - |
36 | | - allowed_jwt_audiences: Optional[Sequence[str]] = [] |
37 | | - |
38 | | - public_reads: bool = True |
39 | | - |
40 | | - model_config = { |
41 | | - "env_prefix": "EOAPI_AUTH_", |
42 | | - "env_file": ".env", |
43 | | - "extra": "allow", |
44 | | - } |
| 15 | +logger = logging.getLogger(__name__) |
45 | 16 |
|
46 | 17 |
|
47 | 18 | @dataclass |
@@ -172,7 +143,3 @@ def apply_auth_dependencies( |
172 | 143 | # https://github.com/tiangolo/fastapi/blob/58ab733f19846b4875c5b79bfb1f4d1cb7f4823f/fastapi/applications.py#L337-L360 |
173 | 144 | # https://github.com/tiangolo/fastapi/blob/58ab733f19846b4875c5b79bfb1f4d1cb7f4823f/fastapi/routing.py#L677-L678 |
174 | 145 | api_route.dependencies.extend([depends]) |
175 | | - |
176 | | - |
177 | | -class OidcFetchError(Exception): |
178 | | - pass |
0 commit comments