🚑 Fixed OAuth bug

This commit is contained in:
Mawoka
2023-05-05 21:19:08 +02:00
parent ceb6760b20
commit 5106392df8
+6 -1
View File
@@ -12,6 +12,7 @@ settings = settings()
@lru_cache() @lru_cache()
def init_oauth() -> OAuth: def init_oauth() -> OAuth:
oauth = OAuth() oauth = OAuth()
if settings.google_client_secret is not None and settings.google_client_id is not None:
oauth.register( oauth.register(
name="google", name="google",
server_metadata_url="https://accounts.google.com/.well-known/openid-configuration", server_metadata_url="https://accounts.google.com/.well-known/openid-configuration",
@@ -19,7 +20,7 @@ def init_oauth() -> OAuth:
client_id=settings.google_client_id, client_id=settings.google_client_id,
client_secret=settings.google_client_secret, client_secret=settings.google_client_secret,
) )
if settings.github_client_id is not None and settings.github_client_secret is not None:
oauth.register( oauth.register(
name="github", name="github",
client_kwargs={"scope": "read:user user:email"}, client_kwargs={"scope": "read:user user:email"},
@@ -31,6 +32,10 @@ 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,
) )
if (
settings.custom_openid_provider.client_id is not None
and settings.custom_openid_provider.client_secret is not None
):
oauth.register( oauth.register(
name="custom", name="custom",
client_kwargs={"scope": settings.custom_openid_provider.scopes}, client_kwargs={"scope": settings.custom_openid_provider.scopes},