├── .circleci ├── authReactDjango.sh ├── authReactFastApi.sh ├── authReactFlask.sh ├── config.yml ├── config_continue.yml ├── doBackendSDKTests.sh ├── doUnitTests.sh ├── generateConfig.sh ├── installJava.sh ├── installNode.sh ├── markAsSuccess.sh ├── markDevTagAsTestNotPassed.sh ├── setupAndTestBackendSDKWithFreeCore.sh ├── setupAndTestWithAuthReact.sh ├── setupAndTestWithAuthReactWithDjango.sh ├── setupAndTestWithAuthReactWithFlask.sh ├── setupAndTestWithFreeCore.sh ├── setupAndTestWithFrontend.sh ├── setupAndTestWithFrontendWithDjango.sh ├── setupAndTestWithFrontendWithDjango2x.sh ├── setupAndTestWithFrontendWithDrfAsync.sh ├── setupAndTestWithFrontendWithDrfSync.sh ├── setupAndTestWithFrontendWithFlask.sh ├── updateDocsInWebsite.sh ├── websiteDjango.sh ├── websiteDjango2x.sh ├── websiteDrfAsync.sh ├── websiteDrfSync.sh ├── websiteFastApi.sh └── websiteFlask.sh ├── .cursorrules ├── .github ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── auth-react-test-1-django.yml │ ├── auth-react-test-1-fastapi.yml │ ├── auth-react-test-1-flask.yml │ ├── auth-react-test-2.yml │ ├── auth-react-test-3.yml │ ├── backend-sdk-testing.yml │ ├── lint-code.yml │ ├── lint-pr.yml │ ├── unit-test.yml │ └── website-test.yml ├── .gitignore ├── .pre-commit-config.yaml ├── .pylintrc ├── .vscode └── launch.json ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Dockerfile ├── LICENSE.md ├── Makefile ├── README.md ├── addDevTag ├── addReleaseTag ├── compose.yml ├── coreDriverInterfaceSupported.json ├── dev-requirements.txt ├── docs-templates ├── _lunr_search.inc.mako ├── config.mako ├── credits.mako ├── css.mako ├── head.mako ├── html.mako ├── logo.mako ├── pdf.mako ├── search.mako └── text.mako ├── examples ├── with-django │ └── with-thirdpartyemailpassword │ │ ├── .env │ │ ├── README.md │ │ ├── create_env.sh │ │ ├── manage.py │ │ ├── project │ │ ├── __init__.py │ │ ├── asgi.py │ │ ├── settings.py │ │ ├── urls.py │ │ └── wsgi.py │ │ ├── requirements.txt │ │ └── sampleapp │ │ ├── __init__.py │ │ ├── admin.py │ │ ├── apps.py │ │ ├── migrations │ │ └── __init__.py │ │ ├── models.py │ │ ├── urls.py │ │ └── views.py ├── with-fastapi │ └── with-thirdpartyemailpassword │ │ ├── .env │ │ ├── README.md │ │ ├── create_env.sh │ │ ├── main.py │ │ └── requirements.txt └── with-flask │ └── with-thirdpartyemailpassword │ ├── .env │ ├── README.md │ ├── app.py │ ├── create_env.sh │ └── requirements.txt ├── frontendDriverInterfaceSupported.json ├── hooks ├── check-branch.sh ├── check-version.sh ├── populate-hook-constants.sh └── pre-commit.sh ├── html └── supertokens_python │ ├── async_to_sync_wrapper.html │ ├── asyncio │ └── index.html │ ├── auth_utils.html │ ├── constants.html │ ├── env │ ├── base.html │ ├── index.html │ └── utils.html │ ├── exceptions.html │ ├── framework │ ├── django │ │ ├── django_middleware.html │ │ ├── django_request.html │ │ ├── django_response.html │ │ ├── framework.html │ │ └── index.html │ ├── fastapi │ │ ├── fastapi_middleware.html │ │ ├── fastapi_request.html │ │ ├── fastapi_response.html │ │ ├── framework.html │ │ └── index.html │ ├── flask │ │ ├── flask_middleware.html │ │ ├── flask_request.html │ │ ├── flask_response.html │ │ ├── framework.html │ │ └── index.html │ ├── index.html │ ├── request.html │ ├── response.html │ └── types.html │ ├── index.html │ ├── ingredients │ ├── emaildelivery │ │ ├── index.html │ │ ├── services │ │ │ ├── index.html │ │ │ └── smtp.html │ │ └── types.html │ ├── index.html │ └── smsdelivery │ │ ├── index.html │ │ ├── services │ │ ├── index.html │ │ ├── supertokens.html │ │ └── twilio.html │ │ └── types.html │ ├── interfaces.html │ ├── logger.html │ ├── normalised_url_domain.html │ ├── normalised_url_path.html │ ├── post_init_callbacks.html │ ├── process_state.html │ ├── querier.html │ ├── recipe │ ├── accountlinking │ │ ├── asyncio │ │ │ └── index.html │ │ ├── index.html │ │ ├── interfaces.html │ │ ├── recipe.html │ │ ├── recipe_implementation.html │ │ ├── syncio │ │ │ └── index.html │ │ ├── types.html │ │ └── utils.html │ ├── dashboard │ │ ├── api │ │ │ ├── analytics.html │ │ │ ├── dashboard.html │ │ │ ├── implementation.html │ │ │ ├── index.html │ │ │ ├── multitenancy │ │ │ │ ├── create_or_update_third_party_config.html │ │ │ │ ├── create_tenant.html │ │ │ │ ├── delete_tenant.html │ │ │ │ ├── delete_third_party_config.html │ │ │ │ ├── get_tenant_info.html │ │ │ │ ├── get_third_party_config.html │ │ │ │ ├── index.html │ │ │ │ ├── list_all_tenants_with_login_methods.html │ │ │ │ ├── update_tenant_core_config.html │ │ │ │ ├── update_tenant_first_factor.html │ │ │ │ ├── update_tenant_secondary_factor.html │ │ │ │ └── utils.html │ │ │ ├── search │ │ │ │ ├── getTags.html │ │ │ │ └── index.html │ │ │ ├── signin.html │ │ │ ├── signout.html │ │ │ ├── user │ │ │ │ ├── create │ │ │ │ │ ├── emailpassword_user.html │ │ │ │ │ ├── index.html │ │ │ │ │ └── passwordless_user.html │ │ │ │ └── index.html │ │ │ ├── userdetails │ │ │ │ ├── index.html │ │ │ │ ├── user_delete.html │ │ │ │ ├── user_email_verify_get.html │ │ │ │ ├── user_email_verify_put.html │ │ │ │ ├── user_email_verify_token_post.html │ │ │ │ ├── user_get.html │ │ │ │ ├── user_metadata_get.html │ │ │ │ ├── user_metadata_put.html │ │ │ │ ├── user_password_put.html │ │ │ │ ├── user_put.html │ │ │ │ ├── user_sessions_get.html │ │ │ │ ├── user_sessions_post.html │ │ │ │ └── user_unlink_get.html │ │ │ ├── userroles │ │ │ │ ├── add_role_to_user.html │ │ │ │ ├── get_role_to_user.html │ │ │ │ ├── index.html │ │ │ │ ├── permissions │ │ │ │ │ ├── get_permissions_for_role.html │ │ │ │ │ ├── index.html │ │ │ │ │ └── remove_permissions_from_role.html │ │ │ │ ├── remove_user_role.html │ │ │ │ └── roles │ │ │ │ │ ├── create_role_or_add_permissions.html │ │ │ │ │ ├── delete_role.html │ │ │ │ │ ├── get_all_roles.html │ │ │ │ │ └── index.html │ │ │ ├── users_count_get.html │ │ │ ├── users_get.html │ │ │ └── validate_key.html │ │ ├── constants.html │ │ ├── exceptions.html │ │ ├── index.html │ │ ├── interfaces.html │ │ ├── recipe.html │ │ ├── recipe_implementation.html │ │ └── utils.html │ ├── emailpassword │ │ ├── api │ │ │ ├── email_exists.html │ │ │ ├── generate_password_reset_token.html │ │ │ ├── implementation.html │ │ │ ├── index.html │ │ │ ├── password_reset.html │ │ │ ├── signin.html │ │ │ ├── signup.html │ │ │ └── utils.html │ │ ├── asyncio │ │ │ └── index.html │ │ ├── constants.html │ │ ├── emaildelivery │ │ │ ├── index.html │ │ │ └── services │ │ │ │ ├── backward_compatibility │ │ │ │ └── index.html │ │ │ │ ├── index.html │ │ │ │ └── smtp │ │ │ │ ├── index.html │ │ │ │ ├── password_reset.html │ │ │ │ ├── password_reset_email.html │ │ │ │ └── service_implementation │ │ │ │ └── index.html │ │ ├── exceptions.html │ │ ├── index.html │ │ ├── interfaces.html │ │ ├── recipe.html │ │ ├── recipe_implementation.html │ │ ├── syncio │ │ │ └── index.html │ │ ├── types.html │ │ └── utils.html │ ├── emailverification │ │ ├── api │ │ │ ├── email_verify.html │ │ │ ├── generate_email_verify_token.html │ │ │ └── index.html │ │ ├── asyncio │ │ │ └── index.html │ │ ├── constants.html │ │ ├── emaildelivery │ │ │ ├── index.html │ │ │ └── services │ │ │ │ ├── backward_compatibility │ │ │ │ └── index.html │ │ │ │ ├── index.html │ │ │ │ └── smtp │ │ │ │ ├── email_verify.html │ │ │ │ ├── email_verify_email.html │ │ │ │ ├── index.html │ │ │ │ └── service_implementation.html │ │ ├── exceptions.html │ │ ├── index.html │ │ ├── interfaces.html │ │ ├── recipe.html │ │ ├── recipe_implementation.html │ │ ├── syncio │ │ │ └── index.html │ │ ├── types.html │ │ └── utils.html │ ├── index.html │ ├── jwt │ │ ├── api │ │ │ ├── implementation.html │ │ │ ├── index.html │ │ │ └── jwks_get.html │ │ ├── asyncio │ │ │ └── index.html │ │ ├── constants.html │ │ ├── exceptions.html │ │ ├── index.html │ │ ├── interfaces.html │ │ ├── recipe.html │ │ ├── recipe_implementation.html │ │ ├── syncio │ │ │ └── index.html │ │ └── utils.html │ ├── multifactorauth │ │ ├── api │ │ │ ├── implementation.html │ │ │ ├── index.html │ │ │ └── resync_session_and_fetch_mfa_info.html │ │ ├── asyncio │ │ │ └── index.html │ │ ├── constants.html │ │ ├── index.html │ │ ├── interfaces.html │ │ ├── multi_factor_auth_claim.html │ │ ├── recipe.html │ │ ├── recipe_implementation.html │ │ ├── syncio │ │ │ └── index.html │ │ ├── types.html │ │ └── utils.html │ ├── multitenancy │ │ ├── api │ │ │ ├── implementation.html │ │ │ ├── index.html │ │ │ └── login_methods.html │ │ ├── asyncio │ │ │ └── index.html │ │ ├── constants.html │ │ ├── exceptions.html │ │ ├── index.html │ │ ├── interfaces.html │ │ ├── recipe.html │ │ ├── recipe_implementation.html │ │ ├── syncio │ │ │ └── index.html │ │ └── utils.html │ ├── oauth2provider │ │ ├── api │ │ │ ├── auth.html │ │ │ ├── end_session.html │ │ │ ├── implementation.html │ │ │ ├── index.html │ │ │ ├── introspect_token.html │ │ │ ├── login.html │ │ │ ├── login_info.html │ │ │ ├── logout.html │ │ │ ├── revoke_token.html │ │ │ ├── token.html │ │ │ ├── user_info.html │ │ │ └── utils.html │ │ ├── asyncio │ │ │ └── index.html │ │ ├── constants.html │ │ ├── exceptions.html │ │ ├── index.html │ │ ├── interfaces.html │ │ ├── oauth2_client.html │ │ ├── recipe.html │ │ ├── recipe_implementation.html │ │ ├── syncio │ │ │ └── index.html │ │ └── utils.html │ ├── openid │ │ ├── api │ │ │ ├── implementation.html │ │ │ ├── index.html │ │ │ └── open_id_discovery_configuration_get.html │ │ ├── asyncio │ │ │ └── index.html │ │ ├── constants.html │ │ ├── exceptions.html │ │ ├── index.html │ │ ├── interfaces.html │ │ ├── recipe.html │ │ ├── recipe_implementation.html │ │ ├── syncio │ │ │ └── index.html │ │ └── utils.html │ ├── passwordless │ │ ├── api │ │ │ ├── consume_code.html │ │ │ ├── create_code.html │ │ │ ├── email_exists.html │ │ │ ├── implementation.html │ │ │ ├── index.html │ │ │ ├── phone_number_exists.html │ │ │ └── resend_code.html │ │ ├── asyncio │ │ │ └── index.html │ │ ├── constants.html │ │ ├── emaildelivery │ │ │ ├── index.html │ │ │ └── services │ │ │ │ ├── backward_compatibility │ │ │ │ └── index.html │ │ │ │ ├── index.html │ │ │ │ └── smtp │ │ │ │ ├── index.html │ │ │ │ ├── pless_login.html │ │ │ │ ├── pless_login_email.html │ │ │ │ └── service_implementation.html │ │ ├── exceptions.html │ │ ├── index.html │ │ ├── interfaces.html │ │ ├── recipe.html │ │ ├── recipe_implementation.html │ │ ├── smsdelivery │ │ │ ├── index.html │ │ │ └── services │ │ │ │ ├── backward_compatibility │ │ │ │ └── index.html │ │ │ │ ├── index.html │ │ │ │ ├── supertokens │ │ │ │ └── index.html │ │ │ │ └── twilio │ │ │ │ ├── index.html │ │ │ │ ├── passwordless_login.html │ │ │ │ └── service_implementation.html │ │ ├── syncio │ │ │ └── index.html │ │ ├── types.html │ │ └── utils.html │ ├── session │ │ ├── access_token.html │ │ ├── api │ │ │ ├── implementation.html │ │ │ ├── index.html │ │ │ ├── refresh.html │ │ │ └── signout.html │ │ ├── asyncio │ │ │ └── index.html │ │ ├── claim_base_classes │ │ │ ├── boolean_claim.html │ │ │ ├── index.html │ │ │ ├── primitive_array_claim.html │ │ │ └── primitive_claim.html │ │ ├── claims.html │ │ ├── constants.html │ │ ├── cookie_and_header.html │ │ ├── exceptions.html │ │ ├── framework │ │ │ ├── django │ │ │ │ ├── asyncio │ │ │ │ │ └── index.html │ │ │ │ ├── index.html │ │ │ │ └── syncio │ │ │ │ │ └── index.html │ │ │ ├── fastapi │ │ │ │ └── index.html │ │ │ ├── flask │ │ │ │ └── index.html │ │ │ └── index.html │ │ ├── index.html │ │ ├── interfaces.html │ │ ├── jwks.html │ │ ├── jwt.html │ │ ├── recipe.html │ │ ├── recipe_implementation.html │ │ ├── session_class.html │ │ ├── session_functions.html │ │ ├── session_request_functions.html │ │ ├── syncio │ │ │ └── index.html │ │ └── utils.html │ ├── thirdparty │ │ ├── api │ │ │ ├── apple_redirect.html │ │ │ ├── authorisation_url.html │ │ │ ├── implementation.html │ │ │ ├── index.html │ │ │ └── signinup.html │ │ ├── asyncio │ │ │ └── index.html │ │ ├── constants.html │ │ ├── exceptions.html │ │ ├── index.html │ │ ├── interfaces.html │ │ ├── provider.html │ │ ├── providers │ │ │ ├── active_directory.html │ │ │ ├── apple.html │ │ │ ├── bitbucket.html │ │ │ ├── boxy_saml.html │ │ │ ├── config_utils.html │ │ │ ├── custom.html │ │ │ ├── discord.html │ │ │ ├── facebook.html │ │ │ ├── github.html │ │ │ ├── gitlab.html │ │ │ ├── google.html │ │ │ ├── google_workspaces.html │ │ │ ├── index.html │ │ │ ├── linkedin.html │ │ │ ├── okta.html │ │ │ ├── twitter.html │ │ │ └── utils.html │ │ ├── recipe.html │ │ ├── recipe_implementation.html │ │ ├── syncio │ │ │ └── index.html │ │ ├── types.html │ │ └── utils.html │ ├── totp │ │ ├── api │ │ │ ├── create_device.html │ │ │ ├── implementation.html │ │ │ ├── index.html │ │ │ ├── list_devices.html │ │ │ ├── remove_device.html │ │ │ ├── verify_device.html │ │ │ └── verify_totp.html │ │ ├── asyncio │ │ │ └── index.html │ │ ├── constants.html │ │ ├── index.html │ │ ├── interfaces.html │ │ ├── recipe.html │ │ ├── recipe_implementation.html │ │ ├── syncio │ │ │ └── index.html │ │ ├── types.html │ │ └── utils.html │ ├── usermetadata │ │ ├── asyncio │ │ │ └── index.html │ │ ├── exceptions.html │ │ ├── index.html │ │ ├── interfaces.html │ │ ├── recipe.html │ │ ├── recipe_implementation.html │ │ ├── syncio │ │ │ └── index.html │ │ └── utils.html │ └── userroles │ │ ├── asyncio │ │ └── index.html │ │ ├── exceptions.html │ │ ├── index.html │ │ ├── interfaces.html │ │ ├── recipe.html │ │ ├── recipe_implementation.html │ │ ├── syncio │ │ └── index.html │ │ └── utils.html │ ├── recipe_module.html │ ├── supertokens.html │ ├── syncio │ └── index.html │ ├── types.html │ └── utils.html ├── pyproject.toml ├── setup.cfg ├── setup.py ├── supertokens_python ├── __init__.py ├── async_to_sync_wrapper.py ├── asyncio │ └── __init__.py ├── auth_utils.py ├── constants.py ├── env │ ├── __init__.py │ ├── base.py │ └── utils.py ├── exceptions.py ├── framework │ ├── __init__.py │ ├── django │ │ ├── __init__.py │ │ ├── django_middleware.py │ │ ├── django_request.py │ │ ├── django_response.py │ │ └── framework.py │ ├── fastapi │ │ ├── __init__.py │ │ ├── fastapi_middleware.py │ │ ├── fastapi_request.py │ │ ├── fastapi_response.py │ │ └── framework.py │ ├── flask │ │ ├── __init__.py │ │ ├── flask_middleware.py │ │ ├── flask_request.py │ │ ├── flask_response.py │ │ └── framework.py │ ├── request.py │ ├── response.py │ └── types.py ├── ingredients │ ├── __init__.py │ ├── emaildelivery │ │ ├── __init__.py │ │ ├── services │ │ │ ├── __init__.py │ │ │ └── smtp.py │ │ └── types.py │ └── smsdelivery │ │ ├── __init__.py │ │ ├── services │ │ ├── __init__.py │ │ ├── supertokens.py │ │ └── twilio.py │ │ └── types.py ├── interfaces.py ├── logger.py ├── normalised_url_domain.py ├── normalised_url_path.py ├── post_init_callbacks.py ├── process_state.py ├── py.typed ├── querier.py ├── recipe │ ├── __init__.py │ ├── accountlinking │ │ ├── __init__.py │ │ ├── asyncio │ │ │ └── __init__.py │ │ ├── interfaces.py │ │ ├── recipe.py │ │ ├── recipe_implementation.py │ │ ├── syncio │ │ │ └── __init__.py │ │ ├── types.py │ │ └── utils.py │ ├── dashboard │ │ ├── __init__.py │ │ ├── api │ │ │ ├── __init__.py │ │ │ ├── analytics.py │ │ │ ├── api_key_protector.py │ │ │ ├── dashboard.py │ │ │ ├── implementation.py │ │ │ ├── multitenancy │ │ │ │ ├── __init__.py │ │ │ │ ├── create_or_update_third_party_config.py │ │ │ │ ├── create_tenant.py │ │ │ │ ├── delete_tenant.py │ │ │ │ ├── delete_third_party_config.py │ │ │ │ ├── get_tenant_info.py │ │ │ │ ├── get_third_party_config.py │ │ │ │ ├── list_all_tenants_with_login_methods.py │ │ │ │ ├── update_tenant_core_config.py │ │ │ │ ├── update_tenant_first_factor.py │ │ │ │ ├── update_tenant_secondary_factor.py │ │ │ │ └── utils.py │ │ │ ├── search │ │ │ │ ├── __init__.py │ │ │ │ └── getTags.py │ │ │ ├── signin.py │ │ │ ├── signout.py │ │ │ ├── user │ │ │ │ ├── __init__.py │ │ │ │ └── create │ │ │ │ │ ├── __init__.py │ │ │ │ │ ├── emailpassword_user.py │ │ │ │ │ └── passwordless_user.py │ │ │ ├── userdetails │ │ │ │ ├── __init__.py │ │ │ │ ├── user_delete.py │ │ │ │ ├── user_email_verify_get.py │ │ │ │ ├── user_email_verify_put.py │ │ │ │ ├── user_email_verify_token_post.py │ │ │ │ ├── user_get.py │ │ │ │ ├── user_metadata_get.py │ │ │ │ ├── user_metadata_put.py │ │ │ │ ├── user_password_put.py │ │ │ │ ├── user_put.py │ │ │ │ ├── user_sessions_get.py │ │ │ │ ├── user_sessions_post.py │ │ │ │ └── user_unlink_get.py │ │ │ ├── userroles │ │ │ │ ├── __init__.py │ │ │ │ ├── add_role_to_user.py │ │ │ │ ├── get_role_to_user.py │ │ │ │ ├── permissions │ │ │ │ │ ├── __init__.py │ │ │ │ │ ├── get_permissions_for_role.py │ │ │ │ │ └── remove_permissions_from_role.py │ │ │ │ ├── remove_user_role.py │ │ │ │ └── roles │ │ │ │ │ ├── __init__.py │ │ │ │ │ ├── create_role_or_add_permissions.py │ │ │ │ │ ├── delete_role.py │ │ │ │ │ └── get_all_roles.py │ │ │ ├── users_count_get.py │ │ │ ├── users_get.py │ │ │ └── validate_key.py │ │ ├── constants.py │ │ ├── exceptions.py │ │ ├── interfaces.py │ │ ├── recipe.py │ │ ├── recipe_implementation.py │ │ └── utils.py │ ├── emailpassword │ │ ├── __init__.py │ │ ├── api │ │ │ ├── __init__.py │ │ │ ├── email_exists.py │ │ │ ├── generate_password_reset_token.py │ │ │ ├── implementation.py │ │ │ ├── password_reset.py │ │ │ ├── signin.py │ │ │ ├── signup.py │ │ │ └── utils.py │ │ ├── asyncio │ │ │ └── __init__.py │ │ ├── constants.py │ │ ├── emaildelivery │ │ │ ├── __init__.py │ │ │ └── services │ │ │ │ ├── __init__.py │ │ │ │ ├── backward_compatibility │ │ │ │ └── __init__.py │ │ │ │ └── smtp │ │ │ │ ├── __init__.py │ │ │ │ ├── password_reset.py │ │ │ │ ├── password_reset_email.py │ │ │ │ └── service_implementation │ │ │ │ └── __init__.py │ │ ├── exceptions.py │ │ ├── interfaces.py │ │ ├── recipe.py │ │ ├── recipe_implementation.py │ │ ├── syncio │ │ │ └── __init__.py │ │ ├── types.py │ │ └── utils.py │ ├── emailverification │ │ ├── __init__.py │ │ ├── api │ │ │ ├── __init__.py │ │ │ ├── email_verify.py │ │ │ └── generate_email_verify_token.py │ │ ├── asyncio │ │ │ └── __init__.py │ │ ├── constants.py │ │ ├── emaildelivery │ │ │ ├── __init__.py │ │ │ └── services │ │ │ │ ├── __init__.py │ │ │ │ ├── backward_compatibility │ │ │ │ └── __init__.py │ │ │ │ └── smtp │ │ │ │ ├── __init__.py │ │ │ │ ├── email_verify.py │ │ │ │ ├── email_verify_email.py │ │ │ │ └── service_implementation.py │ │ ├── exceptions.py │ │ ├── interfaces.py │ │ ├── recipe.py │ │ ├── recipe_implementation.py │ │ ├── syncio │ │ │ └── __init__.py │ │ ├── types.py │ │ └── utils.py │ ├── jwt │ │ ├── __init__.py │ │ ├── api │ │ │ ├── __init__.py │ │ │ ├── implementation.py │ │ │ └── jwks_get.py │ │ ├── asyncio │ │ │ └── __init__.py │ │ ├── constants.py │ │ ├── exceptions.py │ │ ├── interfaces.py │ │ ├── recipe.py │ │ ├── recipe_implementation.py │ │ ├── syncio │ │ │ └── __init__.py │ │ └── utils.py │ ├── multifactorauth │ │ ├── __init__.py │ │ ├── api │ │ │ ├── __init__.py │ │ │ ├── implementation.py │ │ │ └── resync_session_and_fetch_mfa_info.py │ │ ├── asyncio │ │ │ └── __init__.py │ │ ├── constants.py │ │ ├── interfaces.py │ │ ├── multi_factor_auth_claim.py │ │ ├── recipe.py │ │ ├── recipe_implementation.py │ │ ├── syncio │ │ │ └── __init__.py │ │ ├── types.py │ │ └── utils.py │ ├── multitenancy │ │ ├── __init__.py │ │ ├── api │ │ │ ├── __init__.py │ │ │ ├── implementation.py │ │ │ └── login_methods.py │ │ ├── asyncio │ │ │ └── __init__.py │ │ ├── constants.py │ │ ├── exceptions.py │ │ ├── interfaces.py │ │ ├── recipe.py │ │ ├── recipe_implementation.py │ │ ├── syncio │ │ │ └── __init__.py │ │ └── utils.py │ ├── oauth2provider │ │ ├── __init__.py │ │ ├── api │ │ │ ├── __init__.py │ │ │ ├── auth.py │ │ │ ├── end_session.py │ │ │ ├── implementation.py │ │ │ ├── introspect_token.py │ │ │ ├── login.py │ │ │ ├── login_info.py │ │ │ ├── logout.py │ │ │ ├── revoke_token.py │ │ │ ├── token.py │ │ │ ├── user_info.py │ │ │ └── utils.py │ │ ├── asyncio │ │ │ └── __init__.py │ │ ├── constants.py │ │ ├── exceptions.py │ │ ├── interfaces.py │ │ ├── oauth2_client.py │ │ ├── recipe.py │ │ ├── recipe_implementation.py │ │ ├── syncio │ │ │ └── __init__.py │ │ └── utils.py │ ├── openid │ │ ├── __init__.py │ │ ├── api │ │ │ ├── __init__.py │ │ │ ├── implementation.py │ │ │ └── open_id_discovery_configuration_get.py │ │ ├── asyncio │ │ │ └── __init__.py │ │ ├── constants.py │ │ ├── exceptions.py │ │ ├── interfaces.py │ │ ├── recipe.py │ │ ├── recipe_implementation.py │ │ ├── syncio │ │ │ └── __init__.py │ │ └── utils.py │ ├── passwordless │ │ ├── __init__.py │ │ ├── api │ │ │ ├── __init__.py │ │ │ ├── consume_code.py │ │ │ ├── create_code.py │ │ │ ├── email_exists.py │ │ │ ├── implementation.py │ │ │ ├── phone_number_exists.py │ │ │ └── resend_code.py │ │ ├── asyncio │ │ │ └── __init__.py │ │ ├── constants.py │ │ ├── emaildelivery │ │ │ ├── __init__.py │ │ │ └── services │ │ │ │ ├── __init__.py │ │ │ │ ├── backward_compatibility │ │ │ │ └── __init__.py │ │ │ │ └── smtp │ │ │ │ ├── __init__.py │ │ │ │ ├── pless_login.py │ │ │ │ ├── pless_login_email.py │ │ │ │ └── service_implementation.py │ │ ├── exceptions.py │ │ ├── interfaces.py │ │ ├── recipe.py │ │ ├── recipe_implementation.py │ │ ├── smsdelivery │ │ │ ├── __init__.py │ │ │ └── services │ │ │ │ ├── __init__.py │ │ │ │ ├── backward_compatibility │ │ │ │ └── __init__.py │ │ │ │ ├── supertokens │ │ │ │ └── __init__.py │ │ │ │ └── twilio │ │ │ │ ├── __init__.py │ │ │ │ ├── passwordless_login.py │ │ │ │ └── service_implementation.py │ │ ├── syncio │ │ │ └── __init__.py │ │ ├── types.py │ │ └── utils.py │ ├── session │ │ ├── __init__.py │ │ ├── access_token.py │ │ ├── api │ │ │ ├── __init__.py │ │ │ ├── implementation.py │ │ │ ├── refresh.py │ │ │ └── signout.py │ │ ├── asyncio │ │ │ └── __init__.py │ │ ├── claim_base_classes │ │ │ ├── __init__.py │ │ │ ├── boolean_claim.py │ │ │ ├── primitive_array_claim.py │ │ │ └── primitive_claim.py │ │ ├── claims.py │ │ ├── constants.py │ │ ├── cookie_and_header.py │ │ ├── exceptions.py │ │ ├── framework │ │ │ ├── __init__.py │ │ │ ├── django │ │ │ │ ├── __init__.py │ │ │ │ ├── asyncio │ │ │ │ │ └── __init__.py │ │ │ │ └── syncio │ │ │ │ │ └── __init__.py │ │ │ ├── fastapi │ │ │ │ └── __init__.py │ │ │ └── flask │ │ │ │ └── __init__.py │ │ ├── interfaces.py │ │ ├── jwks.py │ │ ├── jwt.py │ │ ├── recipe.py │ │ ├── recipe_implementation.py │ │ ├── session_class.py │ │ ├── session_functions.py │ │ ├── session_request_functions.py │ │ ├── syncio │ │ │ └── __init__.py │ │ └── utils.py │ ├── thirdparty │ │ ├── __init__.py │ │ ├── api │ │ │ ├── __init__.py │ │ │ ├── apple_redirect.py │ │ │ ├── authorisation_url.py │ │ │ ├── implementation.py │ │ │ └── signinup.py │ │ ├── asyncio │ │ │ └── __init__.py │ │ ├── constants.py │ │ ├── exceptions.py │ │ ├── interfaces.py │ │ ├── provider.py │ │ ├── providers │ │ │ ├── __init__.py │ │ │ ├── active_directory.py │ │ │ ├── apple.py │ │ │ ├── bitbucket.py │ │ │ ├── boxy_saml.py │ │ │ ├── config_utils.py │ │ │ ├── custom.py │ │ │ ├── discord.py │ │ │ ├── facebook.py │ │ │ ├── github.py │ │ │ ├── gitlab.py │ │ │ ├── google.py │ │ │ ├── google_workspaces.py │ │ │ ├── linkedin.py │ │ │ ├── okta.py │ │ │ ├── twitter.py │ │ │ └── utils.py │ │ ├── recipe.py │ │ ├── recipe_implementation.py │ │ ├── syncio │ │ │ └── __init__.py │ │ ├── types.py │ │ └── utils.py │ ├── totp │ │ ├── __init__.py │ │ ├── api │ │ │ ├── __init__.py │ │ │ ├── create_device.py │ │ │ ├── implementation.py │ │ │ ├── list_devices.py │ │ │ ├── remove_device.py │ │ │ ├── verify_device.py │ │ │ └── verify_totp.py │ │ ├── asyncio │ │ │ └── __init__.py │ │ ├── constants.py │ │ ├── interfaces.py │ │ ├── recipe.py │ │ ├── recipe_implementation.py │ │ ├── syncio │ │ │ └── __init__.py │ │ ├── types.py │ │ └── utils.py │ ├── usermetadata │ │ ├── __init__.py │ │ ├── asyncio │ │ │ └── __init__.py │ │ ├── exceptions.py │ │ ├── interfaces.py │ │ ├── recipe.py │ │ ├── recipe_implementation.py │ │ ├── syncio │ │ │ └── __init__.py │ │ └── utils.py │ └── userroles │ │ ├── __init__.py │ │ ├── asyncio │ │ └── __init__.py │ │ ├── exceptions.py │ │ ├── interfaces.py │ │ ├── recipe.py │ │ ├── recipe_implementation.py │ │ ├── syncio │ │ └── __init__.py │ │ └── utils.py ├── recipe_module.py ├── supertokens.py ├── syncio │ └── __init__.py ├── types.py └── utils.py └── tests ├── Django ├── __init__.py ├── settings.py ├── sqlite.db └── test_django.py ├── Docker └── Dockerfile ├── Fastapi ├── __init__.py └── test_fastapi.py ├── Flask ├── __init__.py ├── test_flask.py └── utils.py ├── __init__.py ├── auth-react ├── auth-react.env ├── django3x │ ├── __init__.py │ ├── db.sqlite3 │ ├── main.py │ ├── manage.py │ ├── mysite │ │ ├── __init__.py │ │ ├── asgi.py │ │ ├── middleware.py │ │ ├── server.py │ │ ├── settings.py │ │ ├── store.py │ │ ├── urls.py │ │ ├── utils.py │ │ └── wsgi.py │ └── polls │ │ ├── __init__.py │ │ ├── admin.py │ │ ├── apps.py │ │ ├── migrations │ │ └── __init__.py │ │ ├── models.py │ │ ├── tests.py │ │ ├── urls.py │ │ └── views.py ├── fastapi-server │ ├── __init__.py │ └── app.py └── flask-server │ ├── __init__.py │ └── app.py ├── conftest.py ├── dashboard ├── __init__.py └── test_dashboard.py ├── emailpassword ├── __init__.py ├── test_emaildelivery.py ├── test_emailexists.py ├── test_emailverify.py ├── test_multitenancy.py ├── test_passwordreset.py ├── test_signin.py ├── test_signup.py └── test_updateemailorpassword.py ├── emailverification └── test_emailverification_claim.py ├── frontendIntegration ├── __init__.py ├── django2x │ ├── README.md │ ├── create_env.sh │ ├── db.sqlite3 │ ├── manage.py │ ├── mysite │ │ ├── __init__.py │ │ ├── settings.py │ │ ├── urls.py │ │ └── wsgi.py │ ├── polls │ │ ├── __init__.py │ │ ├── apps.py │ │ ├── migrations │ │ │ └── __init__.py │ │ ├── urls.py │ │ └── views.py │ ├── requirements.txt │ └── templates │ │ ├── angular │ │ ├── main.js │ │ ├── polyfills.js │ │ ├── runtime.js │ │ └── vendor.js │ │ └── index.html ├── django3x │ ├── README.md │ ├── create_env.sh │ ├── db.sqlite3 │ ├── main.py │ ├── manage.py │ ├── mysite │ │ ├── __init__.py │ │ ├── asgi.py │ │ ├── server.py │ │ ├── settings.py │ │ ├── urls.py │ │ └── wsgi.py │ ├── polls │ │ ├── __init__.py │ │ ├── admin.py │ │ ├── apps.py │ │ ├── migrations │ │ │ └── __init__.py │ │ ├── models.py │ │ ├── tests.py │ │ ├── urls.py │ │ └── views.py │ ├── requirements.txt │ └── templates │ │ ├── angular │ │ ├── main.js │ │ ├── polyfills.js │ │ ├── runtime.js │ │ └── vendor.js │ │ └── index.html ├── drf_async │ ├── README.md │ ├── create_env.sh │ ├── db.sqlite3 │ ├── main.py │ ├── manage.py │ ├── mysite │ │ ├── __init__.py │ │ ├── asgi.py │ │ ├── server.py │ │ ├── settings.py │ │ ├── urls.py │ │ └── wsgi.py │ ├── polls │ │ ├── __init__.py │ │ ├── admin.py │ │ ├── apps.py │ │ ├── migrations │ │ │ └── __init__.py │ │ ├── models.py │ │ ├── tests.py │ │ ├── urls.py │ │ └── views.py │ ├── requirements.txt │ └── templates │ │ ├── angular │ │ ├── main.js │ │ ├── polyfills.js │ │ ├── runtime.js │ │ └── vendor.js │ │ └── index.html ├── drf_sync │ ├── README.md │ ├── create_env.sh │ ├── db.sqlite3 │ ├── main.py │ ├── manage.py │ ├── mysite │ │ ├── __init__.py │ │ ├── asgi.py │ │ ├── server.py │ │ ├── settings.py │ │ ├── urls.py │ │ └── wsgi.py │ ├── polls │ │ ├── __init__.py │ │ ├── admin.py │ │ ├── apps.py │ │ ├── migrations │ │ │ └── __init__.py │ │ ├── models.py │ │ ├── tests.py │ │ ├── urls.py │ │ └── views.py │ ├── requirements.txt │ └── templates │ │ ├── angular │ │ ├── main.js │ │ ├── polyfills.js │ │ ├── runtime.js │ │ └── vendor.js │ │ └── index.html ├── fastapi-server │ ├── __init__.py │ ├── app.py │ └── templates │ │ ├── angular │ │ ├── main.js │ │ ├── polyfills.js │ │ ├── runtime.js │ │ └── vendor.js │ │ └── index.html └── flask-server │ ├── __init__.py │ ├── app.py │ └── templates │ ├── angular │ ├── main.js │ ├── polyfills.js │ ├── runtime.js │ └── vendor.js │ └── index.html ├── input_validation ├── __init__.py └── test_input_validation.py ├── jwt ├── __init__.py ├── test_config.py ├── test_create_jwt_feature.py ├── test_get_JWKS.py └── test_override.py ├── multitenancy ├── __init__.py ├── test_router.py └── test_tenants_crud.py ├── passwordless ├── __init__.py ├── test_emaildelivery.py ├── test_mutlitenancy.py └── test_smsdelivery.py ├── playground ├── __init__.py └── app.py ├── schema.py ├── sessions ├── __init__.py ├── claims │ ├── __init__.py │ ├── conftest.py │ ├── test_assert_claims.py │ ├── test_create_new_session.py │ ├── test_fetch_and_set_claim.py │ ├── test_get_claim_value.py │ ├── test_primitive_array_claim.py │ ├── test_primitive_claim.py │ ├── test_remove_claim.py │ ├── test_set_claim_value.py │ ├── test_validate_claims_for_session_handle.py │ ├── test_verify_session.py │ └── utils.py ├── test_access_token_version.py ├── test_auth_mode.py ├── test_jwks.py ├── test_session_error_handlers.py ├── test_session_utils.py └── test_use_dynamic_signing_key_switching.py ├── supertokens_python ├── __init__.py └── test_supertokens_functions.py ├── telemetry ├── __init__.py └── test_telemetry.py ├── test-server ├── __init__.py ├── accountlinking.py ├── app.py ├── emailpassword.py ├── emailverification.py ├── multifactorauth.py ├── multitenancy.py ├── oauth2provider.py ├── override_logging.py ├── passwordless.py ├── session.py ├── supertokens.py ├── test_functions_mapper.py ├── thirdparty.py ├── totp.py ├── usermetadata.py └── utils.py ├── test_config.py ├── test_config_without_core.py ├── test_logger.py ├── test_middleware.py ├── test_misc.py ├── test_network_interceptor.py ├── test_pagination.py ├── test_passwordless.py ├── test_querier.py ├── test_session.py ├── test_user_context.py ├── test_utils.py ├── testclient.py ├── thirdparty ├── __init__.py ├── test_authorisation_url_feature.py ├── test_emaildelivery.py ├── test_multitenancy.py └── test_thirdparty.py ├── useridmapping ├── __init__.py ├── create_user_id_mapping.py ├── delete_user_id_mapping.py ├── get_user_id_mapping.py ├── recipe_tests.py └── utils.py ├── usermetadata └── test_metadata.py ├── userroles ├── __init__.py ├── test_add_role_to_user.py ├── test_claims.py ├── test_config.py ├── test_create_new_role_or_add_permissions.py ├── test_delete_role.py ├── test_get_permissions_for_role.py ├── test_get_roles_for_user.py ├── test_get_roles_that_have_permissions.py ├── test_get_users_that_have_role.py ├── test_multitenancy.py ├── test_remove_permissions_from_role.py └── test_remove_user_role.py ├── users.json └── utils.py /.circleci/doBackendSDKTests.sh: -------------------------------------------------------------------------------- 1 | echo "Starting tests for CDI $1"; 2 | 3 | if [ -z "$SUPERTOKENS_API_KEY" ]; then 4 | echo "SUPERTOKENS_API_KEY not set" 5 | exit 1 6 | fi 7 | 8 | coreDriverVersion=$1 9 | coreDriverVersion=`echo $coreDriverVersion | tr -d '"'` 10 | 11 | frontendDriverVersion=$2 12 | 13 | coreFree=`curl -s -X GET \ 14 | "https://api.supertokens.io/0/core-driver-interface/dependency/core/latest?password=$SUPERTOKENS_API_KEY&planType=FREE&mode=DEV&version=$coreDriverVersion&driverName=python" \ 15 | -H 'api-version: 1'` 16 | if [[ `echo $coreFree | jq .core` == "null" ]] 17 | then 18 | echo "fetching latest X.Y version for core given core-driver-interface X.Y version: $coreDriverVersion, planType: FREE gave response: $coreFree. Please make sure all relevant cores have been pushed." 19 | exit 1 20 | fi 21 | coreFree=$(echo $coreFree | jq .core | tr -d '"') 22 | 23 | ./setupAndTestBackendSDKWithFreeCore.sh $coreFree $coreDriverVersion $frontendDriverVersion 24 | if [[ $? -ne 0 ]] 25 | then 26 | echo "test failed... exiting!" 27 | exit 1 28 | fi 29 | rm -rf ../../supertokens-root 30 | -------------------------------------------------------------------------------- /.circleci/doUnitTests.sh: -------------------------------------------------------------------------------- 1 | echo "Starting tests for CDI $1"; 2 | 3 | if [ -z "$SUPERTOKENS_API_KEY" ]; then 4 | echo "SUPERTOKENS_API_KEY not set" 5 | exit 1 6 | fi 7 | 8 | coreDriverVersion=$1 9 | coreDriverVersion=`echo $coreDriverVersion | tr -d '"'` 10 | 11 | coreFree=`curl -s -X GET \ 12 | "https://api.supertokens.io/0/core-driver-interface/dependency/core/latest?password=$SUPERTOKENS_API_KEY&planType=FREE&mode=DEV&version=$coreDriverVersion&driverName=python" \ 13 | -H 'api-version: 1'` 14 | if [[ `echo $coreFree | jq .core` == "null" ]] 15 | then 16 | echo "fetching latest X.Y version for core given core-driver-interface X.Y version: $coreDriverVersion, planType: FREE gave response: $coreFree. Please make sure all relevant cores have been pushed." 17 | exit 1 18 | fi 19 | coreFree=$(echo $coreFree | jq .core | tr -d '"') 20 | 21 | ./setupAndTestWithFreeCore.sh $coreFree $coreDriverVersion 22 | if [[ $? -ne 0 ]] 23 | then 24 | echo "test failed... exiting!" 25 | exit 1 26 | fi 27 | -------------------------------------------------------------------------------- /.circleci/generateConfig.sh: -------------------------------------------------------------------------------- 1 | frontendDriverJson=`cat ../frontendDriverInterfaceSupported.json` 2 | frontendDriverArray=`echo $frontendDriverJson | jq -c ".versions"` 3 | 4 | coreDriverJson=`cat ../coreDriverInterfaceSupported.json` 5 | coreDriverArray=`echo $coreDriverJson | jq -c ".versions"` 6 | 7 | if [ -z "$SUPERTOKENS_API_KEY" ]; then 8 | echo "SUPERTOKENS_API_KEY missing" 9 | exit 1; 10 | fi 11 | 12 | sed -i -e 's/fdi-version: placeholder/fdi-version: '`printf "%s" $frontendDriverArray`'/' config_continue.yml 13 | sed -i -e 's/cdi-version: placeholder/cdi-version: '`printf "%s" $coreDriverArray`'/' config_continue.yml 14 | -------------------------------------------------------------------------------- /.circleci/installJava.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | wget https://download.java.net/java/GA/jdk15.0.1/51f4f36ad4ef43e39d0dfdbaf6549e32/9/GPL/openjdk-15.0.1_linux-x64_bin.tar.gz 4 | mkdir /usr/java 5 | mv openjdk-15.0.1_linux-x64_bin.tar.gz /usr/java 6 | cd /usr/java 7 | tar -xzvf openjdk-15.0.1_linux-x64_bin.tar.gz 8 | rm openjdk-15.0.1_linux-x64_bin.tar.gz 9 | ln -s /usr/java/jdk-15.0.1/bin/java /usr/bin/java 10 | ln -s /usr/java/jdk-15.0.1/bin/javac /usr/bin/javac 11 | -------------------------------------------------------------------------------- /.circleci/installNode.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export NODE_VERSION=$1 4 | 5 | curl -fsSL https://deb.nodesource.com/setup_$NODE_VERSION.x | bash - 6 | apt-get install -y nodejs 7 | -------------------------------------------------------------------------------- /.circleci/markAsSuccess.sh: -------------------------------------------------------------------------------- 1 | coreDriverJson=`cat ../coreDriverInterfaceSupported.json` 2 | coreDriverLength=`echo $coreDriverJson | jq ".versions | length"` 3 | coreDriverArray=`echo $coreDriverJson | jq ".versions"` 4 | echo "got core driver relations" 5 | 6 | frontendDriverJson=`cat ../frontendDriverInterfaceSupported.json` 7 | frontendDriverLength=`echo $frontendDriverJson | jq ".versions | length"` 8 | frontendDriverArray=`echo $frontendDriverJson | jq ".versions"` 9 | echo "got frontend driver relations" 10 | 11 | # get driver version 12 | version=`cat ../setup.py | grep -e 'version='` 13 | while IFS='"' read -ra ADDR; do 14 | counter=0 15 | for i in "${ADDR[@]}"; do 16 | if [ $counter == 1 ] 17 | then 18 | version=$i 19 | fi 20 | counter=$(($counter+1)) 21 | done 22 | done <<< "$version" 23 | 24 | echo "calling /driver PATCH to make testing passed" 25 | responseStatus=`curl -s -o /dev/null -w "%{http_code}" -X PATCH \ 26 | https://api.supertokens.io/0/driver \ 27 | -H 'Content-Type: application/json' \ 28 | -H 'api-version: 0' \ 29 | -d "{ 30 | \"password\": \"$SUPERTOKENS_API_KEY\", 31 | \"version\":\"$version\", 32 | \"name\": \"python\", 33 | \"testPassed\": true 34 | }"` 35 | if [ $responseStatus -ne "200" ] 36 | then 37 | echo "patch api failed" 38 | exit 1 39 | fi 40 | -------------------------------------------------------------------------------- /.circleci/markDevTagAsTestNotPassed.sh: -------------------------------------------------------------------------------- 1 | coreDriverJson=`cat ../coreDriverInterfaceSupported.json` 2 | coreDriverLength=`echo $coreDriverJson | jq ".versions | length"` 3 | coreDriverArray=`echo $coreDriverJson | jq ".versions"` 4 | echo "got core driver relations" 5 | 6 | frontendDriverJson=`cat ../frontendDriverInterfaceSupported.json` 7 | frontendDriverLength=`echo $frontendDriverJson | jq ".versions | length"` 8 | frontendDriverArray=`echo $frontendDriverJson | jq ".versions"` 9 | echo "got frontend driver relations" 10 | 11 | # get driver version 12 | version=`cat ../setup.py | grep -e 'version='` 13 | while IFS='"' read -ra ADDR; do 14 | counter=0 15 | for i in "${ADDR[@]}"; do 16 | if [ $counter == 1 ] 17 | then 18 | version=$i 19 | fi 20 | counter=$(($counter+1)) 21 | done 22 | done <<< "$version" 23 | 24 | responseStatus=`curl -s -o out.bin -w "%{http_code}" -X PUT \ 25 | https://api.supertokens.io/0/driver \ 26 | -H 'Content-Type: application/json' \ 27 | -H 'api-version: 0' \ 28 | -d "{ 29 | \"password\": \"$SUPERTOKENS_API_KEY\", 30 | \"version\":\"$version\", 31 | \"name\": \"python\", 32 | \"frontendDriverInterfaces\": $frontendDriverArray, 33 | \"coreDriverInterfaces\": $coreDriverArray 34 | }"` 35 | if [ $responseStatus -ne "200" ] 36 | then 37 | echo "failed core PUT API status code: $responseStatus. Exiting!" 38 | cat out.bin 39 | exit 1 40 | fi 41 | -------------------------------------------------------------------------------- /.circleci/updateDocsInWebsite.sh: -------------------------------------------------------------------------------- 1 | # get driver version 2 | version=`cat ../setup.py | grep -e 'version='` 3 | while IFS='"' read -ra ADDR; do 4 | counter=0 5 | for i in "${ADDR[@]}"; do 6 | if [ $counter == 1 ] 7 | then 8 | version=$i 9 | fi 10 | counter=$(($counter+1)) 11 | done 12 | done <<< "$version" 13 | 14 | # replace path version with X 15 | IFS='.' read -r -a array <<< "$version" 16 | versionFolder="${array[0]}"."${array[1]}".X 17 | 18 | # create python docs dir in repo if not exists 19 | (cd ../../supertokens-backend-website && mkdir -p ./app/docs/sdk/docs/python/${versionFolder}) 20 | 21 | # copy docs content from this repo to the supertokens-backend-website repo 22 | cp -r ../html/supertokens_python/* ../../supertokens-backend-website/app/docs/sdk/docs/python/ 23 | cp -r ../html/supertokens_python/* ../../supertokens-backend-website/app/docs/sdk/docs/python/${versionFolder} 24 | 25 | # push to git 26 | git config --global user.email "$EMAIL" 27 | git config --global user.name "$NAME" 28 | (cd ../../supertokens-backend-website && git add --all && git commit -m"updates python docs" && git pull && git push && ./releaseDev.sh) 29 | -------------------------------------------------------------------------------- /.cursorrules: -------------------------------------------------------------------------------- 1 | You are an expert Python and Typescript developer. Your job is to convert node code (in typescript) into Python code. The python code then goes into this SDK. The python code style should keep in mind: 2 | - Avoid using TypeDict 3 | - Avoid using generic Dict as much as possible, except when defining the types for `user_context`. 4 | - If a function has multiple `status` strings as outputs, then define one unique class per unique `status` string. The class name should be such that it indicates the status it is associated with. 5 | - Variable and function names should be in snake_case. Class names in PascalCase. 6 | - Whenever importing `Literal`, import it from `typing_extensions`, and not `types`. 7 | - Do not use `|` for OR type, instead use `Union` 8 | - When defining API interface functions, make sure the output classes inherit from `APIResponse` class, and that they have a `to_json` function defined whose output matches the structure of the provided Typescript code output objects. 9 | 10 | The semantic of the python code should be the same as what's of the provided Typescript code. 11 | -------------------------------------------------------------------------------- /.github/workflows/lint-code.yml: -------------------------------------------------------------------------------- 1 | name: "Lint/Format Code" 2 | 3 | on: 4 | pull_request: 5 | types: 6 | - opened 7 | - reopened 8 | - synchronize 9 | push: 10 | branches: 11 | - master 12 | - "v[0-9]+.[0-9]+" 13 | tags: 14 | - "(dev-)?v[0-9]+.[0-9]+.[0-9]+" 15 | 16 | jobs: 17 | define-versions: 18 | runs-on: ubuntu-latest 19 | outputs: 20 | pyVersions: '["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]' 21 | 22 | lint-format: 23 | name: Check linting and formatting 24 | runs-on: ubuntu-latest 25 | needs: define-versions 26 | strategy: 27 | matrix: 28 | py-version: ${{ fromJSON(needs.define-versions.outputs.pyVersions) }} 29 | steps: 30 | - uses: actions/checkout@v4 31 | - uses: actions/setup-python@v5 32 | with: 33 | python-version: ${{ matrix.py-version }} 34 | - name: Create virtual environment and install dependencies 35 | run: | 36 | python3 -m venv venv 37 | source venv/bin/activate 38 | python3 -m pip install pip setuptools --upgrade 39 | make dev-install && rm -rf src 40 | - name: Run checks 41 | # New steps require sourcing the venv again 42 | run: | 43 | source venv/bin/activate 44 | make lint 45 | -------------------------------------------------------------------------------- /.github/workflows/lint-pr.yml: -------------------------------------------------------------------------------- 1 | name: "Lint PR" 2 | 3 | on: 4 | pull_request: 5 | types: 6 | - opened 7 | - reopened 8 | - edited 9 | - synchronize 10 | 11 | jobs: 12 | lint-pr-title: 13 | name: Lint PR Title 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: amannn/action-semantic-pull-request@v3 17 | env: 18 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 19 | with: 20 | validateSingleCommit: true 21 | 22 | # Enforces the update of a changelog file on every pull request 23 | lint-changelog: 24 | name: Enforce Changelogs 25 | runs-on: ubuntu-latest 26 | steps: 27 | - uses: actions/checkout@v2 28 | - uses: dangoslen/changelog-enforcer@v2 29 | with: 30 | changeLogPath: "CHANGELOG.md" 31 | skipLabels: "Skip-Changelog" 32 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .pytest_cache 3 | .vscode/settings.json 4 | build 5 | dist 6 | supertokens_python.egg-info 7 | __pycache__ 8 | releasePassword 9 | apiPassword 10 | venv/ 11 | ./env/ 12 | .env 13 | .DS_Store 14 | bin/ 15 | lib/ 16 | pyvenv.cfg 17 | sqlite.db 18 | .mypy_cache/ 19 | test-results/ 20 | .ruff_cache/ 21 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:latest 2 | RUN apt-get update && apt-get install -y python3 python3-pip python3-venv 3 | ADD . /app 4 | WORKDIR /app 5 | RUN bash ./test-pre-commit.sh 6 | RUN bash ./hooks/pre-commit.sh 7 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | help: 2 | @echo " \x1b[33;1mtest: \x1b[0mruns pytest" 3 | @echo " \x1b[33;1mlint: \x1b[0mrun all hooks - lint and format code" 4 | @echo "\x1b[33;1mset-up-hooks: \x1b[0mset up various git hooks" 5 | @echo " \x1b[33;1mdev-install: \x1b[0minstall all packages required for development" 6 | @echo " \x1b[33;1mhelp: \x1b[0mprints this" 7 | 8 | lint: 9 | pre-commit run --all-files 10 | pre-commit run --all-files --hook-stage manual pyright 11 | 12 | set-up-hooks: 13 | pre-commit install 14 | 15 | test: 16 | docker compose up --wait 17 | pytest -vv ./tests/ --junit-xml=test-results/junit.xml $(ARGS) 18 | docker compose down 19 | 20 | dev-install: 21 | pip install -r dev-requirements.txt 22 | 23 | freeze-dev-requirements: 24 | pip freeze > dev-requirements.txt 25 | 26 | with-fastapi: 27 | pip3 install -e .[fastapi] 28 | 29 | with-django: 30 | pip3 install -e .[django] 31 | 32 | with-django2x: 33 | pip3 install -e .[django2x] 34 | 35 | with-drf: 36 | pip3 install -e .[drf] 37 | 38 | with-flask: 39 | pip3 install -e .[flask] 40 | 41 | build-docs: 42 | rm -rf html && pdoc --html supertokens_python --template-dir docs-templates 43 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![SuperTokens banner](https://raw.githubusercontent.com/supertokens/supertokens-logo/master/images/Artboard%20%E2%80%93%2027%402x.png) 2 | 3 | # SuperTokens Python SDK 4 | 5 | 6 | chat on Discord 8 | 9 | Last 30 days downloads for supertokens-python 10 | 11 | 12 | ## About 13 | This is a Python library that is used to interface between a python API process and the SuperTokens http service. 14 | 15 | Learn more at https://supertokens.com 16 | 17 | ## Documentation 18 | 19 | To see documentation, please click [here](https://supertokens.com/docs/community/introduction). 20 | 21 | ## Contributing 22 | 23 | Please see the [CONTRIBUTING.md](https://github.com/supertokens/supertokens-python/blob/master/CONTRIBUTING.md) file for instructions. 24 | 25 | ## Contact us 26 | 27 | For any queries, or support requests, please email us at team@supertokens.io, or join our [Discord](https://supertokens.com/discord) server. 28 | 29 | ## Authors 30 | 31 | Created with :heart: by the folks at SuperTokens.io. 32 | -------------------------------------------------------------------------------- /compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | core: 3 | # Uses `$SUPERTOKENS_CORE_VERSION` when available, else latest 4 | image: supertokens/supertokens-core:dev-branch-${SUPERTOKENS_CORE_VERSION:-master} 5 | ports: 6 | # Uses `$SUPERTOKENS_CORE_PORT` when available, else 3567 for local port 7 | - ${SUPERTOKENS_CORE_PORT:-3567}:3567 8 | platform: linux/amd64 9 | depends_on: [oauth] 10 | environment: 11 | OAUTH_PROVIDER_PUBLIC_SERVICE_URL: http://oauth:4444 12 | OAUTH_PROVIDER_ADMIN_SERVICE_URL: http://oauth:4445 13 | OAUTH_PROVIDER_CONSENT_LOGIN_BASE_URL: http://localhost:3001/auth 14 | OAUTH_CLIENT_SECRET_ENCRYPTION_KEY: asdfasdfasdfasdfasdf 15 | healthcheck: 16 | test: bash -c 'curl -s "http://127.0.0.1:3567/hello" | grep "Hello"' 17 | interval: 10s 18 | timeout: 5s 19 | retries: 5 20 | 21 | oauth: 22 | image: supertokens/oauth2-test:latest 23 | platform: linux/amd64 24 | -------------------------------------------------------------------------------- /coreDriverInterfaceSupported.json: -------------------------------------------------------------------------------- 1 | { 2 | "_comment": "contains a list of core-driver interfaces branch names that this core supports", 3 | "versions": [ 4 | "5.2" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /dev-requirements.txt: -------------------------------------------------------------------------------- 1 | black==24.8.0 2 | Django==4.2.6 3 | django-cors-headers==4.4.0 4 | django-stubs==4.2.7 5 | django-stubs-ext==4.2.7 6 | fastapi==0.115.5 7 | Flask==3.0.3 8 | flask-cors==5.0.0 9 | nest-asyncio==1.6.0 10 | pdoc3==0.11.0 11 | pre-commit==3.5.0 12 | pyfakefs==5.7.4 13 | pylint==3.2.7 14 | pyright==1.1.393 15 | python-dotenv==1.0.1 16 | pytest==8.3.3 17 | pytest-asyncio==0.24.0 18 | pytest-mock==3.14.0 19 | pytest-rerunfailures==14.0 20 | pyyaml==6.0.2 21 | requests-mock==1.12.1 22 | respx>=0.13.0, <1.0.0 23 | uvicorn==0.32.0 24 | -e . 25 | -------------------------------------------------------------------------------- /docs-templates/credits.mako: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/docs-templates/credits.mako -------------------------------------------------------------------------------- /docs-templates/head.mako: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/docs-templates/head.mako -------------------------------------------------------------------------------- /docs-templates/logo.mako: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/docs-templates/logo.mako -------------------------------------------------------------------------------- /examples/with-django/with-thirdpartyemailpassword/.env: -------------------------------------------------------------------------------- 1 | GOOGLE_CLIENT_ID=1060725074195-kmeum4crr01uirfl2op9kd5acmi9jutn.apps.googleusercontent.com 2 | GOOGLE_CLIENT_SECRET=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 3 | GOOGLE_CLIENT_ID_MOBILE=1060725074195-c7mgk8p0h27c4428prfuo3lg7ould5o7.apps.googleusercontent.com 4 | GOOGLE_CLIENT_SECRET_MOBILE= 5 | GITHUB_CLIENT_ID=467101b197249757c71f 6 | GITHUB_CLIENT_SECRET=e97051221f4b6426e8fe8d51486396703012f5bd 7 | GITHUB_CLIENT_ID_MOBILE=8a9152860ce869b64c44 8 | GITHUB_CLIENT_SECRET_MOBILE=00e841f10f288363cd3786b1b1f538f05cfdbda2 9 | APPLE_CLIENT_ID=4398792-io.supertokens.example.service 10 | APPLE_KEY_ID=7M48Y4RYDL 11 | APPLE_TEAM_ID=YWQCXGJRJL 12 | APPLE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nMIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQgu8gXs+XYkqXD6Ala9Sf/iJXzhbwcoG5dMh1OonpdJUmgCgYIKoZIzj0DAQehRANCAASfrvlFbFCYqn3I2zeknYXLwtH30JuOKestDbSfZYxZNMqhF/OzdZFTV0zc5u5s3eN+oCWbnvl0hM+9IW0UlkdA\n-----END PRIVATE KEY-----" 13 | APPLE_CLIENT_ID_MOBILE=4398792-io.supertokens.example 14 | GOOGLE_WORKSPACES_CLIENT_ID=1060725074195-kmeum4crr01uirfl2op9kd5acmi9jutn.apps.googleusercontent.com 15 | GOOGLE_WORKSPACES_CLIENT_SECRET=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 16 | DISCORD_CLIENT_ID=4398792-907871294886928395 17 | DISCORD_CLIENT_SECRET=His4yXGEovVp5TZkZhEAt0ZXGh8uOVDm 18 | -------------------------------------------------------------------------------- /examples/with-django/with-thirdpartyemailpassword/README.md: -------------------------------------------------------------------------------- 1 | ![SuperTokens banner](https://raw.githubusercontent.com/supertokens/supertokens-logo/master/images/Artboard%20%E2%80%93%2027%402x.png) 2 | 3 | # Django example 4 | 5 | This is an example to show how to use supertokens-python library with Django framework and ThirdpartyEmailpassword recipe. 6 | 7 | This server code can be used to implement social auth using: 8 | - Google 9 | - Google Workspaces 10 | - Github 11 | - Apple 12 | - Discord 13 | 14 | ## Installation 15 | 16 | Before installing, use the script to create a virtual environment and to install all the required packages. 17 | ```bash 18 | source create_env.sh 19 | ``` 20 | 21 | ## Start web app 22 | 23 | ```bash 24 | python manage.py migrate 25 | python manage.py runserver 26 | ``` 27 | 28 | ## Author 29 | 30 | Created with :heart: by the folks at supertokens.com. 31 | 32 | ## License 33 | 34 | This project is licensed under the Apache 2.0 license. 35 | -------------------------------------------------------------------------------- /examples/with-django/with-thirdpartyemailpassword/create_env.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | pip install virtualenv 4 | #Create a virtualenv 5 | virtualenv django_example 6 | # shellcheck disable=SC2164 7 | source django_example/bin/activate 8 | 9 | pip install -r requirements.txt 10 | -------------------------------------------------------------------------------- /examples/with-django/with-thirdpartyemailpassword/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Django's command-line utility for administrative tasks.""" 3 | 4 | import os 5 | import sys 6 | 7 | 8 | def main(): 9 | """Run administrative tasks.""" 10 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings") 11 | try: 12 | from django.core.management import execute_from_command_line 13 | except ImportError as exc: 14 | raise ImportError( 15 | "Couldn't import Django. Are you sure it's installed and " 16 | "available on your PYTHONPATH environment variable? Did you " 17 | "forget to activate a virtual environment?" 18 | ) from exc 19 | execute_from_command_line(sys.argv) 20 | 21 | 22 | if __name__ == "__main__": 23 | main() 24 | -------------------------------------------------------------------------------- /examples/with-django/with-thirdpartyemailpassword/project/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/examples/with-django/with-thirdpartyemailpassword/project/__init__.py -------------------------------------------------------------------------------- /examples/with-django/with-thirdpartyemailpassword/project/asgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | ASGI config for project project. 3 | 4 | It exposes the ASGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/4.0/howto/deployment/asgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.asgi import get_asgi_application 13 | 14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings") 15 | 16 | application = get_asgi_application() 17 | -------------------------------------------------------------------------------- /examples/with-django/with-thirdpartyemailpassword/project/urls.py: -------------------------------------------------------------------------------- 1 | """project URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/4.0/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: path('', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.urls import include, path 14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 15 | """ 16 | 17 | from django.contrib import admin 18 | from django.urls import include, path 19 | 20 | urlpatterns = [ 21 | path("admin/", admin.site.urls), 22 | path("", include("sampleapp.urls")), 23 | ] 24 | -------------------------------------------------------------------------------- /examples/with-django/with-thirdpartyemailpassword/project/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for project project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/4.0/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings") 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /examples/with-django/with-thirdpartyemailpassword/requirements.txt: -------------------------------------------------------------------------------- 1 | django-cors-headers 2 | python-dotenv 3 | supertokens-python 4 | -------------------------------------------------------------------------------- /examples/with-django/with-thirdpartyemailpassword/sampleapp/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/examples/with-django/with-thirdpartyemailpassword/sampleapp/__init__.py -------------------------------------------------------------------------------- /examples/with-django/with-thirdpartyemailpassword/sampleapp/admin.py: -------------------------------------------------------------------------------- 1 | # Register your models here. 2 | -------------------------------------------------------------------------------- /examples/with-django/with-thirdpartyemailpassword/sampleapp/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class SampleappConfig(AppConfig): 5 | default_auto_field = "django.db.models.BigAutoField" 6 | name = "sampleapp" 7 | -------------------------------------------------------------------------------- /examples/with-django/with-thirdpartyemailpassword/sampleapp/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/examples/with-django/with-thirdpartyemailpassword/sampleapp/migrations/__init__.py -------------------------------------------------------------------------------- /examples/with-django/with-thirdpartyemailpassword/sampleapp/models.py: -------------------------------------------------------------------------------- 1 | # Create your models here. 2 | -------------------------------------------------------------------------------- /examples/with-django/with-thirdpartyemailpassword/sampleapp/urls.py: -------------------------------------------------------------------------------- 1 | from django.urls import path 2 | 3 | from . import views 4 | 5 | urlpatterns = [ 6 | path("sessioninfo", views.get_session_info), 7 | ] 8 | -------------------------------------------------------------------------------- /examples/with-django/with-thirdpartyemailpassword/sampleapp/views.py: -------------------------------------------------------------------------------- 1 | from django.http import HttpRequest, JsonResponse 2 | from supertokens_python.recipe.session import SessionContainer 3 | from supertokens_python.recipe.session.framework.django.syncio import verify_session 4 | 5 | 6 | @verify_session() 7 | def get_session_info(request: HttpRequest) -> JsonResponse: 8 | if not isinstance(request.supertokens, SessionContainer): # type: ignore 9 | raise Exception("should never happen") 10 | 11 | session_: SessionContainer = request.supertokens # type: ignore 12 | return JsonResponse( 13 | { 14 | "sessionHandle": session_.get_handle(), 15 | "userId": session_.get_user_id(), 16 | "accessTokenPayload": session_.get_access_token_payload(), 17 | # "sessionData": session_.sync_get_session_data_from_database(), 18 | } 19 | ) 20 | -------------------------------------------------------------------------------- /examples/with-fastapi/with-thirdpartyemailpassword/.env: -------------------------------------------------------------------------------- 1 | GOOGLE_CLIENT_ID=1060725074195-kmeum4crr01uirfl2op9kd5acmi9jutn.apps.googleusercontent.com 2 | GOOGLE_CLIENT_SECRET=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 3 | GOOGLE_CLIENT_ID_MOBILE=1060725074195-c7mgk8p0h27c4428prfuo3lg7ould5o7.apps.googleusercontent.com 4 | GOOGLE_CLIENT_SECRET_MOBILE= 5 | GITHUB_CLIENT_ID=467101b197249757c71f 6 | GITHUB_CLIENT_SECRET=e97051221f4b6426e8fe8d51486396703012f5bd 7 | GITHUB_CLIENT_ID_MOBILE=8a9152860ce869b64c44 8 | GITHUB_CLIENT_SECRET_MOBILE=00e841f10f288363cd3786b1b1f538f05cfdbda2 9 | APPLE_CLIENT_ID=4398792-io.supertokens.example.service 10 | APPLE_KEY_ID=7M48Y4RYDL 11 | APPLE_TEAM_ID=YWQCXGJRJL 12 | APPLE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nMIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQgu8gXs+XYkqXD6Ala9Sf/iJXzhbwcoG5dMh1OonpdJUmgCgYIKoZIzj0DAQehRANCAASfrvlFbFCYqn3I2zeknYXLwtH30JuOKestDbSfZYxZNMqhF/OzdZFTV0zc5u5s3eN+oCWbnvl0hM+9IW0UlkdA\n-----END PRIVATE KEY-----" 13 | APPLE_CLIENT_ID_MOBILE=4398792-io.supertokens.example 14 | GOOGLE_WORKSPACES_CLIENT_ID=1060725074195-kmeum4crr01uirfl2op9kd5acmi9jutn.apps.googleusercontent.com 15 | GOOGLE_WORKSPACES_CLIENT_SECRET=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 16 | DISCORD_CLIENT_ID=4398792-907871294886928395 17 | DISCORD_CLIENT_SECRET=His4yXGEovVp5TZkZhEAt0ZXGh8uOVDm 18 | -------------------------------------------------------------------------------- /examples/with-fastapi/with-thirdpartyemailpassword/README.md: -------------------------------------------------------------------------------- 1 | ![SuperTokens banner](https://raw.githubusercontent.com/supertokens/supertokens-logo/master/images/Artboard%20%E2%80%93%2027%402x.png) 2 | 3 | # FastAPI example 4 | 5 | This is an example to show how to use supertokens-python library with FastAPI framework and ThirdpartyEmailpassword recipe. 6 | 7 | This server code can be used to implement social auth using: 8 | - Google 9 | - Google Workspaces 10 | - Github 11 | - Apple 12 | - Discord 13 | 14 | ## Installation 15 | 16 | Before installing, use the script to create a virtual environment and to install all the required packages. 17 | ```bash 18 | source create_env.sh 19 | ``` 20 | 21 | ## Start web app 22 | 23 | ```bash 24 | uvicorn main:app --reload --host=0.0.0.0 --port=3001 25 | ``` 26 | 27 | ## Author 28 | 29 | Created with :heart: by the folks at supertokens.com. 30 | 31 | ## License 32 | 33 | This project is licensed under the Apache 2.0 license. 34 | -------------------------------------------------------------------------------- /examples/with-fastapi/with-thirdpartyemailpassword/create_env.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | pip install virtualenv 4 | #Create a virtualenv 5 | virtualenv fastapi_example 6 | # shellcheck disable=SC2164 7 | source fastapi_example/bin/activate 8 | 9 | pip install -r requirements.txt 10 | -------------------------------------------------------------------------------- /examples/with-fastapi/with-thirdpartyemailpassword/requirements.txt: -------------------------------------------------------------------------------- 1 | fastapi 2 | uvicorn 3 | python-dotenv 4 | supertokens-python 5 | -------------------------------------------------------------------------------- /examples/with-flask/with-thirdpartyemailpassword/.env: -------------------------------------------------------------------------------- 1 | GOOGLE_CLIENT_ID=1060725074195-kmeum4crr01uirfl2op9kd5acmi9jutn.apps.googleusercontent.com 2 | GOOGLE_CLIENT_SECRET=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 3 | GOOGLE_CLIENT_ID_MOBILE=1060725074195-c7mgk8p0h27c4428prfuo3lg7ould5o7.apps.googleusercontent.com 4 | GOOGLE_CLIENT_SECRET_MOBILE= 5 | GITHUB_CLIENT_ID=467101b197249757c71f 6 | GITHUB_CLIENT_SECRET=e97051221f4b6426e8fe8d51486396703012f5bd 7 | GITHUB_CLIENT_ID_MOBILE=8a9152860ce869b64c44 8 | GITHUB_CLIENT_SECRET_MOBILE=00e841f10f288363cd3786b1b1f538f05cfdbda2 9 | APPLE_CLIENT_ID=4398792-io.supertokens.example.service 10 | APPLE_KEY_ID=7M48Y4RYDL 11 | APPLE_TEAM_ID=YWQCXGJRJL 12 | APPLE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nMIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQgu8gXs+XYkqXD6Ala9Sf/iJXzhbwcoG5dMh1OonpdJUmgCgYIKoZIzj0DAQehRANCAASfrvlFbFCYqn3I2zeknYXLwtH30JuOKestDbSfZYxZNMqhF/OzdZFTV0zc5u5s3eN+oCWbnvl0hM+9IW0UlkdA\n-----END PRIVATE KEY-----" 13 | APPLE_CLIENT_ID_MOBILE=4398792-io.supertokens.example 14 | GOOGLE_WORKSPACES_CLIENT_ID=1060725074195-kmeum4crr01uirfl2op9kd5acmi9jutn.apps.googleusercontent.com 15 | GOOGLE_WORKSPACES_CLIENT_SECRET=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 16 | DISCORD_CLIENT_ID=4398792-907871294886928395 17 | DISCORD_CLIENT_SECRET=His4yXGEovVp5TZkZhEAt0ZXGh8uOVDm 18 | -------------------------------------------------------------------------------- /examples/with-flask/with-thirdpartyemailpassword/README.md: -------------------------------------------------------------------------------- 1 | ![SuperTokens banner](https://raw.githubusercontent.com/supertokens/supertokens-logo/master/images/Artboard%20%E2%80%93%2027%402x.png) 2 | 3 | # Flask example 4 | 5 | This is an example to show how to use supertokens-python library with Flask framework and ThirdpartyEmailpassword recipe. 6 | 7 | This server code can be used to implement social auth using: 8 | - Google 9 | - Google Workspaces 10 | - Github 11 | - Apple 12 | - Discord 13 | 14 | ## Installation 15 | 16 | Before installing, use the script to create a virtual environment and to install all the required packages. 17 | ```bash 18 | source create_env.sh 19 | ``` 20 | 21 | ## Start web app 22 | 23 | ```bash 24 | python app.py 25 | ``` 26 | 27 | ## Author 28 | 29 | Created with :heart: by the folks at supertokens.com. 30 | 31 | ## License 32 | 33 | This project is licensed under the Apache 2.0 license. 34 | -------------------------------------------------------------------------------- /examples/with-flask/with-thirdpartyemailpassword/create_env.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | pip install virtualenv 4 | #Create a virtualenv 5 | virtualenv flask_example 6 | # shellcheck disable=SC2164 7 | source flask_example/bin/activate 8 | 9 | pip install -r requirements.txt 10 | -------------------------------------------------------------------------------- /examples/with-flask/with-thirdpartyemailpassword/requirements.txt: -------------------------------------------------------------------------------- 1 | flask 2 | flask_cors 3 | python-dotenv 4 | supertokens-python 5 | -------------------------------------------------------------------------------- /frontendDriverInterfaceSupported.json: -------------------------------------------------------------------------------- 1 | { 2 | "_comment": "contains a list of frontend-driver interfaces branch names that this core supports", 3 | "versions": [ 4 | "1.17", 5 | "1.18", 6 | "1.19", 7 | "2.0", 8 | "3.0", 9 | "3.1", 10 | "4.0" 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /hooks/check-branch.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source ./hooks/populate-hook-constants.sh 4 | 5 | isVersionBranch=$( if [[ ${targetBranch} =~ ^[0-9]+.[0-9]+$ ]]; then echo true; else echo false; fi ) 6 | 7 | # Check that the code version matches the branch version if on a versioned branch 8 | # `%.*` strips out the suffix after (and including) the last `.` 9 | if "$isVersionBranch" && [[ "${targetBranch}" != "${newestVersion%.*}" ]] 10 | then 11 | echo "Code version (${newestVersion%.*}) does not match branch (${targetBranch}), unexpected." 12 | exit 1 13 | fi 14 | -------------------------------------------------------------------------------- /hooks/check-version.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source ./hooks/populate-hook-constants.sh 4 | 5 | # Versions come from ./populate-hook-constants.sh 6 | if [[ ${constantsVersion} != ${setupVersion} ]] 7 | then 8 | printf "Version mismatch ./supertokens_python/constants.py=$constantsVersion, setup.py=$setupVersion" 9 | exit 1 10 | fi 11 | -------------------------------------------------------------------------------- /hooks/populate-hook-constants.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Look for the version string with additional handling for: 4 | # - Abitrary Spaces: ` *` 5 | # - Extracting the version into a match group: `(...)` 6 | # - Substituting the matched string with the match group: `/\1/` 7 | constantsVersion=$(sed -n 's/^ *VERSION *= *["]\([0-9\.]*\).*/\1/p' supertokens_python/constants.py) 8 | setupVersion=$(sed -n 's/ *version *= *["]\([0-9\.]*\).*/\1/p' setup.py ) 9 | 10 | newestVersion=$( if [[ "$constantsVersion" > "$setupVersion" ]]; then echo "$constantsVersion"; else echo "$setupVersion"; fi ) 11 | 12 | # Target branch of the PR. 13 | # Ideally, this is all we want to check. 14 | if [[ "$GITHUB_BASE_REF" != "" ]] 15 | then 16 | targetBranch="$GITHUB_BASE_REF" 17 | else # Fallback to current branch if not in a PR 18 | targetBranch=$(git branch --show-current 2> /dev/null) || targetBranch="(unnamed branch)" # Get current branch 19 | fi 20 | targetBranch=${targetBranch##refs/heads/} # Remove refs/heads/ if present 21 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.ruff] 2 | line-length = 88 # Match Black's formatting 3 | src = ["supertokens_python"] 4 | 5 | [tool.ruff.lint] 6 | extend-select = ["I"] # enable import sorting 7 | 8 | [tool.ruff.format] 9 | quote-style = "double" # Default 10 | indent-style = "space" # Default 11 | 12 | [tool.pyright] 13 | typeCheckingMode = "strict" 14 | reportImportCycles = false 15 | include = ["supertokens_python/", "tests/", "examples/"] 16 | 17 | [tool.pytest.ini_options] 18 | addopts = " -v -p no:warnings" 19 | python_paths = "." 20 | xfail_strict = true 21 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | license_file = LICENSE.md 3 | -------------------------------------------------------------------------------- /supertokens_python/async_to_sync_wrapper.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | 15 | import asyncio 16 | from os import getenv 17 | from typing import Any, Coroutine, TypeVar 18 | 19 | _T = TypeVar("_T") 20 | 21 | 22 | def nest_asyncio_enabled(): 23 | return getenv("SUPERTOKENS_NEST_ASYNCIO", "") == "1" 24 | 25 | 26 | def create_or_get_event_loop() -> asyncio.AbstractEventLoop: 27 | try: 28 | return asyncio.get_event_loop() 29 | except Exception as ex: 30 | if "There is no current event loop in thread" in str(ex): 31 | loop = asyncio.new_event_loop() 32 | 33 | if nest_asyncio_enabled(): 34 | import nest_asyncio # type: ignore 35 | 36 | nest_asyncio.apply(loop) # type: ignore 37 | 38 | asyncio.set_event_loop(loop) 39 | return loop 40 | raise ex 41 | 42 | 43 | def sync(co: Coroutine[Any, Any, _T]) -> _T: 44 | loop = create_or_get_event_loop() 45 | return loop.run_until_complete(co) 46 | -------------------------------------------------------------------------------- /supertokens_python/constants.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | 15 | from __future__ import annotations 16 | 17 | SUPPORTED_CDI_VERSIONS = ["5.2"] 18 | VERSION = "0.29.2" 19 | TELEMETRY = "/telemetry" 20 | USER_COUNT = "/users/count" 21 | USER_DELETE = "/user/remove" 22 | USERS = "/users" 23 | TELEMETRY_SUPERTOKENS_API_URL = "https://api.supertokens.com/0/st/telemetry" 24 | TELEMETRY_SUPERTOKENS_API_VERSION = "3" 25 | ERROR_MESSAGE_KEY = "message" 26 | API_KEY_HEADER = "api-key" 27 | RID_KEY_HEADER = "rid" 28 | FDI_KEY_HEADER = "fdi-version" 29 | API_VERSION = "/apiversion" 30 | API_VERSION_HEADER = "cdi-version" 31 | DASHBOARD_VERSION = "0.13" 32 | ONE_YEAR_IN_MS = 31536000000 33 | RATE_LIMIT_STATUS_CODE = 429 34 | -------------------------------------------------------------------------------- /supertokens_python/env/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/supertokens_python/env/__init__.py -------------------------------------------------------------------------------- /supertokens_python/env/base.py: -------------------------------------------------------------------------------- 1 | from os import environ 2 | 3 | from supertokens_python.env.utils import str_to_bool 4 | 5 | 6 | def FLAG_tldextract_disable_http(): 7 | """ 8 | Disable HTTP calls from `tldextract`. 9 | """ 10 | val = environ.get("SUPERTOKENS_TLDEXTRACT_DISABLE_HTTP", "0") 11 | 12 | return str_to_bool(val) 13 | -------------------------------------------------------------------------------- /supertokens_python/env/utils.py: -------------------------------------------------------------------------------- 1 | def str_to_bool(val: str) -> bool: 2 | """ 3 | Convert ENV values to boolean 4 | """ 5 | return val.lower() in ("true", "t", "1") 6 | -------------------------------------------------------------------------------- /supertokens_python/exceptions.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from __future__ import annotations 15 | 16 | from typing import NoReturn, Union 17 | 18 | 19 | def raise_general_exception( 20 | msg: Union[str, Exception], previous: Union[None, Exception] = None 21 | ) -> NoReturn: 22 | if isinstance(msg, SuperTokensError): 23 | raise msg 24 | if isinstance(msg, Exception): 25 | raise GeneralError(msg) from None 26 | raise GeneralError(msg) from previous 27 | 28 | 29 | def raise_bad_input_exception(msg: str) -> NoReturn: 30 | raise BadInputError(msg) 31 | 32 | 33 | class SuperTokensError(Exception): 34 | pass 35 | 36 | 37 | class GeneralError(SuperTokensError): 38 | pass 39 | 40 | 41 | class BadInputError(SuperTokensError): 42 | pass 43 | -------------------------------------------------------------------------------- /supertokens_python/framework/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from . import request, response 15 | 16 | BaseRequest = request.BaseRequest 17 | BaseResponse = response.BaseResponse 18 | -------------------------------------------------------------------------------- /supertokens_python/framework/django/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from supertokens_python.framework.django.django_middleware import ( 15 | middleware as middleware, 16 | ) 17 | -------------------------------------------------------------------------------- /supertokens_python/framework/django/framework.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | 15 | from __future__ import annotations 16 | 17 | from typing import TYPE_CHECKING 18 | 19 | from supertokens_python.framework.types import Framework 20 | 21 | if TYPE_CHECKING: 22 | from django.http import HttpRequest 23 | 24 | 25 | class DjangoFramework(Framework): 26 | def wrap_request(self, unwrapped: HttpRequest): 27 | from supertokens_python.framework.django.django_request import DjangoRequest 28 | 29 | return DjangoRequest(unwrapped) 30 | -------------------------------------------------------------------------------- /supertokens_python/framework/fastapi/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from supertokens_python.framework.fastapi import fastapi_middleware 15 | 16 | get_middleware = fastapi_middleware.get_middleware 17 | -------------------------------------------------------------------------------- /supertokens_python/framework/fastapi/framework.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from __future__ import annotations 15 | 16 | from typing import TYPE_CHECKING 17 | 18 | from supertokens_python.framework.types import Framework 19 | 20 | if TYPE_CHECKING: 21 | from fastapi import Request 22 | 23 | 24 | class FastapiFramework(Framework): 25 | def wrap_request(self, unwrapped: Request): 26 | from supertokens_python.framework.fastapi.fastapi_request import FastApiRequest 27 | 28 | return FastApiRequest(unwrapped) 29 | -------------------------------------------------------------------------------- /supertokens_python/framework/flask/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from supertokens_python.framework.flask import flask_middleware 15 | 16 | Middleware = flask_middleware.Middleware 17 | -------------------------------------------------------------------------------- /supertokens_python/framework/flask/framework.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from __future__ import annotations 15 | 16 | from typing import TYPE_CHECKING 17 | 18 | from supertokens_python.framework.types import Framework 19 | 20 | if TYPE_CHECKING: 21 | from flask.wrappers import Request 22 | 23 | 24 | class FlaskFramework(Framework): 25 | def wrap_request(self, unwrapped: Request): 26 | from supertokens_python.framework.flask.flask_request import FlaskRequest 27 | 28 | return FlaskRequest(unwrapped) 29 | -------------------------------------------------------------------------------- /supertokens_python/framework/types.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | 15 | from abc import ABC, abstractmethod 16 | from enum import Enum 17 | from typing import Any, Union 18 | 19 | from supertokens_python.framework.request import BaseRequest 20 | 21 | frameworks = ["fastapi", "flask", "django"] 22 | 23 | 24 | class FrameworkEnum(Enum): 25 | FASTAPI = 1 26 | FLASK = 2 27 | DJANGO = 3 28 | 29 | 30 | class Framework(ABC): 31 | @abstractmethod 32 | def wrap_request(self, unwrapped: Any) -> Union[BaseRequest, None]: 33 | pass 34 | -------------------------------------------------------------------------------- /supertokens_python/ingredients/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | -------------------------------------------------------------------------------- /supertokens_python/ingredients/emaildelivery/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | 15 | from typing import Generic, TypeVar 16 | 17 | from supertokens_python.ingredients.emaildelivery.types import ( 18 | EmailDeliveryConfigWithService, 19 | EmailDeliveryInterface, 20 | ) 21 | 22 | _T = TypeVar("_T") 23 | 24 | 25 | class EmailDeliveryIngredient(Generic[_T]): 26 | ingredient_interface_impl: EmailDeliveryInterface[_T] 27 | 28 | def __init__(self, config: EmailDeliveryConfigWithService[_T]) -> None: 29 | self.ingredient_interface_impl = ( 30 | config.service 31 | if config.override is None 32 | else config.override(config.service) 33 | ) 34 | -------------------------------------------------------------------------------- /supertokens_python/ingredients/emaildelivery/services/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | -------------------------------------------------------------------------------- /supertokens_python/ingredients/smsdelivery/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | 15 | from typing import Generic, TypeVar 16 | 17 | from supertokens_python.ingredients.smsdelivery.types import ( 18 | SMSDeliveryConfigWithService, 19 | SMSDeliveryInterface, 20 | ) 21 | 22 | _T = TypeVar("_T") 23 | 24 | 25 | class SMSDeliveryIngredient(Generic[_T]): 26 | ingredient_interface_impl: SMSDeliveryInterface[_T] 27 | 28 | def __init__(self, config: SMSDeliveryConfigWithService[_T]) -> None: 29 | self.ingredient_interface_impl = ( 30 | config.service 31 | if config.override is None 32 | else config.override(config.service) 33 | ) 34 | -------------------------------------------------------------------------------- /supertokens_python/ingredients/smsdelivery/services/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | -------------------------------------------------------------------------------- /supertokens_python/ingredients/smsdelivery/services/supertokens.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | 15 | SUPERTOKENS_SMS_SERVICE_URL = "https://api.supertokens.com/0/services/sms" 16 | -------------------------------------------------------------------------------- /supertokens_python/ingredients/smsdelivery/services/twilio.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from typing import TypeVar 15 | 16 | from supertokens_python.ingredients.smsdelivery.types import TwilioSettings 17 | 18 | _T = TypeVar("_T") 19 | 20 | 21 | def normalize_twilio_settings(twilio_settings: TwilioSettings) -> TwilioSettings: 22 | from_ = twilio_settings.from_ 23 | messaging_service_sid = twilio_settings.messaging_service_sid 24 | 25 | if (from_ and messaging_service_sid) or (not from_ and not messaging_service_sid): 26 | raise Exception( 27 | 'Please pass exactly one of "from" and "messaging_service_sid" config for twilio_settings.' 28 | ) 29 | 30 | return twilio_settings 31 | -------------------------------------------------------------------------------- /supertokens_python/post_init_callbacks.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | 15 | from typing import Callable, List 16 | 17 | 18 | class PostSTInitCallbacks: 19 | """Callbacks that are called after the SuperTokens instance is initialized.""" 20 | 21 | post_init_callbacks: List[Callable[[], None]] = [] 22 | 23 | @staticmethod 24 | def add_post_init_callback(cb: Callable[[], None]) -> None: 25 | PostSTInitCallbacks.post_init_callbacks.append(cb) 26 | 27 | @staticmethod 28 | def run_post_init_callbacks() -> None: 29 | for cb in PostSTInitCallbacks.post_init_callbacks: 30 | cb() 31 | PostSTInitCallbacks.post_init_callbacks = [] 32 | 33 | @staticmethod 34 | def reset(): 35 | PostSTInitCallbacks.post_init_callbacks = [] 36 | -------------------------------------------------------------------------------- /supertokens_python/py.typed: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/supertokens_python/py.typed -------------------------------------------------------------------------------- /supertokens_python/recipe/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/supertokens_python/recipe/__init__.py -------------------------------------------------------------------------------- /supertokens_python/recipe/dashboard/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | 15 | from __future__ import annotations 16 | 17 | from typing import Callable, List, Optional 18 | 19 | from supertokens_python import AppInfo, RecipeModule 20 | from supertokens_python.recipe.dashboard import utils 21 | 22 | from .recipe import DashboardRecipe 23 | 24 | InputOverrideConfig = utils.InputOverrideConfig 25 | 26 | 27 | def init( 28 | api_key: Optional[str] = None, 29 | admins: Optional[List[str]] = None, 30 | override: Optional[InputOverrideConfig] = None, 31 | ) -> Callable[[AppInfo], RecipeModule]: 32 | return DashboardRecipe.init( 33 | api_key, 34 | admins, 35 | override, 36 | ) 37 | -------------------------------------------------------------------------------- /supertokens_python/recipe/dashboard/api/dashboard.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from __future__ import annotations 15 | 16 | from typing import TYPE_CHECKING, Any, Dict, Optional 17 | 18 | from supertokens_python.framework import BaseResponse 19 | 20 | if TYPE_CHECKING: 21 | from supertokens_python.recipe.dashboard.interfaces import ( 22 | APIInterface, 23 | APIOptions, 24 | ) 25 | 26 | 27 | async def handle_dashboard_api( 28 | api_implementation: APIInterface, 29 | api_options: APIOptions, 30 | user_context: Dict[str, Any], 31 | ) -> Optional[BaseResponse]: 32 | if api_implementation.dashboard_get is None: 33 | return None 34 | 35 | html_str = await api_implementation.dashboard_get(api_options, user_context) 36 | 37 | api_options.response.set_html_content(html_str) 38 | return api_options.response 39 | -------------------------------------------------------------------------------- /supertokens_python/recipe/dashboard/api/multitenancy/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/supertokens_python/recipe/dashboard/api/multitenancy/__init__.py -------------------------------------------------------------------------------- /supertokens_python/recipe/dashboard/api/search/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/supertokens_python/recipe/dashboard/api/search/__init__.py -------------------------------------------------------------------------------- /supertokens_python/recipe/dashboard/api/search/getTags.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from __future__ import annotations 15 | 16 | from typing import TYPE_CHECKING, Any, Dict 17 | 18 | if TYPE_CHECKING: 19 | from supertokens_python.recipe.dashboard.interfaces import APIInterface, APIOptions 20 | 21 | from supertokens_python.normalised_url_path import NormalisedURLPath 22 | from supertokens_python.querier import Querier 23 | from supertokens_python.recipe.dashboard.interfaces import SearchTagsOK 24 | 25 | 26 | async def handle_get_tags( 27 | _: APIInterface, _tenant_id: str, __: APIOptions, _user_context: Dict[str, Any] 28 | ) -> SearchTagsOK: 29 | response = await Querier.get_instance().send_get_request( 30 | NormalisedURLPath("/user/search/tags"), None, _user_context 31 | ) 32 | return SearchTagsOK(tags=response["tags"]) 33 | -------------------------------------------------------------------------------- /supertokens_python/recipe/dashboard/api/user/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/supertokens_python/recipe/dashboard/api/user/__init__.py -------------------------------------------------------------------------------- /supertokens_python/recipe/dashboard/api/user/create/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/supertokens_python/recipe/dashboard/api/user/create/__init__.py -------------------------------------------------------------------------------- /supertokens_python/recipe/dashboard/api/userdetails/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/supertokens_python/recipe/dashboard/api/userdetails/__init__.py -------------------------------------------------------------------------------- /supertokens_python/recipe/dashboard/api/userdetails/user_delete.py: -------------------------------------------------------------------------------- 1 | from typing import Any, Dict 2 | 3 | from supertokens_python.asyncio import delete_user 4 | from supertokens_python.exceptions import raise_bad_input_exception 5 | 6 | from ...interfaces import APIInterface, APIOptions, UserDeleteAPIResponse 7 | 8 | 9 | async def handle_user_delete( 10 | _api_interface: APIInterface, 11 | _tenant_id: str, 12 | api_options: APIOptions, 13 | _user_context: Dict[str, Any], 14 | ) -> UserDeleteAPIResponse: 15 | user_id = api_options.request.get_query_param("userId") 16 | remove_all_linked_accounts_query_value = api_options.request.get_query_param( 17 | "removeAllLinkedAccounts" 18 | ) 19 | 20 | if remove_all_linked_accounts_query_value is not None: 21 | remove_all_linked_accounts_query_value = ( 22 | remove_all_linked_accounts_query_value.strip().lower() 23 | ) 24 | 25 | remove_all_linked_accounts = ( 26 | True 27 | if remove_all_linked_accounts_query_value is None 28 | else remove_all_linked_accounts_query_value == "true" 29 | ) 30 | 31 | if user_id is None or user_id == "": 32 | raise_bad_input_exception("Missing required parameter 'userId'") 33 | 34 | await delete_user(user_id, remove_all_linked_accounts) 35 | 36 | return UserDeleteAPIResponse() 37 | -------------------------------------------------------------------------------- /supertokens_python/recipe/dashboard/api/userdetails/user_email_verify_get.py: -------------------------------------------------------------------------------- 1 | from typing import Any, Dict, Union 2 | 3 | from supertokens_python.exceptions import raise_bad_input_exception 4 | from supertokens_python.recipe.emailverification import EmailVerificationRecipe 5 | from supertokens_python.recipe.emailverification.asyncio import is_email_verified 6 | from supertokens_python.types import RecipeUserId 7 | 8 | from ...interfaces import ( 9 | APIInterface, 10 | APIOptions, 11 | FeatureNotEnabledError, 12 | UserEmailVerifyGetAPIResponse, 13 | ) 14 | 15 | 16 | async def handle_user_email_verify_get( 17 | _api_interface: APIInterface, 18 | _tenant_id: str, 19 | api_options: APIOptions, 20 | user_context: Dict[str, Any], 21 | ) -> Union[UserEmailVerifyGetAPIResponse, FeatureNotEnabledError]: 22 | req = api_options.request 23 | recipe_user_id = req.get_query_param("recipeUserId") 24 | 25 | if recipe_user_id is None: 26 | raise_bad_input_exception("Missing required parameter 'recipeUserId'") 27 | 28 | try: 29 | EmailVerificationRecipe.get_instance_or_throw() 30 | except Exception: 31 | return FeatureNotEnabledError() 32 | 33 | is_verified = await is_email_verified( 34 | RecipeUserId(recipe_user_id), user_context=user_context 35 | ) 36 | return UserEmailVerifyGetAPIResponse(is_verified) 37 | -------------------------------------------------------------------------------- /supertokens_python/recipe/dashboard/api/userdetails/user_metadata_get.py: -------------------------------------------------------------------------------- 1 | from typing import Any, Dict, Union 2 | 3 | from supertokens_python.exceptions import raise_bad_input_exception 4 | from supertokens_python.recipe.usermetadata import UserMetadataRecipe 5 | from supertokens_python.recipe.usermetadata.asyncio import get_user_metadata 6 | 7 | from ...interfaces import ( 8 | APIInterface, 9 | APIOptions, 10 | FeatureNotEnabledError, 11 | UserMetadataGetAPIOkResponse, 12 | ) 13 | 14 | 15 | async def handle_metadata_get( 16 | _api_interface: APIInterface, 17 | _tenant_id: str, 18 | api_options: APIOptions, 19 | user_context: Dict[str, Any], 20 | ) -> Union[UserMetadataGetAPIOkResponse, FeatureNotEnabledError]: 21 | user_id = api_options.request.get_query_param("userId") 22 | 23 | if user_id is None: 24 | raise_bad_input_exception("Missing required parameter 'userId'") 25 | 26 | try: 27 | UserMetadataRecipe.get_instance() 28 | except Exception: 29 | return FeatureNotEnabledError() 30 | 31 | metadata_response = await get_user_metadata(user_id, user_context=user_context) 32 | return UserMetadataGetAPIOkResponse(metadata_response.metadata) 33 | -------------------------------------------------------------------------------- /supertokens_python/recipe/dashboard/api/userdetails/user_sessions_post.py: -------------------------------------------------------------------------------- 1 | from typing import Any, Dict, List, Optional 2 | 3 | from supertokens_python.exceptions import raise_bad_input_exception 4 | from supertokens_python.recipe.session.asyncio import revoke_multiple_sessions 5 | 6 | from ...interfaces import APIInterface, APIOptions, UserSessionsPostAPIResponse 7 | 8 | 9 | async def handle_user_sessions_post( 10 | _api_interface: APIInterface, 11 | _tenant_id: str, 12 | api_options: APIOptions, 13 | _user_context: Dict[str, Any], 14 | ) -> UserSessionsPostAPIResponse: 15 | request_body = await api_options.request.json() # type: ignore 16 | session_handles: Optional[List[str]] = request_body.get("sessionHandles") # type: ignore 17 | 18 | if not isinstance(session_handles, list): 19 | raise_bad_input_exception( 20 | "Required parameter 'sessionHandles' is missing or has an invalid type" 21 | ) 22 | 23 | await revoke_multiple_sessions(session_handles, _user_context) 24 | return UserSessionsPostAPIResponse() 25 | -------------------------------------------------------------------------------- /supertokens_python/recipe/dashboard/api/userdetails/user_unlink_get.py: -------------------------------------------------------------------------------- 1 | from typing import Any, Dict 2 | 3 | from typing_extensions import Literal 4 | 5 | from supertokens_python.exceptions import raise_bad_input_exception 6 | from supertokens_python.recipe.accountlinking.asyncio import unlink_account 7 | from supertokens_python.recipe.dashboard.utils import RecipeUserId 8 | from supertokens_python.types import APIResponse 9 | 10 | from ...interfaces import APIInterface, APIOptions 11 | 12 | 13 | class UserUnlinkGetOkResult(APIResponse): 14 | def __init__(self): 15 | self.status: Literal["OK"] = "OK" 16 | 17 | def to_json(self): 18 | return {"status": self.status} 19 | 20 | 21 | async def handle_user_unlink_get( 22 | _api_interface: APIInterface, 23 | _tenant_id: str, 24 | api_options: APIOptions, 25 | user_context: Dict[str, Any], 26 | ) -> UserUnlinkGetOkResult: 27 | recipe_user_id = api_options.request.get_query_param("recipeUserId") 28 | 29 | if recipe_user_id is None: 30 | raise_bad_input_exception("Required field recipeUserId is missing") 31 | 32 | await unlink_account(RecipeUserId(recipe_user_id), user_context) 33 | 34 | return UserUnlinkGetOkResult() 35 | -------------------------------------------------------------------------------- /supertokens_python/recipe/dashboard/api/userroles/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/supertokens_python/recipe/dashboard/api/userroles/__init__.py -------------------------------------------------------------------------------- /supertokens_python/recipe/dashboard/api/userroles/get_role_to_user.py: -------------------------------------------------------------------------------- 1 | from typing import Any, List, Union 2 | 3 | from typing_extensions import Literal 4 | 5 | from supertokens_python.exceptions import raise_bad_input_exception 6 | from supertokens_python.recipe.dashboard.interfaces import APIInterface, APIOptions 7 | from supertokens_python.recipe.userroles.asyncio import get_roles_for_user 8 | from supertokens_python.recipe.userroles.recipe import UserRolesRecipe 9 | from supertokens_python.types import APIResponse 10 | 11 | 12 | class OkResponse(APIResponse): 13 | def __init__(self, roles: List[str]): 14 | self.status: Literal["OK"] = "OK" 15 | self.roles = roles 16 | 17 | def to_json(self): 18 | return { 19 | "status": self.status, 20 | "roles": self.roles, 21 | } 22 | 23 | 24 | class FeatureNotEnabledErrorResponse(APIResponse): 25 | def __init__(self): 26 | self.status: Literal["FEATURE_NOT_ENABLED_ERROR"] = "FEATURE_NOT_ENABLED_ERROR" 27 | 28 | def to_json(self): 29 | return {"status": self.status} 30 | 31 | 32 | async def get_roles_for_user_api( 33 | _: APIInterface, tenant_id: str, api_options: APIOptions, __: Any 34 | ) -> Union[OkResponse, FeatureNotEnabledErrorResponse]: 35 | try: 36 | UserRolesRecipe.get_instance() 37 | except Exception: 38 | return FeatureNotEnabledErrorResponse() 39 | 40 | user_id = api_options.request.get_query_param("userId") 41 | 42 | if user_id is None: 43 | raise_bad_input_exception( 44 | "Required parameter 'userId' is missing or has an invalid type" 45 | ) 46 | 47 | response = await get_roles_for_user(tenant_id, user_id) 48 | return OkResponse(roles=response.roles) 49 | -------------------------------------------------------------------------------- /supertokens_python/recipe/dashboard/api/userroles/permissions/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/supertokens_python/recipe/dashboard/api/userroles/permissions/__init__.py -------------------------------------------------------------------------------- /supertokens_python/recipe/dashboard/api/userroles/roles/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/supertokens_python/recipe/dashboard/api/userroles/roles/__init__.py -------------------------------------------------------------------------------- /supertokens_python/recipe/dashboard/api/userroles/roles/delete_role.py: -------------------------------------------------------------------------------- 1 | from typing import Any, Union 2 | 3 | from typing_extensions import Literal 4 | 5 | from supertokens_python.exceptions import raise_bad_input_exception 6 | from supertokens_python.recipe.dashboard.interfaces import APIInterface, APIOptions 7 | from supertokens_python.recipe.userroles.asyncio import delete_role 8 | from supertokens_python.recipe.userroles.recipe import UserRolesRecipe 9 | from supertokens_python.types import APIResponse 10 | 11 | 12 | class OkResponse(APIResponse): 13 | def __init__(self, did_role_exist: bool): 14 | self.status: Literal["OK"] = "OK" 15 | self.did_role_exist = did_role_exist 16 | 17 | def to_json(self): 18 | return {"status": self.status, "didRoleExist": self.did_role_exist} 19 | 20 | 21 | class FeatureNotEnabledErrorResponse(APIResponse): 22 | def __init__(self): 23 | self.status: Literal["FEATURE_NOT_ENABLED_ERROR"] = "FEATURE_NOT_ENABLED_ERROR" 24 | 25 | def to_json(self): 26 | return {"status": self.status} 27 | 28 | 29 | async def delete_role_api( 30 | _: APIInterface, __: str, api_options: APIOptions, ___: Any 31 | ) -> Union[OkResponse, FeatureNotEnabledErrorResponse]: 32 | try: 33 | UserRolesRecipe.get_instance() 34 | except Exception: 35 | return FeatureNotEnabledErrorResponse() 36 | 37 | role = api_options.request.get_query_param("role") 38 | 39 | if role is None: 40 | raise_bad_input_exception( 41 | "Required parameter 'role' is missing or has an invalid type" 42 | ) 43 | 44 | response = await delete_role(role) 45 | return OkResponse(did_role_exist=response.did_role_exist) 46 | -------------------------------------------------------------------------------- /supertokens_python/recipe/dashboard/api/userroles/roles/get_all_roles.py: -------------------------------------------------------------------------------- 1 | from typing import Any, List, Union 2 | 3 | from typing_extensions import Literal 4 | 5 | from supertokens_python.recipe.dashboard.interfaces import APIInterface, APIOptions 6 | from supertokens_python.recipe.userroles.asyncio import get_all_roles 7 | from supertokens_python.recipe.userroles.recipe import UserRolesRecipe 8 | from supertokens_python.types import APIResponse 9 | 10 | 11 | class OkResponse(APIResponse): 12 | def __init__(self, roles: List[str]): 13 | self.status: Literal["OK"] = "OK" 14 | self.roles = roles 15 | 16 | def to_json(self): 17 | return {"status": self.status, "roles": self.roles} 18 | 19 | 20 | class FeatureNotEnabledErrorResponse(APIResponse): 21 | def __init__(self): 22 | self.status: Literal["FEATURE_NOT_ENABLED_ERROR"] = "FEATURE_NOT_ENABLED_ERROR" 23 | 24 | def to_json(self): 25 | return {"status": self.status} 26 | 27 | 28 | async def get_all_roles_api( 29 | _: APIInterface, __: str, ___: APIOptions, ____: Any 30 | ) -> Union[OkResponse, FeatureNotEnabledErrorResponse]: 31 | try: 32 | UserRolesRecipe.get_instance() 33 | except Exception: 34 | return FeatureNotEnabledErrorResponse() 35 | 36 | response = await get_all_roles() 37 | return OkResponse(roles=response.roles) 38 | -------------------------------------------------------------------------------- /supertokens_python/recipe/dashboard/api/users_count_get.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from __future__ import annotations 15 | 16 | from typing import TYPE_CHECKING, Any, Dict 17 | 18 | from supertokens_python.recipe.dashboard.interfaces import UserCountGetAPIResponse 19 | from supertokens_python.supertokens import Supertokens 20 | 21 | if TYPE_CHECKING: 22 | from supertokens_python.recipe.dashboard.interfaces import ( 23 | APIInterface, 24 | APIOptions, 25 | ) 26 | 27 | 28 | async def handle_users_count_get_api( 29 | _: APIInterface, 30 | tenant_id: str, 31 | _api_options: APIOptions, 32 | _user_context: Dict[str, Any], 33 | ) -> UserCountGetAPIResponse: 34 | count = await Supertokens.get_instance().get_user_count( 35 | None, 36 | tenant_id, 37 | ) 38 | return UserCountGetAPIResponse(count=count) 39 | -------------------------------------------------------------------------------- /supertokens_python/recipe/dashboard/api/validate_key.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from __future__ import annotations 15 | 16 | from typing import TYPE_CHECKING, Any, Dict 17 | 18 | if TYPE_CHECKING: 19 | from supertokens_python.recipe.dashboard.interfaces import ( 20 | APIInterface, 21 | APIOptions, 22 | ) 23 | 24 | from supertokens_python.utils import ( 25 | send_200_response, 26 | send_non_200_response_with_message, 27 | ) 28 | 29 | from ..utils import validate_api_key 30 | 31 | 32 | async def handle_validate_key_api( 33 | _api_implementation: APIInterface, 34 | api_options: APIOptions, 35 | user_context: Dict[str, Any], 36 | ): 37 | is_valid_key = await validate_api_key( 38 | api_options.request, api_options.config, user_context 39 | ) 40 | 41 | if is_valid_key: 42 | return send_200_response({"status": "OK"}, api_options.response) 43 | return send_non_200_response_with_message("Unauthorised", 401, api_options.response) 44 | -------------------------------------------------------------------------------- /supertokens_python/recipe/dashboard/constants.py: -------------------------------------------------------------------------------- 1 | DASHBOARD_API = "/dashboard" 2 | VALIDATE_KEY_API = "/api/key/validate" 3 | USERS_LIST_GET_API = "/api/users" 4 | USERS_COUNT_API = "/api/users/count" 5 | USER_API = "/api/user" 6 | USER_EMAIL_VERIFY_API = "/api/user/email/verify" 7 | USER_METADATA_API = "/api/user/metadata" 8 | USER_SESSION_API = "/api/user/sessions" 9 | USER_PASSWORD_API = "/api/user/password" 10 | USER_EMAIL_VERIFY_TOKEN_API = "/api/user/email/verify/token" 11 | SIGN_IN_API = "/api/signin" 12 | SIGN_OUT_API = "/api/signout" 13 | SEARCH_TAGS_API = "/api/search/tags" 14 | DASHBOARD_ANALYTICS_API = "/api/analytics" 15 | TENANT_THIRD_PARTY_CONFIG_API = "/api/thirdparty/config" 16 | TENANT_API = "/api/tenant" 17 | LIST_TENANTS_WITH_LOGIN_METHODS = "/api/tenants" 18 | UPDATE_TENANT_CORE_CONFIG_API = "/api/tenant/core-config" 19 | UPDATE_TENANT_FIRST_FACTOR_API = "/api/tenant/first-factor" 20 | UPDATE_TENANT_REQUIRED_SECONDARY_FACTOR_API = "/api/tenant/required-secondary-factor" 21 | CREATE_EMAIL_PASSWORD_USER = "/api/user/emailpassword" 22 | CREATE_PASSWORDLESS_USER = "/api/user/passwordless" 23 | UNLINK_USER = "/api/user/unlink" 24 | 25 | USERROLES_LIST_API = "/api/userroles/roles" 26 | USERROLES_PERMISSIONS_API = "/api/userroles/role/permissions" 27 | USERROLES_REMOVE_PERMISSIONS_API = "/api/userroles/role/permissions/remove" 28 | USERROLES_ROLE_API = "/api/userroles/role" 29 | USERROLES_USER_API = "/api/userroles/user/roles" 30 | -------------------------------------------------------------------------------- /supertokens_python/recipe/dashboard/exceptions.py: -------------------------------------------------------------------------------- 1 | from supertokens_python.exceptions import SuperTokensError 2 | 3 | 4 | class SuperTokensDashboardError(SuperTokensError): 5 | pass 6 | 7 | 8 | class DashboardOperationNotAllowedError(SuperTokensDashboardError): 9 | pass 10 | -------------------------------------------------------------------------------- /supertokens_python/recipe/emailpassword/api/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from .email_exists import handle_email_exists_api as handle_email_exists_api 15 | from .generate_password_reset_token import ( 16 | handle_generate_password_reset_token_api as handle_generate_password_reset_token_api, 17 | ) 18 | from .password_reset import handle_password_reset_api as handle_password_reset_api 19 | from .signin import handle_sign_in_api as handle_sign_in_api 20 | from .signup import handle_sign_up_api as handle_sign_up_api 21 | -------------------------------------------------------------------------------- /supertokens_python/recipe/emailpassword/constants.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | FORM_FIELD_PASSWORD_ID = "password" 15 | FORM_FIELD_EMAIL_ID = "email" 16 | SIGNUP = "/signup" 17 | SIGNIN = "/signin" 18 | USER_PASSWORD_RESET_TOKEN = "/user/password/reset/token" 19 | USER_PASSWORD_RESET = "/user/password/reset" 20 | SIGNUP_EMAIL_EXISTS_OLD = "/signup/email/exists" 21 | SIGNUP_EMAIL_EXISTS = "/emailpassword/email/exists" 22 | RESET_PASSWORD = "/reset-password" 23 | -------------------------------------------------------------------------------- /supertokens_python/recipe/emailpassword/emaildelivery/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | -------------------------------------------------------------------------------- /supertokens_python/recipe/emailpassword/emaildelivery/services/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | 15 | from . import smtp 16 | 17 | SMTPService = smtp.SMTPService 18 | -------------------------------------------------------------------------------- /supertokens_python/recipe/emailpassword/emaildelivery/services/smtp/service_implementation/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | 15 | from typing import Any, Dict 16 | 17 | from supertokens_python.ingredients.emaildelivery.types import ( 18 | EmailContent, 19 | SMTPServiceInterface, 20 | ) 21 | from supertokens_python.recipe.emailpassword.emaildelivery.services.smtp.password_reset import ( 22 | get_password_reset_email_content, 23 | ) 24 | from supertokens_python.recipe.emailpassword.types import EmailTemplateVars 25 | 26 | 27 | class ServiceImplementation(SMTPServiceInterface[EmailTemplateVars]): 28 | async def send_raw_email( 29 | self, content: EmailContent, user_context: Dict[str, Any] 30 | ) -> None: 31 | await self.transporter.send_email(content, user_context) 32 | 33 | async def get_content( 34 | self, template_vars: EmailTemplateVars, user_context: Dict[str, Any] 35 | ) -> EmailContent: 36 | return get_password_reset_email_content(template_vars) 37 | -------------------------------------------------------------------------------- /supertokens_python/recipe/emailpassword/exceptions.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from __future__ import annotations 15 | 16 | from typing import TYPE_CHECKING, Any, Dict, List, NoReturn 17 | 18 | from supertokens_python.exceptions import SuperTokensError 19 | 20 | if TYPE_CHECKING: 21 | from .types import ErrorFormField 22 | 23 | 24 | def raise_form_field_exception(msg: str, form_fields: List[ErrorFormField]) -> NoReturn: 25 | raise FieldError(msg, form_fields) 26 | 27 | 28 | class SuperTokensEmailPasswordError(SuperTokensError): 29 | pass 30 | 31 | 32 | class FieldError(SuperTokensEmailPasswordError): 33 | def __init__(self, msg: str, form_fields: List[ErrorFormField]): 34 | super().__init__(msg) 35 | self.form_fields = form_fields 36 | 37 | def get_json_form_fields(self) -> List[Dict[str, Any]]: 38 | form_fields: List[Dict[str, Any]] = [] 39 | for form_field in self.form_fields: 40 | form_fields.append({"id": form_field.id, "error": form_field.error}) 41 | return form_fields 42 | -------------------------------------------------------------------------------- /supertokens_python/recipe/emailverification/api/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from .email_verify import handle_email_verify_api as handle_email_verify_api 15 | from .generate_email_verify_token import ( 16 | handle_generate_email_verify_token_api as handle_generate_email_verify_token_api, 17 | ) 18 | -------------------------------------------------------------------------------- /supertokens_python/recipe/emailverification/constants.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | USER_EMAIL_VERIFY_TOKEN = "/user/email/verify/token" 15 | USER_EMAIL_VERIFY = "/user/email/verify" 16 | -------------------------------------------------------------------------------- /supertokens_python/recipe/emailverification/emaildelivery/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | -------------------------------------------------------------------------------- /supertokens_python/recipe/emailverification/emaildelivery/services/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | 15 | from . import smtp 16 | 17 | SMTPService = smtp.SMTPService 18 | -------------------------------------------------------------------------------- /supertokens_python/recipe/emailverification/exceptions.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from __future__ import annotations 15 | 16 | from supertokens_python.exceptions import SuperTokensError 17 | 18 | 19 | class SuperTokensEmailVerificationError(SuperTokensError): 20 | pass 21 | 22 | 23 | class EmailVerificationInvalidTokenError(SuperTokensEmailVerificationError): 24 | pass 25 | -------------------------------------------------------------------------------- /supertokens_python/recipe/jwt/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from __future__ import annotations 15 | 16 | from typing import TYPE_CHECKING, Callable, Union 17 | 18 | from .recipe import JWTRecipe 19 | from .utils import OverrideConfig 20 | 21 | if TYPE_CHECKING: 22 | from supertokens_python.supertokens import AppInfo 23 | 24 | from ...recipe_module import RecipeModule 25 | 26 | 27 | def init( 28 | jwt_validity_seconds: Union[int, None] = None, 29 | override: Union[OverrideConfig, None] = None, 30 | ) -> Callable[[AppInfo], RecipeModule]: 31 | return JWTRecipe.init(jwt_validity_seconds, override) 32 | -------------------------------------------------------------------------------- /supertokens_python/recipe/jwt/api/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/supertokens_python/recipe/jwt/api/__init__.py -------------------------------------------------------------------------------- /supertokens_python/recipe/jwt/api/implementation.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from typing import Any, Dict 15 | 16 | from supertokens_python.recipe.jwt.interfaces import ( 17 | APIInterface, 18 | APIOptions, 19 | JWKSGetResponse, 20 | ) 21 | 22 | 23 | class APIImplementation(APIInterface): 24 | async def jwks_get( 25 | self, api_options: APIOptions, user_context: Dict[str, Any] 26 | ) -> JWKSGetResponse: 27 | response = await api_options.recipe_implementation.get_jwks(user_context) 28 | 29 | if response.validity_in_secs is not None: 30 | api_options.response.set_header( 31 | "Cache-Control", f"max-age={response.validity_in_secs}, must-revalidate" 32 | ) 33 | 34 | return JWKSGetResponse(response.keys) 35 | -------------------------------------------------------------------------------- /supertokens_python/recipe/jwt/api/jwks_get.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from __future__ import annotations 15 | 16 | from typing import Any, Dict 17 | 18 | from supertokens_python.recipe.jwt.interfaces import APIInterface, APIOptions 19 | from supertokens_python.utils import send_200_response 20 | 21 | from ..interfaces import JWKSGetResponse 22 | 23 | 24 | async def jwks_get( 25 | api_implementation: APIInterface, 26 | api_options: APIOptions, 27 | user_context: Dict[str, Any], 28 | ): 29 | if api_implementation.disable_jwks_get: 30 | return None 31 | 32 | result = await api_implementation.jwks_get(api_options, user_context) 33 | 34 | if isinstance(result, JWKSGetResponse): 35 | api_options.response.set_header("Access-Control-Allow-Origin", "*") 36 | 37 | return send_200_response(result.to_json(), api_options.response) 38 | -------------------------------------------------------------------------------- /supertokens_python/recipe/jwt/constants.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | 15 | GET_JWKS_API = "/jwt/jwks.json" 16 | -------------------------------------------------------------------------------- /supertokens_python/recipe/jwt/exceptions.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from __future__ import annotations 15 | 16 | from supertokens_python.exceptions import SuperTokensError 17 | 18 | 19 | class SuperTokensJWTError(SuperTokensError): 20 | pass 21 | -------------------------------------------------------------------------------- /supertokens_python/recipe/jwt/syncio/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from typing import Any, Dict, Optional, Union 15 | 16 | from supertokens_python.async_to_sync_wrapper import sync 17 | from supertokens_python.recipe.jwt import asyncio 18 | from supertokens_python.recipe.jwt.interfaces import ( 19 | CreateJwtOkResult, 20 | CreateJwtResultUnsupportedAlgorithm, 21 | GetJWKSResult, 22 | ) 23 | 24 | 25 | def create_jwt( 26 | payload: Optional[Dict[str, Any]] = None, 27 | validity_seconds: Optional[int] = None, 28 | use_static_signing_key: Optional[bool] = None, 29 | user_context: Optional[Dict[str, Any]] = None, 30 | ) -> Union[CreateJwtOkResult, CreateJwtResultUnsupportedAlgorithm]: 31 | return sync( 32 | asyncio.create_jwt( 33 | payload, validity_seconds, use_static_signing_key, user_context 34 | ) 35 | ) 36 | 37 | 38 | def get_jwks(user_context: Optional[Dict[str, Any]] = None) -> GetJWKSResult: 39 | return sync(asyncio.get_jwks(user_context)) 40 | -------------------------------------------------------------------------------- /supertokens_python/recipe/multifactorauth/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from __future__ import annotations 15 | 16 | from typing import TYPE_CHECKING, Callable, List, Optional, Union 17 | 18 | from supertokens_python.recipe.multifactorauth.types import OverrideConfig 19 | 20 | from .recipe import MultiFactorAuthRecipe 21 | 22 | if TYPE_CHECKING: 23 | from supertokens_python.supertokens import AppInfo 24 | 25 | from ...recipe_module import RecipeModule 26 | 27 | 28 | def init( 29 | first_factors: Optional[List[str]] = None, 30 | override: Union[OverrideConfig, None] = None, 31 | ) -> Callable[[AppInfo], RecipeModule]: 32 | return MultiFactorAuthRecipe.init( 33 | first_factors, 34 | override, 35 | ) 36 | -------------------------------------------------------------------------------- /supertokens_python/recipe/multifactorauth/api/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | 15 | from .resync_session_and_fetch_mfa_info import ( 16 | handle_resync_session_and_fetch_mfa_info_api as handle_resync_session_and_fetch_mfa_info_api, 17 | ) 18 | -------------------------------------------------------------------------------- /supertokens_python/recipe/multifactorauth/constants.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | RESYNC_SESSION_AND_FETCH_MFA_INFO = "/mfa/info" 15 | -------------------------------------------------------------------------------- /supertokens_python/recipe/multitenancy/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from __future__ import annotations 15 | 16 | from typing import TYPE_CHECKING, Callable, Union 17 | 18 | from . import exceptions as ex 19 | from . import recipe 20 | 21 | AllowedDomainsClaim = recipe.AllowedDomainsClaim 22 | exceptions = ex 23 | 24 | if TYPE_CHECKING: 25 | from supertokens_python.supertokens import AppInfo 26 | 27 | from ...recipe_module import RecipeModule 28 | from .interfaces import TypeGetAllowedDomainsForTenantId 29 | from .utils import InputOverrideConfig 30 | 31 | 32 | def init( 33 | get_allowed_domains_for_tenant_id: Union[ 34 | TypeGetAllowedDomainsForTenantId, None 35 | ] = None, 36 | override: Union[InputOverrideConfig, None] = None, 37 | ) -> Callable[[AppInfo], RecipeModule]: 38 | return recipe.MultitenancyRecipe.init( 39 | get_allowed_domains_for_tenant_id, 40 | override, 41 | ) 42 | -------------------------------------------------------------------------------- /supertokens_python/recipe/multitenancy/api/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from .login_methods import handle_login_methods_api as handle_login_methods_api 15 | -------------------------------------------------------------------------------- /supertokens_python/recipe/multitenancy/api/login_methods.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from __future__ import annotations 15 | 16 | from typing import Any, Dict 17 | 18 | from supertokens_python.recipe.multitenancy.interfaces import ( 19 | APIInterface, 20 | APIOptions, 21 | ) 22 | from supertokens_python.utils import send_200_response 23 | 24 | 25 | async def handle_login_methods_api( 26 | api_implementation: APIInterface, 27 | tenant_id: str, 28 | api_options: APIOptions, 29 | user_context: Dict[str, Any], 30 | ): 31 | if api_implementation.disable_login_methods_get: 32 | return None 33 | 34 | client_type = api_options.request.get_query_param("clientType") 35 | 36 | result = await api_implementation.login_methods_get( 37 | tenant_id, client_type, api_options, user_context 38 | ) 39 | 40 | return send_200_response(result.to_json(), api_options.response) 41 | -------------------------------------------------------------------------------- /supertokens_python/recipe/multitenancy/constants.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | LOGIN_METHODS = "/loginmethods" 15 | DEFAULT_TENANT_ID = "public" 16 | -------------------------------------------------------------------------------- /supertokens_python/recipe/multitenancy/exceptions.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from __future__ import annotations 15 | 16 | from supertokens_python.exceptions import SuperTokensError 17 | 18 | 19 | class MultitenancyError(SuperTokensError): 20 | pass 21 | -------------------------------------------------------------------------------- /supertokens_python/recipe/oauth2provider/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from __future__ import annotations 15 | 16 | from typing import TYPE_CHECKING, Callable, Union 17 | 18 | from . import exceptions as ex 19 | from . import recipe, utils 20 | 21 | exceptions = ex 22 | InputOverrideConfig = utils.InputOverrideConfig 23 | 24 | if TYPE_CHECKING: 25 | from supertokens_python.supertokens import AppInfo 26 | 27 | from ...recipe_module import RecipeModule 28 | 29 | 30 | def init( 31 | override: Union[InputOverrideConfig, None] = None, 32 | ) -> Callable[[AppInfo], RecipeModule]: 33 | return recipe.OAuth2ProviderRecipe.init(override) 34 | -------------------------------------------------------------------------------- /supertokens_python/recipe/oauth2provider/api/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | 15 | from .auth import auth_get as auth_get 16 | from .end_session import end_session_get as end_session_get 17 | from .end_session import end_session_post as end_session_post 18 | from .introspect_token import introspect_token_post as introspect_token_post 19 | from .login import login as login 20 | from .login_info import login_info_get as login_info_get 21 | from .logout import logout_post as logout_post 22 | from .revoke_token import revoke_token_post as revoke_token_post 23 | from .token import token_post as token_post 24 | from .user_info import user_info_get as user_info_get 25 | -------------------------------------------------------------------------------- /supertokens_python/recipe/oauth2provider/constants.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | 15 | 16 | LOGIN_PATH = "/oauth/login" 17 | AUTH_PATH = "/oauth/auth" 18 | TOKEN_PATH = "/oauth/token" 19 | LOGIN_INFO_PATH = "/oauth/login/info" 20 | USER_INFO_PATH = "/oauth/userinfo" 21 | REVOKE_TOKEN_PATH = "/oauth/revoke" 22 | INTROSPECT_TOKEN_PATH = "/oauth/introspect" 23 | END_SESSION_PATH = "/oauth/end_session" 24 | LOGOUT_PATH = "/oauth/logout" 25 | -------------------------------------------------------------------------------- /supertokens_python/recipe/oauth2provider/exceptions.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from __future__ import annotations 15 | 16 | from supertokens_python.exceptions import SuperTokensError 17 | 18 | 19 | class OAuth2ProviderError(SuperTokensError): 20 | pass 21 | -------------------------------------------------------------------------------- /supertokens_python/recipe/openid/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from __future__ import annotations 15 | 16 | from typing import TYPE_CHECKING, Callable, Union 17 | 18 | from .recipe import OpenIdRecipe 19 | from .utils import InputOverrideConfig 20 | 21 | if TYPE_CHECKING: 22 | from supertokens_python.supertokens import AppInfo 23 | 24 | from ...recipe_module import RecipeModule 25 | 26 | 27 | def init( 28 | issuer: Union[str, None] = None, 29 | override: Union[InputOverrideConfig, None] = None, 30 | ) -> Callable[[AppInfo], RecipeModule]: 31 | return OpenIdRecipe.init(issuer, override) 32 | -------------------------------------------------------------------------------- /supertokens_python/recipe/openid/api/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/supertokens_python/recipe/openid/api/__init__.py -------------------------------------------------------------------------------- /supertokens_python/recipe/openid/api/open_id_discovery_configuration_get.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from __future__ import annotations 15 | 16 | from typing import Any, Dict 17 | 18 | from supertokens_python.recipe.openid.interfaces import APIInterface, APIOptions 19 | from supertokens_python.utils import send_200_response 20 | 21 | from ..interfaces import OpenIdDiscoveryConfigurationGetResponse 22 | 23 | 24 | async def open_id_discovery_configuration_get( 25 | api_implementation: APIInterface, 26 | api_options: APIOptions, 27 | user_context: Dict[str, Any], 28 | ): 29 | if api_implementation.disable_open_id_discovery_configuration_get: 30 | return None 31 | 32 | result = await api_implementation.open_id_discovery_configuration_get( 33 | api_options, user_context 34 | ) 35 | 36 | if isinstance(result, OpenIdDiscoveryConfigurationGetResponse): 37 | api_options.response.set_header("Access-Control-Allow-Origin", "*") 38 | return send_200_response(result.to_json(), api_options.response) 39 | -------------------------------------------------------------------------------- /supertokens_python/recipe/openid/constants.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | 15 | GET_DISCOVERY_CONFIG_URL = "/.well-known/openid-configuration" 16 | -------------------------------------------------------------------------------- /supertokens_python/recipe/openid/exceptions.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from __future__ import annotations 15 | 16 | from supertokens_python.exceptions import SuperTokensError 17 | 18 | 19 | class SuperTokensOpenIdError(SuperTokensError): 20 | pass 21 | -------------------------------------------------------------------------------- /supertokens_python/recipe/passwordless/api/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | 15 | from .consume_code import consume_code as consume_code 16 | from .create_code import create_code as create_code 17 | from .email_exists import email_exists as email_exists 18 | from .phone_number_exists import phone_number_exists as phone_number_exists 19 | from .resend_code import resend_code as resend_code 20 | -------------------------------------------------------------------------------- /supertokens_python/recipe/passwordless/api/email_exists.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from __future__ import annotations 15 | 16 | from typing import Any, Dict 17 | 18 | from supertokens_python.exceptions import raise_bad_input_exception 19 | from supertokens_python.recipe.passwordless.interfaces import APIInterface, APIOptions 20 | from supertokens_python.utils import send_200_response 21 | 22 | 23 | async def email_exists( 24 | api_implementation: APIInterface, 25 | tenant_id: str, 26 | api_options: APIOptions, 27 | user_context: Dict[str, Any], 28 | ): 29 | if api_implementation.disable_email_exists_get: 30 | return None 31 | 32 | email = api_options.request.get_query_param("email") 33 | if email is None: 34 | raise_bad_input_exception("Please provide the email as a GET param") 35 | 36 | result = await api_implementation.email_exists_get( 37 | email, tenant_id, api_options, user_context 38 | ) 39 | return send_200_response(result.to_json(), api_options.response) 40 | -------------------------------------------------------------------------------- /supertokens_python/recipe/passwordless/api/phone_number_exists.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from typing import Any, Dict 15 | 16 | from supertokens_python.exceptions import raise_bad_input_exception 17 | from supertokens_python.recipe.passwordless.interfaces import APIInterface, APIOptions 18 | from supertokens_python.utils import send_200_response 19 | 20 | 21 | async def phone_number_exists( 22 | api_implementation: APIInterface, 23 | tenant_id: str, 24 | api_options: APIOptions, 25 | user_context: Dict[str, Any], 26 | ): 27 | if api_implementation.disable_phone_number_exists_get: 28 | return None 29 | 30 | phone_number = api_options.request.get_query_param("phoneNumber") 31 | if phone_number is None: 32 | raise_bad_input_exception("Please provide the phoneNumber as a GET param") 33 | 34 | result = await api_implementation.phone_number_exists_get( 35 | phone_number, tenant_id, api_options, user_context 36 | ) 37 | return send_200_response(result.to_json(), api_options.response) 38 | -------------------------------------------------------------------------------- /supertokens_python/recipe/passwordless/constants.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | 15 | CREATE_CODE_API = "/signinup/code" 16 | RESEND_CODE_API = "/signinup/code/resend" 17 | CONSUME_CODE_API = "/signinup/code/consume" 18 | DOES_EMAIL_EXIST_API_OLD = "/signup/email/exists" 19 | DOES_PHONE_NUMBER_EXIST_API_OLD = "/signup/phonenumber/exists" 20 | DOES_EMAIL_EXIST_API = "/passwordless/email/exists" 21 | DOES_PHONE_NUMBER_EXIST_API = "/passwordless/phonenumber/exists" 22 | -------------------------------------------------------------------------------- /supertokens_python/recipe/passwordless/emaildelivery/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | -------------------------------------------------------------------------------- /supertokens_python/recipe/passwordless/emaildelivery/services/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | 15 | from . import smtp 16 | 17 | SMTPService = smtp.SMTPService 18 | -------------------------------------------------------------------------------- /supertokens_python/recipe/passwordless/exceptions.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from __future__ import annotations 15 | 16 | from supertokens_python.exceptions import SuperTokensError 17 | 18 | 19 | class SuperTokensPasswordlessError(SuperTokensError): 20 | pass 21 | -------------------------------------------------------------------------------- /supertokens_python/recipe/passwordless/smsdelivery/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | -------------------------------------------------------------------------------- /supertokens_python/recipe/passwordless/smsdelivery/services/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | 15 | from . import supertokens, twilio 16 | 17 | SuperTokensSMSService = supertokens.SuperTokensSMSService 18 | TwilioService = twilio.TwilioService 19 | -------------------------------------------------------------------------------- /supertokens_python/recipe/session/api/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from .refresh import handle_refresh_api as handle_refresh_api 15 | from .signout import handle_signout_api as handle_signout_api 16 | -------------------------------------------------------------------------------- /supertokens_python/recipe/session/api/refresh.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from __future__ import annotations 15 | 16 | from typing import TYPE_CHECKING, Any, Dict 17 | 18 | if TYPE_CHECKING: 19 | from supertokens_python.recipe.session.interfaces import APIInterface, APIOptions 20 | 21 | from supertokens_python.utils import send_200_response 22 | 23 | 24 | async def handle_refresh_api( 25 | api_implementation: APIInterface, 26 | api_options: APIOptions, 27 | user_context: Dict[str, Any], 28 | ): 29 | if ( 30 | api_implementation.disable_refresh_post 31 | or api_implementation.refresh_post is None # type: ignore 32 | ): 33 | return None 34 | 35 | await api_implementation.refresh_post(api_options, user_context) 36 | if api_options.response is None: 37 | raise Exception("Should never come here") 38 | return send_200_response({}, api_options.response) 39 | -------------------------------------------------------------------------------- /supertokens_python/recipe/session/claim_base_classes/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | -------------------------------------------------------------------------------- /supertokens_python/recipe/session/claims.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | 15 | from . import interfaces 16 | from .claim_base_classes import boolean_claim, primitive_array_claim, primitive_claim 17 | 18 | SessionClaim = interfaces.SessionClaim 19 | BooleanClaim = boolean_claim.BooleanClaim 20 | PrimitiveClaim = primitive_claim.PrimitiveClaim 21 | PrimitiveArrayClaim = primitive_array_claim.PrimitiveArrayClaim 22 | -------------------------------------------------------------------------------- /supertokens_python/recipe/session/framework/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | -------------------------------------------------------------------------------- /supertokens_python/recipe/session/framework/django/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | -------------------------------------------------------------------------------- /supertokens_python/recipe/thirdparty/api/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from .apple_redirect import handle_apple_redirect_api 15 | from .authorisation_url import handle_authorisation_url_api 16 | from .signinup import handle_sign_in_up_api 17 | 18 | __all__ = [ 19 | "handle_apple_redirect_api", 20 | "handle_authorisation_url_api", 21 | "handle_sign_in_up_api", 22 | ] 23 | -------------------------------------------------------------------------------- /supertokens_python/recipe/thirdparty/api/apple_redirect.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from __future__ import annotations 15 | 16 | from typing import TYPE_CHECKING, Any, Dict 17 | 18 | if TYPE_CHECKING: 19 | from supertokens_python.recipe.thirdparty.interfaces import APIInterface, APIOptions 20 | 21 | 22 | async def handle_apple_redirect_api( 23 | api_implementation: APIInterface, 24 | api_options: APIOptions, 25 | user_context: Dict[str, Any], 26 | ): 27 | if api_implementation.disable_apple_redirect_handler_post: 28 | return None 29 | 30 | body = await api_options.request.form_data() 31 | 32 | # this will redirect the user... 33 | await api_implementation.apple_redirect_handler_post( 34 | body, api_options, user_context 35 | ) 36 | 37 | return api_options.response 38 | -------------------------------------------------------------------------------- /supertokens_python/recipe/thirdparty/constants.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | AUTHORISATIONURL = "/authorisationurl" 15 | SIGNINUP = "/signinup" 16 | SIGNOUT = "/signout" 17 | SIGNUP_EMAIL_EXISTS = "/signup/email/exists" 18 | RESET_PASSWORD = "/reset-password" 19 | APPLE_REDIRECT_HANDLER = "/callback/apple" 20 | -------------------------------------------------------------------------------- /supertokens_python/recipe/thirdparty/exceptions.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from __future__ import annotations 15 | 16 | from supertokens_python.exceptions import SuperTokensError 17 | 18 | 19 | class SuperTokensThirdPartyError(SuperTokensError): 20 | pass 21 | 22 | 23 | class ClientTypeNotFoundError(SuperTokensError): 24 | def __init__(self, message: str): 25 | super().__init__() 26 | self.message = message 27 | -------------------------------------------------------------------------------- /supertokens_python/recipe/thirdparty/providers/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | -------------------------------------------------------------------------------- /supertokens_python/recipe/totp/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from __future__ import annotations 15 | 16 | from typing import TYPE_CHECKING, Callable, Union 17 | 18 | from supertokens_python.recipe.totp.types import TOTPConfig 19 | 20 | from .recipe import TOTPRecipe 21 | 22 | if TYPE_CHECKING: 23 | from supertokens_python.supertokens import AppInfo 24 | 25 | from ...recipe_module import RecipeModule 26 | 27 | 28 | def init( 29 | config: Union[TOTPConfig, None] = None, 30 | ) -> Callable[[AppInfo], RecipeModule]: 31 | return TOTPRecipe.init( 32 | config=config, 33 | ) 34 | -------------------------------------------------------------------------------- /supertokens_python/recipe/totp/api/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from .create_device import handle_create_device_api 15 | from .list_devices import handle_list_devices_api 16 | from .remove_device import handle_remove_device_api 17 | from .verify_device import handle_verify_device_api 18 | from .verify_totp import handle_verify_totp_api 19 | 20 | __all__ = [ 21 | "handle_create_device_api", 22 | "handle_list_devices_api", 23 | "handle_remove_device_api", 24 | "handle_verify_device_api", 25 | "handle_verify_totp_api", 26 | ] 27 | -------------------------------------------------------------------------------- /supertokens_python/recipe/totp/constants.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | 15 | CREATE_TOTP_DEVICE = "/totp/device" 16 | LIST_TOTP_DEVICES = "/totp/device/list" 17 | REMOVE_TOTP_DEVICE = "/totp/device/remove" 18 | VERIFY_TOTP_DEVICE = "/totp/device/verify" 19 | VERIFY_TOTP = "/totp/verify" 20 | -------------------------------------------------------------------------------- /supertokens_python/recipe/usermetadata/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from __future__ import annotations 15 | 16 | from typing import TYPE_CHECKING, Callable, Union 17 | 18 | from . import utils 19 | from .recipe import UserMetadataRecipe 20 | 21 | if TYPE_CHECKING: 22 | from supertokens_python.supertokens import AppInfo 23 | 24 | from ...recipe_module import RecipeModule 25 | 26 | 27 | def init( 28 | override: Union[utils.InputOverrideConfig, None] = None, 29 | ) -> Callable[[AppInfo], RecipeModule]: 30 | return UserMetadataRecipe.init(override) 31 | -------------------------------------------------------------------------------- /supertokens_python/recipe/usermetadata/asyncio/__init__.py: -------------------------------------------------------------------------------- 1 | from typing import Any, Dict, Union 2 | 3 | from supertokens_python.recipe.usermetadata.recipe import UserMetadataRecipe 4 | 5 | 6 | async def get_user_metadata( 7 | user_id: str, user_context: Union[Dict[str, Any], None] = None 8 | ): 9 | if user_context is None: 10 | user_context = {} 11 | return ( 12 | await UserMetadataRecipe.get_instance().recipe_implementation.get_user_metadata( 13 | user_id, user_context 14 | ) 15 | ) 16 | 17 | 18 | async def update_user_metadata( 19 | user_id: str, 20 | metadata_update: Dict[str, Any], 21 | user_context: Union[Dict[str, Any], None] = None, 22 | ): 23 | if user_context is None: 24 | user_context = {} 25 | return await UserMetadataRecipe.get_instance().recipe_implementation.update_user_metadata( 26 | user_id, metadata_update, user_context 27 | ) 28 | 29 | 30 | async def clear_user_metadata( 31 | user_id: str, user_context: Union[Dict[str, Any], None] = None 32 | ): 33 | if user_context is None: 34 | user_context = {} 35 | return await UserMetadataRecipe.get_instance().recipe_implementation.clear_user_metadata( 36 | user_id, user_context 37 | ) 38 | -------------------------------------------------------------------------------- /supertokens_python/recipe/usermetadata/exceptions.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | 15 | from supertokens_python.exceptions import SuperTokensError 16 | 17 | 18 | class SuperTokensUserMetadataError(SuperTokensError): 19 | pass 20 | -------------------------------------------------------------------------------- /supertokens_python/recipe/usermetadata/interfaces.py: -------------------------------------------------------------------------------- 1 | from abc import ABC, abstractmethod 2 | from typing import Any, Dict 3 | 4 | 5 | class MetadataResult(ABC): 6 | def __init__(self, metadata: Dict[str, Any]): 7 | self.metadata = metadata 8 | 9 | 10 | class ClearUserMetadataResult: 11 | pass 12 | 13 | 14 | class RecipeInterface(ABC): 15 | @abstractmethod 16 | async def get_user_metadata( 17 | self, user_id: str, user_context: Dict[str, Any] 18 | ) -> MetadataResult: 19 | pass 20 | 21 | @abstractmethod 22 | async def update_user_metadata( 23 | self, 24 | user_id: str, 25 | metadata_update: Dict[str, Any], 26 | user_context: Dict[str, Any], 27 | ) -> MetadataResult: 28 | pass 29 | 30 | @abstractmethod 31 | async def clear_user_metadata( 32 | self, user_id: str, user_context: Dict[str, Any] 33 | ) -> ClearUserMetadataResult: 34 | pass 35 | 36 | 37 | class APIInterface(ABC): 38 | pass 39 | -------------------------------------------------------------------------------- /supertokens_python/recipe/usermetadata/syncio/__init__.py: -------------------------------------------------------------------------------- 1 | from typing import Any, Dict, Union 2 | 3 | from supertokens_python.async_to_sync_wrapper import sync 4 | 5 | 6 | def get_user_metadata(user_id: str, user_context: Union[Dict[str, Any], None] = None): 7 | from supertokens_python.recipe.usermetadata.asyncio import get_user_metadata 8 | 9 | return sync(get_user_metadata(user_id, user_context)) 10 | 11 | 12 | def update_user_metadata( 13 | user_id: str, 14 | metadata_update: Dict[str, Any], 15 | user_context: Union[Dict[str, Any], None] = None, 16 | ): 17 | from supertokens_python.recipe.usermetadata.asyncio import update_user_metadata 18 | 19 | return sync(update_user_metadata(user_id, metadata_update, user_context)) 20 | 21 | 22 | def clear_user_metadata(user_id: str, user_context: Union[Dict[str, Any], None] = None): 23 | from supertokens_python.recipe.usermetadata.asyncio import clear_user_metadata 24 | 25 | return sync(clear_user_metadata(user_id, user_context)) 26 | -------------------------------------------------------------------------------- /supertokens_python/recipe/userroles/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | from __future__ import annotations 15 | 16 | from typing import TYPE_CHECKING, Callable, Optional, Union 17 | 18 | from . import recipe, utils 19 | from .recipe import UserRolesRecipe 20 | 21 | PermissionClaim = recipe.PermissionClaim 22 | UserRoleClaim = recipe.UserRoleClaim 23 | 24 | if TYPE_CHECKING: 25 | from supertokens_python.supertokens import AppInfo 26 | 27 | from ...recipe_module import RecipeModule 28 | 29 | 30 | def init( 31 | skip_adding_roles_to_access_token: Optional[bool] = None, 32 | skip_adding_permissions_to_access_token: Optional[bool] = None, 33 | override: Union[utils.InputOverrideConfig, None] = None, 34 | ) -> Callable[[AppInfo], RecipeModule]: 35 | return UserRolesRecipe.init( 36 | skip_adding_roles_to_access_token, 37 | skip_adding_permissions_to_access_token, 38 | override, 39 | ) 40 | -------------------------------------------------------------------------------- /supertokens_python/recipe/userroles/exceptions.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | 15 | from supertokens_python.exceptions import SuperTokensError 16 | 17 | 18 | class SuperTokensUserRolesError(SuperTokensError): 19 | pass 20 | -------------------------------------------------------------------------------- /tests/Django/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/Django/__init__.py -------------------------------------------------------------------------------- /tests/Django/sqlite.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/Django/sqlite.db -------------------------------------------------------------------------------- /tests/Docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM rishabhpoddar/supertokens_core_testing:ubuntu18 2 | 3 | RUN apt update && apt install software-properties-common -y 4 | 5 | RUN curl -sL https://deb.nodesource.com/setup_10.x -o nodesource_setup.sh 6 | 7 | RUN chmod +x nodesource_setup.sh 8 | 9 | RUN ./nodesource_setup.sh 10 | 11 | RUN apt-get install -y nodejs 12 | 13 | RUN apt-get update 14 | 15 | RUN apt-get install -y gconf-service lsof libasound2 libatk1.0-0 libgbm-dev libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget 16 | 17 | RUN add-apt-repository ppa:deadsnakes/ppa -y 18 | 19 | RUN apt-get update 20 | 21 | RUN apt-get install python3.7 -y 22 | 23 | RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 1 24 | 25 | RUN echo 'alias pip=pip3\nalias python=python3.7' >> ~/.bashrc 26 | 27 | RUN wget https://bootstrap.pypa.io/get-pip.py 28 | 29 | RUN apt install python3.7-distutils -y 30 | 31 | RUN python3.7 get-pip.py 32 | 33 | RUN curl -s https://deb.nodesource.com/setup_14.x | bash 34 | 35 | RUN apt install nodejs -y 36 | 37 | RUN npm install -g n 38 | 39 | RUN n 14 40 | -------------------------------------------------------------------------------- /tests/Fastapi/__init__.py: -------------------------------------------------------------------------------- 1 | import nest_asyncio # type: ignore 2 | 3 | nest_asyncio.apply() # type: ignore 4 | -------------------------------------------------------------------------------- /tests/Flask/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/Flask/__init__.py -------------------------------------------------------------------------------- /tests/Flask/utils.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | 15 | 16 | from typing import Any, Dict 17 | 18 | from werkzeug.test import TestResponse 19 | 20 | 21 | def extract_all_cookies(response: TestResponse) -> Dict[str, Any]: 22 | cookie_headers = response.headers.getlist("Set-Cookie") 23 | cookies: Dict[str, Any] = {} 24 | for header in cookie_headers: 25 | attributes = header.split(";") 26 | cookie = {} 27 | is_name = True 28 | name: str = "" 29 | for attr in attributes: 30 | split = attr.split("=") 31 | if is_name: 32 | name = split[0].strip() 33 | cookie["value"] = split[1] 34 | is_name = False 35 | else: 36 | cookie[split[0].strip().lower()] = split[1] if len(split) > 1 else True 37 | cookies[name] = cookie 38 | return cookies 39 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | 15 | import nest_asyncio # type: ignore 16 | 17 | nest_asyncio.apply() # type: ignore 18 | -------------------------------------------------------------------------------- /tests/auth-react/auth-react.env: -------------------------------------------------------------------------------- 1 | # Github 2 | GITHUB_CLIENT_ID=3252a5c90b03cf443809 3 | GITHUB_CLIENT_SECRET=52d734435c33ba639e4c96dc0637b1732034f44b 4 | # Google 5 | GOOGLE_CLIENT_ID=32344485696-ghkrbkgc6e3ar39nvmmbuvgn0g71923s.apps.googleusercontent.com 6 | GOOGLE_CLIENT_SECRET=hK_o4jHsglS_qdCU6qGgoMz2 7 | # Facebook 8 | FACEBOOK_CLIENT_ID=1149041618882342 9 | FACEBOOK_CLIENT_SECRET=d6bb1171262bbe9095053145de07cd32 10 | # Auth0 11 | AUTH0_CLIENT_ID=hlhUyF1OvpCYqODkkjdeNAuDdVdDNkIm 12 | AUTH0_CLIENT_SECRET=CBNLgo3j2G-RuZWowNV5x9rPNio1O44y4sEl_jZSOWIQ1Pad_4hN-qD8TWs405pa 13 | AUTH0_DOMAIN=dev-3myi6b3e.us.auth0.com 14 | -------------------------------------------------------------------------------- /tests/auth-react/django3x/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/auth-react/django3x/__init__.py -------------------------------------------------------------------------------- /tests/auth-react/django3x/db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/auth-react/django3x/db.sqlite3 -------------------------------------------------------------------------------- /tests/auth-react/django3x/main.py: -------------------------------------------------------------------------------- 1 | # This is a sample Python script. 2 | 3 | # Press ⌃R to execute it or replace it with your code. 4 | # Press Double ⇧ to search everywhere for classes, files, tool windows, 5 | # actions, and settings. 6 | 7 | # Press the green button in the gutter to run the script. 8 | if __name__ == "__main__": 9 | pass 10 | 11 | # See PyCharm help at https://www.jetbrains.com/help/pycharm/ 12 | -------------------------------------------------------------------------------- /tests/auth-react/django3x/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Django's command-line utility for administrative tasks.""" 3 | 4 | import os 5 | import sys 6 | 7 | 8 | def main(): 9 | os.environ.setdefault("SUPERTOKENS_ENV", "testing") 10 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") 11 | try: 12 | from django.core.management import execute_from_command_line 13 | except ImportError as exc: 14 | raise ImportError( 15 | "Couldn't import Django. Are you sure it's installed and " 16 | "available on your PYTHONPATH environment variable? Did you " 17 | "forget to activate a virtual environment?" 18 | ) from exc 19 | execute_from_command_line(sys.argv) 20 | 21 | 22 | if __name__ == "__main__": 23 | main() 24 | -------------------------------------------------------------------------------- /tests/auth-react/django3x/mysite/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/auth-react/django3x/mysite/__init__.py -------------------------------------------------------------------------------- /tests/auth-react/django3x/mysite/asgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | ASGI config for django3x project. 3 | 4 | It exposes the ASGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.asgi import get_asgi_application 13 | 14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") 15 | os.environ.setdefault("SUPERTOKENS_ENV", "testing") 16 | 17 | application = get_asgi_application() 18 | -------------------------------------------------------------------------------- /tests/auth-react/django3x/mysite/middleware.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | from typing import Callable 3 | 4 | from django.http import HttpRequest, HttpResponse 5 | 6 | 7 | def custom_cors_middleware(get_response): # type: ignore 8 | if asyncio.iscoroutinefunction(get_response): # type: ignore 9 | 10 | async def __middleware1(request: HttpRequest): # type: ignore 11 | response: HttpResponse = await get_response(request) # type: ignore 12 | if request.method == "OPTIONS": 13 | response.status_code = 204 14 | return response # type: ignore 15 | 16 | return __middleware1 17 | else: 18 | 19 | def __middleware(request: HttpRequest): # type: ignore 20 | response: HttpResponse = get_response(request) # type: ignore 21 | 22 | if request.method == "OPTIONS": 23 | response.status_code = 204 24 | return response # type: ignore 25 | 26 | return __middleware 27 | 28 | 29 | def response_logging_middleware(get_response: Callable): # type: ignore 30 | def middleware(request: HttpRequest) -> HttpResponse: 31 | response = get_response(request) # type: ignore 32 | 33 | # Log the response 34 | print( 35 | f"Path: {request.path} | Method: {request.method} | Status: {response.status_code}" # type: ignore 36 | ) 37 | if hasattr(response, "content"): # type: ignore 38 | print(f"Response: {response.content.decode('utf-8')}") # type: ignore 39 | 40 | return response # type: ignore 41 | 42 | return middleware 43 | -------------------------------------------------------------------------------- /tests/auth-react/django3x/mysite/server.py: -------------------------------------------------------------------------------- 1 | import uvicorn # type: ignore 2 | 3 | if __name__ == "__main__": 4 | uvicorn.run( # type: ignore 5 | "asgi:application", host="localhost.org", port=8080, log_level="info" 6 | ) 7 | -------------------------------------------------------------------------------- /tests/auth-react/django3x/mysite/urls.py: -------------------------------------------------------------------------------- 1 | """mysite URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/2.2/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: path('', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.urls import include, path 14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 15 | """ 16 | 17 | from django.urls import include, path 18 | 19 | urlpatterns = [ 20 | path("", include("polls.urls")), 21 | ] 22 | -------------------------------------------------------------------------------- /tests/auth-react/django3x/mysite/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for mysite project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") 15 | os.environ.setdefault("SUPERTOKENS_ENV", "testing") 16 | 17 | application = get_wsgi_application() 18 | -------------------------------------------------------------------------------- /tests/auth-react/django3x/polls/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/auth-react/django3x/polls/__init__.py -------------------------------------------------------------------------------- /tests/auth-react/django3x/polls/admin.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/auth-react/django3x/polls/admin.py -------------------------------------------------------------------------------- /tests/auth-react/django3x/polls/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class PollsConfig(AppConfig): 5 | name = "polls" 6 | 7 | def ready(self): 8 | pass 9 | -------------------------------------------------------------------------------- /tests/auth-react/django3x/polls/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/auth-react/django3x/polls/migrations/__init__.py -------------------------------------------------------------------------------- /tests/auth-react/django3x/polls/models.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/auth-react/django3x/polls/models.py -------------------------------------------------------------------------------- /tests/auth-react/django3x/polls/tests.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/auth-react/django3x/polls/tests.py -------------------------------------------------------------------------------- /tests/auth-react/fastapi-server/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/auth-react/fastapi-server/__init__.py -------------------------------------------------------------------------------- /tests/auth-react/flask-server/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/auth-react/flask-server/__init__.py -------------------------------------------------------------------------------- /tests/conftest.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from tests.utils import reset 4 | 5 | 6 | def pytest_configure(): 7 | import os 8 | 9 | os.environ.setdefault("SUPERTOKENS_ENV", "testing") 10 | os.environ.setdefault("SUPERTOKENS_PATH", "../supertokens-root") 11 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tests.Django.settings") 12 | 13 | 14 | @pytest.fixture(autouse=True) 15 | def setup_teardown(): 16 | """ 17 | Common setup/teardown for all tests. 18 | Runs per-test. 19 | """ 20 | 21 | # Setup 22 | reset() 23 | 24 | # Yield to test function 25 | yield 26 | 27 | # Teardown 28 | reset() 29 | -------------------------------------------------------------------------------- /tests/dashboard/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/dashboard/__init__.py -------------------------------------------------------------------------------- /tests/emailpassword/__init__.py: -------------------------------------------------------------------------------- 1 | import nest_asyncio # type: ignore 2 | 3 | nest_asyncio.apply() # type: ignore 4 | -------------------------------------------------------------------------------- /tests/frontendIntegration/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/frontendIntegration/__init__.py -------------------------------------------------------------------------------- /tests/frontendIntegration/django2x/README.md: -------------------------------------------------------------------------------- 1 | # Django2 example 2 | 3 | This is an example to show how to use supertokens-python library with django3 framework. This example works with django version 2.2 and python version 3.8. 4 | 5 | ## Installation 6 | 7 | Before installing, use the script to create a virtual environment and to install all the required packages. 8 | ```bash 9 | source create_env.sh 10 | ``` 11 | 12 | ## Start web app 13 | 14 | ```bash 15 | python manage.py runsever 16 | ``` 17 | -------------------------------------------------------------------------------- /tests/frontendIntegration/django2x/create_env.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | pip install virtualenv 4 | 5 | #Create a virtualenv 6 | virtualenv django2x_example 7 | # shellcheck disable=SC2164 8 | source django2x_example/bin/activate 9 | 10 | touch requirements.txt 11 | echo "django==2.2" >> requirements.txt 12 | pip install -r requirements.txt 13 | pip install ../../package/supertokens_python-2.0.0-py2.py3-none-any.whl 14 | -------------------------------------------------------------------------------- /tests/frontendIntegration/django2x/db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/frontendIntegration/django2x/db.sqlite3 -------------------------------------------------------------------------------- /tests/frontendIntegration/django2x/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Django's command-line utility for administrative tasks.""" 3 | 4 | import os 5 | import sys 6 | 7 | 8 | def main(): 9 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") 10 | try: 11 | from django.core.management import execute_from_command_line 12 | except ImportError as exc: 13 | raise ImportError( 14 | "Couldn't import Django. Are you sure it's installed and " 15 | "available on your PYTHONPATH environment variable? Did you " 16 | "forget to activate a virtual environment?" 17 | ) from exc 18 | execute_from_command_line(sys.argv) 19 | 20 | 21 | if __name__ == "__main__": 22 | main() 23 | -------------------------------------------------------------------------------- /tests/frontendIntegration/django2x/mysite/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/frontendIntegration/django2x/mysite/__init__.py -------------------------------------------------------------------------------- /tests/frontendIntegration/django2x/mysite/urls.py: -------------------------------------------------------------------------------- 1 | """mysite URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/2.2/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: path('', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.urls import include, path 14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 15 | """ 16 | 17 | from django.contrib import admin 18 | from django.urls import include, path 19 | 20 | urlpatterns = [ 21 | path("admin/", admin.site.urls), 22 | path("", include("polls.urls")), 23 | ] 24 | -------------------------------------------------------------------------------- /tests/frontendIntegration/django2x/mysite/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for mysite project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") 15 | 16 | if True: 17 | # to help middleware function with uvicorn (to ensure supertokens init is called) 18 | from polls.views import config 19 | 20 | core_host = os.environ.get("SUPERTOKENS_CORE_HOST", "localhost") 21 | core_port = os.environ.get("SUPERTOKENS_CORE_PORT", "3567") 22 | 23 | config( 24 | core_url=f"http://{core_host}:{core_port}", 25 | enable_anti_csrf=True, 26 | enable_jwt=False, 27 | jwt_property_name=None, 28 | ) 29 | 30 | application = get_wsgi_application() 31 | -------------------------------------------------------------------------------- /tests/frontendIntegration/django2x/polls/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/frontendIntegration/django2x/polls/__init__.py -------------------------------------------------------------------------------- /tests/frontendIntegration/django2x/polls/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class PollsConfig(AppConfig): 5 | name = "polls" 6 | -------------------------------------------------------------------------------- /tests/frontendIntegration/django2x/polls/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/frontendIntegration/django2x/polls/migrations/__init__.py -------------------------------------------------------------------------------- /tests/frontendIntegration/django2x/requirements.txt: -------------------------------------------------------------------------------- 1 | django==2.2 2 | django-cors-headers==3.11 3 | -------------------------------------------------------------------------------- /tests/frontendIntegration/django3x/README.md: -------------------------------------------------------------------------------- 1 | # Django3 example 2 | 3 | This is an example to show how to use supertokens-python library with django3 framework. This example works with django version 3.2.12 and python version 3.8. 4 | 5 | ## Installation 6 | 7 | Before installing, use the script to create a virtual environment and to install all the required packages. 8 | ```bash 9 | source create_env.sh 10 | ``` 11 | 12 | ## Start web app 13 | 14 | ```bash 15 | python manage.py runsever 16 | ``` 17 | -------------------------------------------------------------------------------- /tests/frontendIntegration/django3x/create_env.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | pip install virtualenv 4 | 5 | #Create a virtualenv 6 | virtualenv django3x_example 7 | # shellcheck disable=SC2164 8 | source django3x_example/bin/activate 9 | 10 | touch requirements.txt 11 | echo "django==3.2.12" >> requirements.txt 12 | pip install -r requirements.txt 13 | pip install ../../package/supertokens_python-2.0.0-py2.py3-none-any.whl 14 | -------------------------------------------------------------------------------- /tests/frontendIntegration/django3x/db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/frontendIntegration/django3x/db.sqlite3 -------------------------------------------------------------------------------- /tests/frontendIntegration/django3x/main.py: -------------------------------------------------------------------------------- 1 | # This is a sample Python script. 2 | 3 | # Press ⌃R to execute it or replace it with your code. 4 | # Press Double ⇧ to search everywhere for classes, files, tool windows, 5 | # actions, and settings. 6 | 7 | 8 | def print_hi(_): 9 | pass 10 | 11 | 12 | # Press the green button in the gutter to run the script. 13 | if __name__ == "__main__": 14 | pass 15 | 16 | # See PyCharm help at https://www.jetbrains.com/help/pycharm/ 17 | -------------------------------------------------------------------------------- /tests/frontendIntegration/django3x/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Django's command-line utility for administrative tasks.""" 3 | 4 | import os 5 | import sys 6 | 7 | 8 | def main(): 9 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") 10 | try: 11 | from django.core.management import execute_from_command_line 12 | except ImportError as exc: 13 | raise ImportError( 14 | "Couldn't import Django. Are you sure it's installed and " 15 | "available on your PYTHONPATH environment variable? Did you " 16 | "forget to activate a virtual environment?" 17 | ) from exc 18 | execute_from_command_line(sys.argv) 19 | 20 | 21 | if __name__ == "__main__": 22 | main() 23 | -------------------------------------------------------------------------------- /tests/frontendIntegration/django3x/mysite/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/frontendIntegration/django3x/mysite/__init__.py -------------------------------------------------------------------------------- /tests/frontendIntegration/django3x/mysite/asgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | ASGI config for django3x project. 3 | 4 | It exposes the ASGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.asgi import get_asgi_application 13 | 14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") 15 | 16 | if True: 17 | # to help middleware function with uvicorn (to ensure supertokens init is called) 18 | from polls.views import config 19 | 20 | core_host = os.environ.get("SUPERTOKENS_CORE_HOST", "localhost") 21 | core_port = os.environ.get("SUPERTOKENS_CORE_PORT", "3567") 22 | 23 | config( 24 | core_url=f"http://{core_host}:{core_port}", 25 | enable_anti_csrf=True, 26 | enable_jwt=False, 27 | jwt_property_name=None, 28 | ) 29 | 30 | application = get_asgi_application() 31 | -------------------------------------------------------------------------------- /tests/frontendIntegration/django3x/mysite/server.py: -------------------------------------------------------------------------------- 1 | import uvicorn # type: ignore 2 | 3 | if __name__ == "__main__": 4 | uvicorn.run( # type: ignore 5 | "asgi:application", host="localhost", port=8080, log_level="info" 6 | ) 7 | -------------------------------------------------------------------------------- /tests/frontendIntegration/django3x/mysite/urls.py: -------------------------------------------------------------------------------- 1 | """mysite URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/2.2/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: path('', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.urls import include, path 14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 15 | """ 16 | 17 | from django.urls import include, path 18 | 19 | urlpatterns = [ 20 | path("", include("polls.urls")), 21 | ] 22 | -------------------------------------------------------------------------------- /tests/frontendIntegration/django3x/mysite/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for mysite project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") 15 | 16 | if True: 17 | # to help middleware function with uvicorn (to ensure supertokens init is called) 18 | from polls.views import config 19 | 20 | core_host = os.environ.get("SUPERTOKENS_CORE_HOST", "localhost") 21 | core_port = os.environ.get("SUPERTOKENS_CORE_PORT", "3567") 22 | 23 | config( 24 | core_url=f"http://{core_host}:{core_port}", 25 | enable_anti_csrf=True, 26 | enable_jwt=False, 27 | jwt_property_name=None, 28 | ) 29 | 30 | application = get_wsgi_application() 31 | -------------------------------------------------------------------------------- /tests/frontendIntegration/django3x/polls/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/frontendIntegration/django3x/polls/__init__.py -------------------------------------------------------------------------------- /tests/frontendIntegration/django3x/polls/admin.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/frontendIntegration/django3x/polls/admin.py -------------------------------------------------------------------------------- /tests/frontendIntegration/django3x/polls/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class PollsConfig(AppConfig): 5 | name = "polls" 6 | 7 | def ready(self): 8 | pass 9 | -------------------------------------------------------------------------------- /tests/frontendIntegration/django3x/polls/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/frontendIntegration/django3x/polls/migrations/__init__.py -------------------------------------------------------------------------------- /tests/frontendIntegration/django3x/polls/models.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/frontendIntegration/django3x/polls/models.py -------------------------------------------------------------------------------- /tests/frontendIntegration/django3x/polls/tests.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/frontendIntegration/django3x/polls/tests.py -------------------------------------------------------------------------------- /tests/frontendIntegration/django3x/requirements.txt: -------------------------------------------------------------------------------- 1 | Django==3.2.12 2 | django-cors-headers==3.11 3 | -------------------------------------------------------------------------------- /tests/frontendIntegration/drf_async/README.md: -------------------------------------------------------------------------------- 1 | # Django3 example 2 | 3 | This is an example to show how to use supertokens-python library with django3 framework. This example works with django version 3.2.12 and python version 3.8. 4 | 5 | ## Installation 6 | 7 | Before installing, use the script to create a virtual environment and to install all the required packages. 8 | ```bash 9 | source create_env.sh 10 | ``` 11 | 12 | ## Start web app 13 | 14 | ```bash 15 | python manage.py runsever 16 | ``` 17 | -------------------------------------------------------------------------------- /tests/frontendIntegration/drf_async/create_env.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | pip install virtualenv 4 | 5 | #Create a virtualenv 6 | virtualenv django3x_example 7 | # shellcheck disable=SC2164 8 | source django3x_example/bin/activate 9 | 10 | touch requirements.txt 11 | echo "django==3.2.12" >> requirements.txt 12 | pip install -r requirements.txt 13 | pip install ../../package/supertokens_python-2.0.0-py2.py3-none-any.whl 14 | -------------------------------------------------------------------------------- /tests/frontendIntegration/drf_async/db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/frontendIntegration/drf_async/db.sqlite3 -------------------------------------------------------------------------------- /tests/frontendIntegration/drf_async/main.py: -------------------------------------------------------------------------------- 1 | # This is a sample Python script. 2 | 3 | # Press ⌃R to execute it or replace it with your code. 4 | # Press Double ⇧ to search everywhere for classes, files, tool windows, 5 | # actions, and settings. 6 | 7 | 8 | def print_hi(_): 9 | pass 10 | 11 | 12 | # Press the green button in the gutter to run the script. 13 | if __name__ == "__main__": 14 | pass 15 | 16 | # See PyCharm help at https://www.jetbrains.com/help/pycharm/ 17 | -------------------------------------------------------------------------------- /tests/frontendIntegration/drf_async/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Django's command-line utility for administrative tasks.""" 3 | 4 | import os 5 | import sys 6 | 7 | 8 | def main(): 9 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") 10 | try: 11 | from django.core.management import execute_from_command_line 12 | except ImportError as exc: 13 | raise ImportError( 14 | "Couldn't import Django. Are you sure it's installed and " 15 | "available on your PYTHONPATH environment variable? Did you " 16 | "forget to activate a virtual environment?" 17 | ) from exc 18 | execute_from_command_line(sys.argv) 19 | 20 | 21 | if __name__ == "__main__": 22 | main() 23 | -------------------------------------------------------------------------------- /tests/frontendIntegration/drf_async/mysite/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/frontendIntegration/drf_async/mysite/__init__.py -------------------------------------------------------------------------------- /tests/frontendIntegration/drf_async/mysite/asgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | ASGI config for django3x project. 3 | 4 | It exposes the ASGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.asgi import get_asgi_application 13 | 14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") 15 | 16 | if True: 17 | # to help middleware function with uvicorn (to ensure supertokens init is called) 18 | from polls.views import config 19 | 20 | core_host = os.environ.get("SUPERTOKENS_CORE_HOST", "localhost") 21 | core_port = os.environ.get("SUPERTOKENS_CORE_PORT", "3567") 22 | 23 | config( 24 | core_url=f"http://{core_host}:{core_port}", 25 | enable_anti_csrf=True, 26 | enable_jwt=False, 27 | jwt_property_name=None, 28 | ) 29 | 30 | application = get_asgi_application() 31 | -------------------------------------------------------------------------------- /tests/frontendIntegration/drf_async/mysite/server.py: -------------------------------------------------------------------------------- 1 | import uvicorn # type: ignore 2 | 3 | if __name__ == "__main__": 4 | uvicorn.run( # type: ignore 5 | "asgi:application", host="localhost", port=8080, log_level="info" 6 | ) 7 | -------------------------------------------------------------------------------- /tests/frontendIntegration/drf_async/mysite/urls.py: -------------------------------------------------------------------------------- 1 | """mysite URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/2.2/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: path('', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.urls import include, path 14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 15 | """ 16 | 17 | from django.urls import include, path 18 | 19 | urlpatterns = [ 20 | path("", include("polls.urls")), 21 | ] 22 | -------------------------------------------------------------------------------- /tests/frontendIntegration/drf_async/mysite/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for mysite project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") 15 | 16 | if True: 17 | # to help middleware function with uvicorn (to ensure supertokens init is called) 18 | from polls.views import config 19 | 20 | core_host = os.environ.get("SUPERTOKENS_CORE_HOST", "localhost") 21 | core_port = os.environ.get("SUPERTOKENS_CORE_PORT", "3567") 22 | 23 | config( 24 | core_url=f"http://{core_host}:{core_port}", 25 | enable_anti_csrf=True, 26 | enable_jwt=False, 27 | jwt_property_name=None, 28 | ) 29 | 30 | application = get_wsgi_application() 31 | -------------------------------------------------------------------------------- /tests/frontendIntegration/drf_async/polls/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/frontendIntegration/drf_async/polls/__init__.py -------------------------------------------------------------------------------- /tests/frontendIntegration/drf_async/polls/admin.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/frontendIntegration/drf_async/polls/admin.py -------------------------------------------------------------------------------- /tests/frontendIntegration/drf_async/polls/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class PollsConfig(AppConfig): 5 | name = "polls" 6 | 7 | def ready(self): 8 | pass 9 | -------------------------------------------------------------------------------- /tests/frontendIntegration/drf_async/polls/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/frontendIntegration/drf_async/polls/migrations/__init__.py -------------------------------------------------------------------------------- /tests/frontendIntegration/drf_async/polls/models.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/frontendIntegration/drf_async/polls/models.py -------------------------------------------------------------------------------- /tests/frontendIntegration/drf_async/polls/tests.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/frontendIntegration/drf_async/polls/tests.py -------------------------------------------------------------------------------- /tests/frontendIntegration/drf_async/requirements.txt: -------------------------------------------------------------------------------- 1 | Django==3.2.12 2 | django-cors-headers==3.11 3 | -------------------------------------------------------------------------------- /tests/frontendIntegration/drf_sync/README.md: -------------------------------------------------------------------------------- 1 | # Django3 example 2 | 3 | This is an example to show how to use supertokens-python library with django3 framework. This example works with django version 3.2.12 and python version 3.8. 4 | 5 | ## Installation 6 | 7 | Before installing, use the script to create a virtual environment and to install all the required packages. 8 | ```bash 9 | source create_env.sh 10 | ``` 11 | 12 | ## Start web app 13 | 14 | ```bash 15 | python manage.py runsever 16 | ``` 17 | -------------------------------------------------------------------------------- /tests/frontendIntegration/drf_sync/create_env.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | pip install virtualenv 4 | 5 | #Create a virtualenv 6 | virtualenv django3x_example 7 | # shellcheck disable=SC2164 8 | source django3x_example/bin/activate 9 | 10 | touch requirements.txt 11 | echo "django==3.2.12" >> requirements.txt 12 | pip install -r requirements.txt 13 | pip install ../../package/supertokens_python-2.0.0-py2.py3-none-any.whl 14 | -------------------------------------------------------------------------------- /tests/frontendIntegration/drf_sync/db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/frontendIntegration/drf_sync/db.sqlite3 -------------------------------------------------------------------------------- /tests/frontendIntegration/drf_sync/main.py: -------------------------------------------------------------------------------- 1 | # This is a sample Python script. 2 | 3 | # Press ⌃R to execute it or replace it with your code. 4 | # Press Double ⇧ to search everywhere for classes, files, tool windows, 5 | # actions, and settings. 6 | 7 | 8 | def print_hi(_): 9 | pass 10 | 11 | 12 | # Press the green button in the gutter to run the script. 13 | if __name__ == "__main__": 14 | pass 15 | 16 | # See PyCharm help at https://www.jetbrains.com/help/pycharm/ 17 | -------------------------------------------------------------------------------- /tests/frontendIntegration/drf_sync/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Django's command-line utility for administrative tasks.""" 3 | 4 | import os 5 | import sys 6 | 7 | 8 | def main(): 9 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") 10 | try: 11 | from django.core.management import execute_from_command_line 12 | except ImportError as exc: 13 | raise ImportError( 14 | "Couldn't import Django. Are you sure it's installed and " 15 | "available on your PYTHONPATH environment variable? Did you " 16 | "forget to activate a virtual environment?" 17 | ) from exc 18 | execute_from_command_line(sys.argv) 19 | 20 | 21 | if __name__ == "__main__": 22 | main() 23 | -------------------------------------------------------------------------------- /tests/frontendIntegration/drf_sync/mysite/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/frontendIntegration/drf_sync/mysite/__init__.py -------------------------------------------------------------------------------- /tests/frontendIntegration/drf_sync/mysite/asgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | ASGI config for django3x project. 3 | 4 | It exposes the ASGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.asgi import get_asgi_application 13 | 14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") 15 | 16 | if True: 17 | # to help middleware function with uvicorn (to ensure supertokens init is called) 18 | from polls.views import config 19 | 20 | core_host = os.environ.get("SUPERTOKENS_CORE_HOST", "localhost") 21 | core_port = os.environ.get("SUPERTOKENS_CORE_PORT", "3567") 22 | 23 | config( 24 | core_url=f"http://{core_host}:{core_port}", 25 | enable_anti_csrf=True, 26 | enable_jwt=False, 27 | jwt_property_name=None, 28 | ) 29 | 30 | application = get_asgi_application() 31 | -------------------------------------------------------------------------------- /tests/frontendIntegration/drf_sync/mysite/server.py: -------------------------------------------------------------------------------- 1 | import uvicorn # type: ignore 2 | 3 | if __name__ == "__main__": 4 | uvicorn.run( # type: ignore 5 | "asgi:application", host="localhost", port=8080, log_level="info" 6 | ) 7 | -------------------------------------------------------------------------------- /tests/frontendIntegration/drf_sync/mysite/urls.py: -------------------------------------------------------------------------------- 1 | """mysite URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/2.2/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: path('', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.urls import include, path 14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 15 | """ 16 | 17 | from django.urls import include, path 18 | 19 | urlpatterns = [ 20 | path("", include("polls.urls")), 21 | ] 22 | -------------------------------------------------------------------------------- /tests/frontendIntegration/drf_sync/mysite/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for mysite project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") 15 | 16 | if True: 17 | # to help middleware function with uvicorn (to ensure supertokens init is called) 18 | from polls.views import config 19 | 20 | core_host = os.environ.get("SUPERTOKENS_CORE_HOST", "localhost") 21 | core_port = os.environ.get("SUPERTOKENS_CORE_PORT", "3567") 22 | 23 | config( 24 | core_url=f"http://{core_host}:{core_port}", 25 | enable_anti_csrf=True, 26 | enable_jwt=False, 27 | jwt_property_name=None, 28 | ) 29 | 30 | application = get_wsgi_application() 31 | -------------------------------------------------------------------------------- /tests/frontendIntegration/drf_sync/polls/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/frontendIntegration/drf_sync/polls/__init__.py -------------------------------------------------------------------------------- /tests/frontendIntegration/drf_sync/polls/admin.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/frontendIntegration/drf_sync/polls/admin.py -------------------------------------------------------------------------------- /tests/frontendIntegration/drf_sync/polls/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class PollsConfig(AppConfig): 5 | name = "polls" 6 | 7 | def ready(self): 8 | pass 9 | -------------------------------------------------------------------------------- /tests/frontendIntegration/drf_sync/polls/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/frontendIntegration/drf_sync/polls/migrations/__init__.py -------------------------------------------------------------------------------- /tests/frontendIntegration/drf_sync/polls/models.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/frontendIntegration/drf_sync/polls/models.py -------------------------------------------------------------------------------- /tests/frontendIntegration/drf_sync/polls/tests.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/frontendIntegration/drf_sync/polls/tests.py -------------------------------------------------------------------------------- /tests/frontendIntegration/drf_sync/requirements.txt: -------------------------------------------------------------------------------- 1 | Django==3.2.12 2 | django-cors-headers==3.11 3 | -------------------------------------------------------------------------------- /tests/frontendIntegration/fastapi-server/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/frontendIntegration/fastapi-server/__init__.py -------------------------------------------------------------------------------- /tests/frontendIntegration/flask-server/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/frontendIntegration/flask-server/__init__.py -------------------------------------------------------------------------------- /tests/input_validation/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/input_validation/__init__.py -------------------------------------------------------------------------------- /tests/jwt/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/jwt/__init__.py -------------------------------------------------------------------------------- /tests/multitenancy/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/multitenancy/__init__.py -------------------------------------------------------------------------------- /tests/passwordless/__init__.py: -------------------------------------------------------------------------------- 1 | import nest_asyncio # type: ignore 2 | 3 | nest_asyncio.apply() # type: ignore 4 | -------------------------------------------------------------------------------- /tests/playground/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/playground/__init__.py -------------------------------------------------------------------------------- /tests/playground/app.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | 15 | from supertokens_python import InputAppInfo, SupertokensConfig, init 16 | from supertokens_python.recipe import emailpassword 17 | 18 | # from supertokens_python.recipe.emailpassword import InputFormField 19 | # from supertokens_python.recipe.emailverification import InputOverrideConfig as EVInputOverrideConfig 20 | # from supertokens_python.recipe.session.utils import OverrideConfig 21 | 22 | init( 23 | app_info=InputAppInfo(app_name="", website_domain="", api_domain=""), 24 | supertokens_config=SupertokensConfig(connection_uri="", api_key=""), 25 | framework="fastapi", 26 | recipe_list=[emailpassword.init()], 27 | ) 28 | -------------------------------------------------------------------------------- /tests/sessions/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/sessions/__init__.py -------------------------------------------------------------------------------- /tests/sessions/claims/__init__.py: -------------------------------------------------------------------------------- 1 | import nest_asyncio # type: ignore 2 | 3 | nest_asyncio.apply() # type: ignore 4 | -------------------------------------------------------------------------------- /tests/sessions/claims/conftest.py: -------------------------------------------------------------------------------- 1 | from typing import Tuple 2 | 3 | from pytest import fixture 4 | from pytest_mock.plugin import MockerFixture 5 | from supertokens_python.utils import get_timestamp_ms 6 | 7 | 8 | @fixture() 9 | def primitive_claim_time_patch(mocker: MockerFixture): 10 | timestamp = get_timestamp_ms() 11 | patched_get_timestamp_ms = mocker.patch( 12 | "supertokens_python.recipe.session.claim_base_classes.primitive_claim.get_timestamp_ms" 13 | ) 14 | patched_get_timestamp_ms.return_value = timestamp 15 | 16 | return patched_get_timestamp_ms, timestamp 17 | 18 | 19 | @fixture() 20 | def timestamp(primitive_claim_time_patch: Tuple[MockerFixture, int]): 21 | return primitive_claim_time_patch[1] 22 | 23 | 24 | @fixture() 25 | def patch_get_timestamp_ms(primitive_claim_time_patch: Tuple[MockerFixture, int]): 26 | return primitive_claim_time_patch[0] 27 | -------------------------------------------------------------------------------- /tests/supertokens_python/__init__.py: -------------------------------------------------------------------------------- 1 | import nest_asyncio # type: ignore 2 | 3 | nest_asyncio.apply() # type: ignore 4 | -------------------------------------------------------------------------------- /tests/telemetry/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/telemetry/__init__.py -------------------------------------------------------------------------------- /tests/test-server/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/test-server/__init__.py -------------------------------------------------------------------------------- /tests/test-server/usermetadata.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, jsonify, request 2 | from supertokens_python.recipe.usermetadata.syncio import ( 3 | clear_user_metadata, 4 | get_user_metadata, 5 | update_user_metadata, 6 | ) 7 | 8 | 9 | def add_usermetadata_routes(app: Flask): 10 | @app.route("/test/usermetadata/getusermetadata", methods=["POST"]) # type: ignore 11 | def get_user_metadata_api(): # type: ignore 12 | assert request.json is not None 13 | user_id = request.json["userId"] 14 | response = get_user_metadata( 15 | user_id=user_id, user_context=request.json.get("userContext") 16 | ) 17 | return jsonify({"metadata": response.metadata}) 18 | 19 | @app.route("/test/usermetadata/updateusermetadata", methods=["POST"]) # type: ignore 20 | def update_user_metadata_api(): # type: ignore 21 | assert request.json is not None 22 | user_id = request.json["userId"] 23 | metadata_update = request.json["metadataUpdate"] 24 | 25 | response = update_user_metadata( 26 | user_id=user_id, 27 | metadata_update=metadata_update, 28 | user_context=request.json.get("userContext"), 29 | ) 30 | return jsonify({"metadata": response.metadata}) 31 | 32 | @app.route("/test/usermetadata/clearusermetadata", methods=["POST"]) # type: ignore 33 | def clear_user_metadata_api(): # type: ignore 34 | assert request.json is not None 35 | user_id = request.json["userId"] 36 | clear_user_metadata( 37 | user_id=user_id, user_context=request.json.get("userContext") 38 | ) 39 | return jsonify({"status": "OK"}) 40 | -------------------------------------------------------------------------------- /tests/testclient.py: -------------------------------------------------------------------------------- 1 | from fastapi.testclient import TestClient 2 | 3 | 4 | # The `fastapi.testclient.TestClient` uses a cookie jar to store cookies between requests. 5 | # Our test cases aren't written with this behavior in mind, and for consistency with other SDKs, 6 | # we need a `TestClient` that doesn't retain cookies. The class below inherits from `TestClient` 7 | # and clears the cookie jar before every request. 8 | class TestClientWithNoCookieJar(TestClient): 9 | def request(self, *args, **kwargs): # type: ignore 10 | self.cookies.clear() 11 | return super().request(*args, **kwargs) # type: ignore 12 | -------------------------------------------------------------------------------- /tests/thirdparty/__init__.py: -------------------------------------------------------------------------------- 1 | import nest_asyncio # type: ignore 2 | 3 | nest_asyncio.apply() # type: ignore 4 | -------------------------------------------------------------------------------- /tests/useridmapping/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertokens/supertokens-python/1d431dc1d9e558c29ffb952ccb768e4775c8296a/tests/useridmapping/__init__.py -------------------------------------------------------------------------------- /tests/useridmapping/utils.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. 2 | # 3 | # This software is licensed under the Apache License, Version 2.0 (the 4 | # "License") as published by the Apache Software Foundation. 5 | # 6 | # You may not use this file except in compliance with the License. You may 7 | # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | 15 | from supertokens_python import InputAppInfo, SupertokensConfig 16 | from supertokens_python.recipe import emailpassword, session, usermetadata 17 | 18 | from tests.utils import get_new_core_app_url 19 | 20 | 21 | def get_st_config(): 22 | return { 23 | "supertokens_config": SupertokensConfig(get_new_core_app_url()), 24 | "app_info": InputAppInfo( 25 | app_name="SuperTokens Demo", 26 | api_domain="https://api.supertokens.io", 27 | website_domain="supertokens.io", 28 | ), 29 | "framework": "fastapi", 30 | "recipe_list": [ 31 | emailpassword.init(), 32 | usermetadata.init(), 33 | session.init(get_token_transfer_method=lambda _, __, ___: "cookie"), 34 | ], 35 | } 36 | -------------------------------------------------------------------------------- /tests/userroles/__init__.py: -------------------------------------------------------------------------------- 1 | import nest_asyncio # type: ignore 2 | 3 | nest_asyncio.apply() # type: ignore 4 | --------------------------------------------------------------------------------