MCPcopy
hub / github.com/diffgram/diffgram / OAuth2Provider

Class OAuth2Provider

shared/auth/OAuth2Provider.py:144–168  ·  view source on GitHub ↗

Factory Class For OIDC Clients implementation. Depending on the setting set in settings.OIDC_PROVIDER_NAME this class will instantiatiate a different client oidc provider implementation for users to manage login, registration, token refresh, etc...

Source from the content-addressed store, hash-verified

142
143
144class OAuth2Provider(metaclass = Singleton):
145 """
146 Factory Class For OIDC Clients implementation.
147 Depending on the setting set in settings.OIDC_PROVIDER_NAME
148 this class will instantiatiate a different client oidc provider implementation for
149 users to manage login, registration, token refresh, etc...
150 """
151 oidc_client: OAuth2ClientBase
152
153 def __init__(self):
154 from shared.auth.KeycloakDiffgramClient import KeycloakDiffgramClient
155 from shared.auth.CognitoDiffgramClient import CognitoDiffgramClient
156
157 provider = settings.OAUTH2_PROVIDER_NAME
158
159 if not provider:
160 raise ValueError("No DIFFGRAM_STATIC_STORAGE_PROVIDER env var set. valid values are [gcp, aws, azure]")
161
162 if provider == 'keycloak':
163 self.oidc_client = KeycloakDiffgramClient()
164 if provider == 'cognito':
165 self.oidc_client = CognitoDiffgramClient()
166
167 def get_client(self):
168 return self.oidc_client

Callers 9

oauth2_is_setFunction · 0.90
api_oidc_callbackFunction · 0.90
oauth2_logoutFunction · 0.90
set_jwt_in_sessionFunction · 0.90
try_refreshing_tokensFunction · 0.90
get_user_from_oauth2Function · 0.90
check_oauth2_setupFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected