Disabling APIs
- NodeJS
- GoLang
- Python
To disable an API entirely, all you need to do is override the api implementation with undefined
.
For example, if you want to disable the sign-up / sign-in api from this recipe, all you do is this:
- >= v8.0.0
- < v8.0.0
import SuperTokens from "supertokens-node";import ThirdPartyEmailPassword from "supertokens-node/recipe/thirdpartyemailpassword";
SuperTokens.init({ appInfo: { apiDomain: "...", appName: "...", websiteDomain: "..." }, supertokens: { connectionURI: "...", }, recipeList: [ ThirdPartyEmailPassword.init({ override: { apis: (originalImplementation) => { return { ...originalImplementation, emailPasswordSignInPOST: undefined, // disable sign in with email & password emailPasswordSignUpPOST: undefined, // disable sign up with email & password thirdPartySignInUpPOST: undefined // disable sign in & up with third party } } } }) ]});
import SuperTokens from "supertokens-node";import ThirdPartyEmailPassword from "supertokens-node/recipe/thirdpartyemailpassword";
SuperTokens.init({ appInfo: { apiDomain: "...", appName: "...", websiteDomain: "..." }, supertokens: { connectionURI: "...", }, recipeList: [ ThirdPartyEmailPassword.init({ override: { apis: (originalImplementation) => { return { ...originalImplementation, signInUpPOST: undefined } } } }) ]});
To disable an API entirely, all you need to do is override the api implementation with nil
.
For example, if you want to disable the sign-up / sign-in api from this recipe, all you do is this:
import ( "github.com/supertokens/supertokens-golang/recipe/thirdpartyemailpassword" "github.com/supertokens/supertokens-golang/recipe/thirdpartyemailpassword/tpepmodels" "github.com/supertokens/supertokens-golang/supertokens")
func main() { supertokens.Init(supertokens.TypeInput{ RecipeList: []supertokens.Recipe{ thirdpartyemailpassword.Init(&tpepmodels.TypeInput{ Override: &tpepmodels.OverrideStruct{ APIs: func(originalImplementation tpepmodels.APIInterface) tpepmodels.APIInterface {
// disable sign in with email & password originalImplementation.EmailPasswordSignInPOST = nil
// disable sign up with email & password originalImplementation.EmailPasswordSignUpPOST = nil
// disable sign in & up with third party originalImplementation.ThirdPartySignInUpPOST = nil
return originalImplementation }, }, }), }, })}
To disable an API entirely, all you need to do is override the api disable bool value to True
.
For example, if you want to disable the sign-up / sign-in api from this recipe, all you do is this:
from supertokens_python import init, InputAppInfofrom supertokens_python.recipe import thirdpartyemailpasswordfrom supertokens_python.recipe.thirdpartyemailpassword.interfaces import APIInterface
def apis_override(original_impl: APIInterface): # disable sign in & up with third party original_impl.disable_thirdparty_sign_in_up_post = True
# disable sign up with email & password original_impl.disable_emailpassword_sign_up_post = True
# disable sign in with email & password original_impl.disable_emailpassword_sign_in_post = True return original_impl
init( app_info=InputAppInfo(api_domain="...", app_name="...", website_domain="..."), framework='...', recipe_list=[ thirdpartyemailpassword.init( override=thirdpartyemailpassword.InputOverrideConfig( apis=apis_override ), ) ])
important
You then need to define your own routes that will handle this API call. You can see the Frontend driver interface API spec here