Skip to content

Commit 7c98abf

Browse files
committed
Add microsoft and github oauth
1 parent 3b34213 commit 7c98abf

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

scripts/local_with_uvicorn/.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,5 @@ TIER_NAME="free"
8080
# MICROSOFT_CLIENT_ID=
8181
# MICROSOFT_CLIENT_SECRET=
8282
# MICROSOFT_TENANT=
83+
# GITHUB_CLIENT_ID=
84+
# GITHUB_CLIENT_SECRET=

src/app/api/v1/oauth.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from fastapi import APIRouter, Depends, Request, Response
66
from fastapi_sso.sso.base import OpenID, SSOBase
7+
from fastapi_sso.sso.github import GithubSSO
78
from fastapi_sso.sso.google import GoogleSSO
89
from fastapi_sso.sso.microsoft import MicrosoftSSO
910
from sqlalchemy.ext.asyncio import AsyncSession
@@ -112,7 +113,6 @@ class GoogleOAuthProvider(BaseOAuthProvider):
112113
}
113114

114115

115-
# TODO: There is a bug in fastapi-sso, it does not return the email address
116116
class MicrosoftOAuthProvider(BaseOAuthProvider):
117117
sso_provider = MicrosoftSSO
118118
provider_config = {
@@ -122,5 +122,14 @@ class MicrosoftOAuthProvider(BaseOAuthProvider):
122122
}
123123

124124

125+
class GithubSSOProvider(BaseOAuthProvider):
126+
sso_provider = GithubSSO
127+
provider_config = {
128+
"client_id": settings.GITHUB_CLIENT_ID,
129+
"client_secret": settings.GITHUB_CLIENT_SECRET,
130+
}
131+
132+
125133
GoogleOAuthProvider(router)
126134
MicrosoftOAuthProvider(router)
135+
GithubSSOProvider(router)

src/app/core/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ class AuthSettings(BaseSettings):
148148
MICROSOFT_CLIENT_ID: str | None = None
149149
MICROSOFT_CLIENT_SECRET: str | None = None
150150
MICROSOFT_TENANT: str | None = None
151+
GITHUB_CLIENT_ID: str | None = None
152+
GITHUB_CLIENT_SECRET: str | None = None
151153

152154

153155
class Settings(

0 commit comments

Comments
 (0)