✨ Added some files and config for openid
This commit is contained in:
+9
-1
@@ -6,13 +6,20 @@ from functools import lru_cache
|
|||||||
|
|
||||||
from redis import asyncio as redis_lib
|
from redis import asyncio as redis_lib
|
||||||
import redis as redis_base_lib
|
import redis as redis_base_lib
|
||||||
from pydantic import BaseSettings, RedisDsn, PostgresDsn
|
from pydantic import BaseSettings, RedisDsn, PostgresDsn, BaseModel
|
||||||
import meilisearch as MeiliSearch
|
import meilisearch as MeiliSearch
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from classquiz.storage import Storage
|
from classquiz.storage import Storage
|
||||||
|
|
||||||
|
|
||||||
|
class CustomOpenIDProvider(BaseModel):
|
||||||
|
scopes: str = "openid email profile"
|
||||||
|
server_metadata_url: str
|
||||||
|
client_id: str
|
||||||
|
client_secret: str
|
||||||
|
|
||||||
|
|
||||||
class Settings(BaseSettings):
|
class Settings(BaseSettings):
|
||||||
"""
|
"""
|
||||||
Settings class for the shop app.
|
Settings class for the shop app.
|
||||||
@@ -39,6 +46,7 @@ class Settings(BaseSettings):
|
|||||||
google_client_secret: Optional[str]
|
google_client_secret: Optional[str]
|
||||||
github_client_id: Optional[str]
|
github_client_id: Optional[str]
|
||||||
github_client_secret: Optional[str]
|
github_client_secret: Optional[str]
|
||||||
|
custom_openid_provider: CustomOpenIDProvider | None = None
|
||||||
telemetry_enabled: bool = True
|
telemetry_enabled: bool = True
|
||||||
|
|
||||||
# storage_backend
|
# storage_backend
|
||||||
|
|||||||
@@ -31,4 +31,11 @@ def init_oauth() -> OAuth:
|
|||||||
client_id=settings.github_client_id,
|
client_id=settings.github_client_id,
|
||||||
client_secret=settings.github_client_secret,
|
client_secret=settings.github_client_secret,
|
||||||
)
|
)
|
||||||
|
oauth.register(
|
||||||
|
name="custom",
|
||||||
|
client_kwargs={"scope": settings.custom_openid_provider.scopes},
|
||||||
|
server_metadata_url=settings.custom_openid_provider,
|
||||||
|
client_id=settings.custom_openid_provider.client_id,
|
||||||
|
client_secret=settings.custom_openid_provider.client_secret,
|
||||||
|
)
|
||||||
return oauth
|
return oauth
|
||||||
|
|||||||
Reference in New Issue
Block a user