Skip to content

Commit

Permalink
fix/allow single tenant app (Chainlit#443)
Browse files Browse the repository at this point in the history
Co-authored-by: Clément Sirieix <[email protected]>
  • Loading branch information
clementsirieix and Clément Sirieix authored Oct 2, 2023
1 parent 17d38a7 commit f951614
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions backend/chainlit/oauth_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,16 @@ class AzureADOAuthProvider(OAuthProvider):
"OAUTH_AZURE_AD_CLIENT_SECRET",
"OAUTH_AZURE_AD_TENANT_ID",
]
authorize_url = "https://login.microsoftonline.com/common/oauth2/v2.0/authorize"
authorize_url = (
f"https://login.microsoftonline.com/{os.environ.get('OAUTH_AZURE_AD_TENANT_ID', '')}/oauth2/v2.0/authorize"
if os.environ.get("OAUTH_AZURE_AD_ENABLE_SINGLE_TENANT")
else "https://login.microsoftonline.com/common/oauth2/v2.0/authorize"
)
token_url = (
f"https://login.microsoftonline.com/{os.environ.get('OAUTH_AZURE_AD_TENANT_ID', '')}/oauth2/v2.0/token"
if os.environ.get("OAUTH_AZURE_AD_ENABLE_SINGLE_TENANT")
else "https://login.microsoftonline.com/common/oauth2/v2.0/token"
)

def __init__(self):
self.client_id = os.environ.get("OAUTH_AZURE_AD_CLIENT_ID")
Expand All @@ -169,7 +178,7 @@ async def get_token(self, code: str, url: str):
trust_env=True, raise_for_status=True
) as session:
async with session.post(
"https://login.microsoftonline.com/common/oauth2/v2.0/token",
self.token_url,
data=payload,
) as result:
json = await result.json()
Expand Down

0 comments on commit f951614

Please sign in to comment.