Skip to content

Commit

Permalink
Reach feature parity with legacyapi
Browse files Browse the repository at this point in the history
  • Loading branch information
hellais committed Mar 14, 2024
1 parent 96370ef commit 94bca8b
Show file tree
Hide file tree
Showing 8 changed files with 354 additions and 291 deletions.
6 changes: 6 additions & 0 deletions ooniapi/common/src/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ class Settings(BaseSettings):
statsd_port: int = 8125
statsd_prefix: str = "ooniapi"
jwt_encryption_key: str = "CHANGEME"
account_id_hashing_key: str = "CHANGEME"
prometheus_metrics_password: str = "CHANGEME"
session_expiry_days: int = 10
login_expiry_days: int = 10

aws_region: str = ""
aws_access_key_id: str = ""
aws_secret_access_key: str = ""
email_source_address: str = "[email protected]"
1 change: 1 addition & 0 deletions ooniapi/services/ooniauth/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/
3 changes: 2 additions & 1 deletion ooniapi/services/ooniauth/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ dependencies = [
"clickhouse-driver ~= 0.2.6",
"sqlalchemy ~= 2.0.27",
"ujson ~= 5.9.0",
"urllib3 ~= 2.1.0",
"python-dateutil ~= 2.8.2",
"pydantic-settings ~= 2.1.0",
"uvicorn ~= 0.25.0",
Expand All @@ -37,6 +36,8 @@ dependencies = [
"alembic ~= 1.13.1",
"prometheus-fastapi-instrumentator ~= 6.1.0",
"prometheus-client",
"email-validator",
"boto3 ~= 1.34.0",
]

[project.urls]
Expand Down
12 changes: 12 additions & 0 deletions ooniapi/services/ooniauth/src/ooniauth/dependencies.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from typing import Annotated

from clickhouse_driver import Client as ClickhouseClient
import boto3

from fastapi import Depends

from .common.dependencies import get_settings
Expand All @@ -10,3 +13,12 @@ def get_clickhouse_client(
settings: Annotated[Settings, Depends(get_settings)]
) -> ClickhouseClient:
return ClickhouseClient.from_url(settings.clickhouse_url)


def get_ses_client(settings: Annotated[Settings, Depends(get_settings)]):
return boto3.client(
"ses",
region_name=settings.aws_region,
aws_access_key_id=settings.aws_access_key_id,
aws_secret_access_key=settings.aws_secret_access_key,
)
6 changes: 3 additions & 3 deletions ooniapi/services/ooniauth/src/ooniauth/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from prometheus_fastapi_instrumentator import Instrumentator

from .routers import ooniauth
from .routers import v1

from .common.dependencies import get_settings
from .common.version import get_build_label, get_pkg_version
Expand All @@ -32,7 +32,7 @@ async def lifespan(app: FastAPI):
app = FastAPI(lifespan=lifespan)

instrumentor = Instrumentator().instrument(
app, metric_namespace="ooniapi", metric_subsystem="oonirun"
app, metric_namespace="ooniapi", metric_subsystem="ooniauth"
)

# TODO: temporarily enable all
Expand All @@ -45,7 +45,7 @@ async def lifespan(app: FastAPI):
allow_headers=["*"],
)

app.include_router(ooniauth.router, prefix="/api")
app.include_router(v1.router, prefix="/api")


@app.get("/version")
Expand Down
286 changes: 0 additions & 286 deletions ooniapi/services/ooniauth/src/ooniauth/routers/ooniauth.py

This file was deleted.

Loading

0 comments on commit 94bca8b

Please sign in to comment.