-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
14 changed files
with
266 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from fastapi import APIRouter, Depends | ||
from sqlalchemy.ext.asyncio import AsyncSession | ||
|
||
from app import crud, models, schemas | ||
from app.api import deps | ||
from app.core import config | ||
|
||
router = APIRouter() | ||
|
||
|
||
@router.get("/oauth2-providers", response_model=list[schemas.OAuth2ProviderPublic]) | ||
async def list_oauth2_providers() -> list[schemas.OAuth2ProviderPublic]: | ||
"""Retrieve all admin messages""" | ||
providers = [ | ||
schemas.OAuth2ProviderPublic.model_validate(obj.model_dump()) | ||
for obj in config.settings.OAUTH2_PROVIDERS | ||
] | ||
return providers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,12 @@ | |
import secrets | ||
from typing import Any | ||
|
||
from pydantic import AnyHttpUrl, EmailStr, HttpUrl, PostgresDsn, field_validator | ||
from pydantic import AnyHttpUrl, BaseModel, EmailStr, HttpUrl, PostgresDsn, field_validator | ||
from pydantic_core.core_schema import ValidationInfo | ||
from pydantic_settings import BaseSettings, SettingsConfigDict | ||
|
||
from app.schemas import OAuth2ProviderConfig | ||
|
||
|
||
class Settings(BaseSettings): | ||
model_config = SettingsConfigDict( | ||
|
@@ -95,6 +97,9 @@ def assemble_cors_origins(cls, v: str | list[str]) -> list[str] | str: # pragma | |
#: Email of test users, ignored. | ||
EMAIL_TEST_USER: EmailStr = "[email protected]" # type: ignore | ||
|
||
#: OAuth2 providers | ||
OAUTH2_PROVIDERS: list[OAuth2ProviderConfig] = [] | ||
|
||
# -- Database Configuration ---------------------------------------------- | ||
|
||
# Note that when os.environ["CI"] is "true" then we will use an in-memory | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from app.schemas.adminmsg import AdminMessageCreate, AdminMessageRead, AdminMessageUpdate # noqa | ||
from app.schemas.auth import OAuth2ProviderConfig, OAuth2ProviderPublic # noqa | ||
from app.schemas.user import UserCreate, UserRead, UserUpdate # noqa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from pydantic import BaseModel, HttpUrl | ||
|
||
|
||
class OAuth2ProviderBase(BaseModel): | ||
"""Base class for OAuth2 providers infos.""" | ||
|
||
#: Name of the identity provider. | ||
name: str | ||
#: Label to display to users | ||
label: str | ||
|
||
|
||
class OAuth2ProviderPublic(OAuth2ProviderBase): | ||
"""Information exposed via API.""" | ||
|
||
|
||
class OAuth2ProviderConfig(OAuth2ProviderBase): | ||
"""OAuth2 provider configuration with client secrets.""" | ||
|
||
#: Configuration URL of the provider. | ||
config_url: HttpUrl | ||
#: Client ID to use. | ||
client_id: str | ||
#: Client secret to use. | ||
client_secret: str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# Application configuration | ||
SERVER_NAME=localhost | ||
SERVER_HOST=http://localhost:8080 | ||
SERVER_HOST=http://localhost:8081 | ||
BACKEND_CORS_ORIGINS=["http://localhost:8081"] | ||
DEBUG=1 | ||
|
||
|
@@ -17,6 +17,9 @@ BACKEND_PREFIX_MEHARI=http://localhost:3002 | |
BACKEND_PREFIX_VIGUNO=http://localhost:3003 | ||
BACKEND_PREFIX_NGINX=http://localhost:3004 | ||
|
||
# Access to redis as it runs Docker Compose. | ||
REDIS_URL=redis://localhost:3030 | ||
|
||
# Superuser to setup on startup | ||
[email protected] | ||
FIRST_SUPERUSER_PASSWORD=password |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.