Disabling APIs
- NodeJS
- GoLang
- Python
- Other Frameworks
Important
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 ThirdParty from "supertokens-node/recipe/thirdparty";
import EmailPassword from "supertokens-node/recipe/emailpassword";
SuperTokens.init({
appInfo: {
apiDomain: "...",
appName: "...",
websiteDomain: "..."
},
supertokens: {
connectionURI: "...",
},
recipeList: [
EmailPassword.init({
override: {
apis: (originalImplementation) => {
return {
...originalImplementation,
signInPOST: undefined, // disable sign in with email & password
signUpPOST: undefined, // disable sign up with email & password
}
}
}
}),
ThirdParty.init({
override: {
apis: (originalImplementation) => {
return {
...originalImplementation,
signInUpPOST: 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/emailpassword"
"github.com/supertokens/supertokens-golang/recipe/emailpassword/epmodels"
"github.com/supertokens/supertokens-golang/recipe/thirdparty"
"github.com/supertokens/supertokens-golang/recipe/thirdparty/tpmodels"
"github.com/supertokens/supertokens-golang/supertokens"
)
func main() {
supertokens.Init(supertokens.TypeInput{
RecipeList: []supertokens.Recipe{
thirdparty.Init(&tpmodels.TypeInput{
Override: &tpmodels.OverrideStruct{
APIs: func(originalImplementation tpmodels.APIInterface) tpmodels.APIInterface {
// disable sign in & up with third party
originalImplementation.SignInUpPOST = nil
return originalImplementation
},
},
}),
emailpassword.Init(&epmodels.TypeInput{
Override: &epmodels.OverrideStruct{
APIs: func(originalImplementation epmodels.APIInterface) epmodels.APIInterface {
// disable sign in with email & password
originalImplementation.SignInPOST = nil
// disable sign up with email & password
originalImplementation.SignUpPOST = 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, InputAppInfo
from supertokens_python.recipe import thirdparty, emailpassword
from supertokens_python.recipe.thirdparty.interfaces import (
APIInterface as ThirdPartyAPIInterface,
)
from supertokens_python.recipe.emailpassword.interfaces import (
APIInterface as EmailPasswordAPIInterface,
)
def thirdparty_apis_override(original_impl: ThirdPartyAPIInterface):
# disable sign in & up with third party
original_impl.disable_sign_in_up_post = True
return original_impl
def emailpassword_apis_override(original_impl: EmailPasswordAPIInterface):
# disable sign up with email & password
original_impl.disable_sign_up_post = True
# disable sign in with email & password
original_impl.disable_sign_in_post = True
return original_impl
init(
app_info=InputAppInfo(api_domain="...", app_name="...", website_domain="..."),
framework="...",
recipe_list=[
thirdparty.init(
override=thirdparty.InputOverrideConfig(apis=thirdparty_apis_override),
),
emailpassword.init(
override=emailpassword.InputOverrideConfig(
apis=emailpassword_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