Skip to content

Commit 78b75a0

Browse files
committed
Breakout into files
1 parent aa30f7d commit 78b75a0

File tree

4 files changed

+43
-36
lines changed

4 files changed

+43
-36
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from .auth import OidcAuth # noqa
2+
from .config import AuthSettings # noqa
3+
4+
__version__ = "0.1.0"

runtimes/eoapi/auth/eoapi/auth.py renamed to runtimes/eoapi/auth/eoapi/auth/auth.py

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,17 @@
22
import logging
33
import urllib.request
44
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
66

77
import jwt
88
from fastapi import HTTPException, Security, routing, security, status
99
from fastapi.dependencies.utils import get_parameterless_sub_dependant
1010
from fastapi.security.base import SecurityBase
1111
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]
2712

13+
from .types import OidcFetchError
2814

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__)
4516

4617

4718
@dataclass
@@ -172,7 +143,3 @@ def apply_auth_dependencies(
172143
# https://github.com/tiangolo/fastapi/blob/58ab733f19846b4875c5b79bfb1f4d1cb7f4823f/fastapi/applications.py#L337-L360
173144
# https://github.com/tiangolo/fastapi/blob/58ab733f19846b4875c5b79bfb1f4d1cb7f4823f/fastapi/routing.py#L677-L678
174145
api_route.dependencies.extend([depends])
175-
176-
177-
class OidcFetchError(Exception):
178-
pass
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from typing import Optional, Sequence
2+
3+
from pydantic import AnyHttpUrl
4+
from pydantic_settings import BaseSettings
5+
6+
7+
class AuthSettings(BaseSettings):
8+
# Swagger UI config for Authorization Code Flow
9+
client_id: str = ""
10+
use_pkce: bool = True
11+
openid_configuration_url: Optional[AnyHttpUrl] = None
12+
openid_configuration_internal_url: Optional[AnyHttpUrl] = None
13+
14+
allowed_jwt_audiences: Optional[Sequence[str]] = []
15+
16+
public_reads: bool = True
17+
18+
model_config = {
19+
"env_prefix": "EOAPI_AUTH_",
20+
"env_file": ".env",
21+
"extra": "allow",
22+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from typing import Optional, TypedDict
2+
3+
4+
class OidcFetchError(Exception):
5+
pass
6+
7+
8+
class Scope(TypedDict, total=False):
9+
"""More strict version of Starlette's Scope."""
10+
11+
# https://github.com/encode/starlette/blob/6af5c515e0a896cbf3f86ee043b88f6c24200bcf/starlette/types.py#L3
12+
path: str
13+
method: str
14+
type: Optional[str]

0 commit comments

Comments
 (0)