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...
| 142 | |
| 143 | |
| 144 | class 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 |
no outgoing calls
no test coverage detected