|
27 | 27 | from ...post_init_callbacks import PostSTInitCallbacks |
28 | 28 |
|
29 | 29 | from .interfaces import ( |
30 | | - APIInterface, |
31 | 30 | APIOptions, |
32 | 31 | TypeGetAllowedDomainsForTenantId, |
33 | 32 | ) |
|
42 | 41 |
|
43 | 42 | from supertokens_python.normalised_url_path import NormalisedURLPath |
44 | 43 | from supertokens_python.querier import Querier |
45 | | -from supertokens_python.types import GeneralErrorResponse |
| 44 | +from supertokens_python.recipe.multitenancy.api.implementation import APIImplementation |
46 | 45 |
|
47 | 46 |
|
48 | 47 | from .api import handle_login_methods_api |
49 | 48 | from .constants import LOGIN_METHODS |
50 | 49 | from .exceptions import MultitenancyError |
51 | | -from .interfaces import ( |
52 | | - LoginMethodsGetOkResult, |
53 | | - ThirdPartyProvider, |
54 | | - LoginMethodEmailPassword, |
55 | | - LoginMethodPasswordless, |
56 | | - LoginMethodThirdParty, |
57 | | -) |
58 | 50 | from .utils import ( |
59 | 51 | InputOverrideConfig, |
60 | 52 | validate_and_normalise_user_input, |
@@ -196,65 +188,6 @@ def reset(): |
196 | 188 | MultitenancyRecipe.__instance = None |
197 | 189 |
|
198 | 190 |
|
199 | | -class APIImplementation(APIInterface): |
200 | | - async def login_methods_get( |
201 | | - self, |
202 | | - tenant_id: str, |
203 | | - client_type: Optional[str], |
204 | | - api_options: APIOptions, |
205 | | - user_context: Dict[str, Any], |
206 | | - ) -> Union[LoginMethodsGetOkResult, GeneralErrorResponse]: |
207 | | - from supertokens_python.recipe.thirdparty.providers.config_utils import ( |
208 | | - find_and_create_provider_instance, |
209 | | - merge_providers_from_core_and_static, |
210 | | - ) |
211 | | - from supertokens_python.recipe.thirdparty.exceptions import ( |
212 | | - ClientTypeNotFoundError, |
213 | | - ) |
214 | | - |
215 | | - tenant_config = await api_options.recipe_implementation.get_tenant( |
216 | | - tenant_id, user_context |
217 | | - ) |
218 | | - |
219 | | - if tenant_config is None: |
220 | | - raise Exception("Tenant not found") |
221 | | - |
222 | | - provider_inputs_from_static = api_options.static_third_party_providers |
223 | | - provider_configs_from_core = tenant_config.third_party.providers |
224 | | - |
225 | | - merged_providers = merge_providers_from_core_and_static( |
226 | | - provider_configs_from_core, provider_inputs_from_static |
227 | | - ) |
228 | | - |
229 | | - final_provider_list: List[ThirdPartyProvider] = [] |
230 | | - |
231 | | - for provider_input in merged_providers: |
232 | | - try: |
233 | | - provider_instance = await find_and_create_provider_instance( |
234 | | - merged_providers, |
235 | | - provider_input.config.third_party_id, |
236 | | - client_type, |
237 | | - user_context, |
238 | | - ) |
239 | | - |
240 | | - if provider_instance is None: |
241 | | - raise Exception("Should never come here") |
242 | | - |
243 | | - except ClientTypeNotFoundError: |
244 | | - continue |
245 | | - final_provider_list.append( |
246 | | - ThirdPartyProvider(provider_instance.id, provider_instance.config.name) |
247 | | - ) |
248 | | - |
249 | | - return LoginMethodsGetOkResult( |
250 | | - LoginMethodEmailPassword(tenant_config.emailpassword.enabled), |
251 | | - LoginMethodPasswordless(tenant_config.passwordless.enabled), |
252 | | - LoginMethodThirdParty( |
253 | | - tenant_config.third_party.enabled, final_provider_list |
254 | | - ), |
255 | | - ) |
256 | | - |
257 | | - |
258 | 191 | class AllowedDomainsClaimClass(PrimitiveArrayClaim[List[str]]): |
259 | 192 | def __init__(self): |
260 | 193 | default_max_age_in_sec = 60 * 60 |
|
0 commit comments