🚑 Fixed OAuth bug
This commit is contained in:
@@ -12,30 +12,35 @@ settings = settings()
|
|||||||
@lru_cache()
|
@lru_cache()
|
||||||
def init_oauth() -> OAuth:
|
def init_oauth() -> OAuth:
|
||||||
oauth = OAuth()
|
oauth = OAuth()
|
||||||
oauth.register(
|
if settings.google_client_secret is not None and settings.google_client_id is not None:
|
||||||
name="google",
|
oauth.register(
|
||||||
server_metadata_url="https://accounts.google.com/.well-known/openid-configuration",
|
name="google",
|
||||||
client_kwargs={"scope": "openid email profile"},
|
server_metadata_url="https://accounts.google.com/.well-known/openid-configuration",
|
||||||
client_id=settings.google_client_id,
|
client_kwargs={"scope": "openid email profile"},
|
||||||
client_secret=settings.google_client_secret,
|
client_id=settings.google_client_id,
|
||||||
)
|
client_secret=settings.google_client_secret,
|
||||||
|
)
|
||||||
oauth.register(
|
if settings.github_client_id is not None and settings.github_client_secret is not None:
|
||||||
name="github",
|
oauth.register(
|
||||||
client_kwargs={"scope": "read:user user:email"},
|
name="github",
|
||||||
access_token_url="https://github.com/login/oauth/access_token",
|
client_kwargs={"scope": "read:user user:email"},
|
||||||
access_token_params=None,
|
access_token_url="https://github.com/login/oauth/access_token",
|
||||||
authorize_url="https://github.com/login/oauth/authorize",
|
access_token_params=None,
|
||||||
authorize_params=None,
|
authorize_url="https://github.com/login/oauth/authorize",
|
||||||
api_base_url="https://api.github.com/",
|
authorize_params=None,
|
||||||
client_id=settings.github_client_id,
|
api_base_url="https://api.github.com/",
|
||||||
client_secret=settings.github_client_secret,
|
client_id=settings.github_client_id,
|
||||||
)
|
client_secret=settings.github_client_secret,
|
||||||
oauth.register(
|
)
|
||||||
name="custom",
|
if (
|
||||||
client_kwargs={"scope": settings.custom_openid_provider.scopes},
|
settings.custom_openid_provider.client_id is not None
|
||||||
server_metadata_url=settings.custom_openid_provider.server_metadata_url,
|
and settings.custom_openid_provider.client_secret is not None
|
||||||
client_id=settings.custom_openid_provider.client_id,
|
):
|
||||||
client_secret=settings.custom_openid_provider.client_secret,
|
oauth.register(
|
||||||
)
|
name="custom",
|
||||||
|
client_kwargs={"scope": settings.custom_openid_provider.scopes},
|
||||||
|
server_metadata_url=settings.custom_openid_provider.server_metadata_url,
|
||||||
|
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