Configure the plugin
Just like any other plugin in Strapi, Headlockr requires some default configuration in order to get it up and running. Most of the required environment variables are autogenerated by Headlockr the first time you start up Headlockr. The only required environment variable is HEADLOCKR_LICENSE_KEY. Please follow the tutorial at the next chapter on how to set this up.
Headlockr Config file
Headlockr comes with the default configuration file below which can be overwritten. However, we must warn you that doing so might break the plugin. So please use with caution!
If you'd like to overwrite the default configuration, create a new file or edit your existing plugins config file located at ./config/plugins.js|ts
Please be aware that disabling headlockr and enabling it afterwards will wipe all your previous saved data from the database. This is something that we do not have control over since this is happening from within the Strapi Core.
- Strapi v4
- Strapi v5
headlockr: {
enabled: true, // ❗️ Caution: disabling the plugin will wipe previous data from the database.
config: {
// Optionally: Headlockr will cleanup any expired otp codes that were generated by it recurringly.
cron: {
enabled: true,
schedule: "0 0 * * *", // This will run the cron job every day at midnight. Any Cron expression can we used here.
},
licenseKey: env("HEADLOCKR_LICENSE_KEY"), // Your license key that you received from us
auth: {
encryptionIv: env("ENCRYPTION_IV_HEADLOCKR"), // A random 32 bytes long base64 string *
encryptionKey: env("ENCRYPTION_KEY_HEADLOCKR"), // A random 16 bytes long base64 string *
backupEncryptionIv: env("ENCRYPTION_IV_HEADLOCKR_BACKUP"), // *
backupEncryptionKey: env("ENCRYPTION_KEY_HEADLOCKR_BACKUP"), // *
secret: env("MFA_SECRET"), // This is the secret used to sign the shortlived tokens
phoneTokenSecret: env("PHONE_TOKEN_SECRET"), // This is the secret used to sign the phone tokens that are used during phone registration of a user
// Any option that jwt supports
options: {
expiresIn: "5m",
audience: "strapi-admin-panel",
issuer: "headlockr-admin-auth",
},
},
twilio: {
accountSid: env("TWILIO_ACCOUNT_SID"),
apiKeySid: env("TWILIO_API_KEY_SID"),
apiKeySecret: env("TWILIO_API_KEY_SECRET"),
from: env("TWILIO_PHONE_NUMBER"),
},
cookies: {
httpOnly: false,
secure: process.env.NODE_ENV === "production",
sameSite: "Lax",
//maxAge: 1000 * 60 * 5, // 5 minutes
path: "/",
},
},
},
headlockr: {
enabled: true, // ❗️ Caution: disabling the plugin will wipe previous data from the database.
config: {
// Configure a global rateLimiter which is used for auth/verify actions
rateLimit: {
enabled: true,
interval: { day: 1 },
max: 5,
},
// Optionally: Headlockr will cleanup any expired otp codes that were generated by it recurringly.
cron: {
enabled: true,
schedule: "0 0 * * *", // This will run the cron job every day at midnight. Any Cron expression can we used here.
},
licenseKey: env("HEADLOCKR_LICENSE_KEY"), // Your license key that you received from us
admin: {
auth: {
shouldPersist: env("HEADLOCKR_ADMIN_AUTH_PERSIST", true),
encryptionIv: env("ENCRYPTION_IV_HEADLOCKR"), // A random 32 bytes long base64 string *
encryptionKey: env("ENCRYPTION_KEY_HEADLOCKR"), // A random 16 bytes long base64 string *
backupEncryptionIv: env("ENCRYPTION_IV_HEADLOCKR_BACKUP"), // *
backupEncryptionKey: env("ENCRYPTION_KEY_HEADLOCKR_BACKUP"), // *
secret: env("MFA_SECRET"), // This is the secret used to sign the shortlived tokens
phoneTokenSecret: env("PHONE_TOKEN_SECRET"), // This is the secret used to sign the phone tokens that are used during phone registration of a user
// Any option that jwt supports
options: {
expiresIn: "5m",
audience: "strapi-admin-panel",
issuer: "headlockr-admin-auth",
},
phoneOptions: {
expiresIn: "5m",
audience: "headlockr-phone-verification-service",
issuer: "headlockr-phone-auth",
},
},
trustedDevice: {
enabled: env.bool("HEADLOCKR_TRUSTED_DEVICE_ENABLED", true),
ttlMs: env.int("HEADLOCKR_TRUSTED_DEVICE_TTL_MS", 24 * 60 * 60 * 1000),
cookieName: env("HEADLOCKR_TRUSTED_DEVICE_COOKIE_NAME", "headlockr_trusted_device"),
secret: env("HEADLOCKR_TRUSTED_DEVICE_SECRET", env("MFA_SECRET")),
requireRememberMe: env.bool("HEADLOCKR_TRUSTED_DEVICE_REQUIRE_REMEMBER_ME", true),
},
},
contentApi: {
auth: {
encryptionIv: env("ENCRYPTION_IV_HEADLOCKR_CONTENT_API"),
encryptionKey: env("ENCRYPTION_KEY_HEADLOCKR_CONTENT_API"),
backupEncryptionIv: env("ENCRYPTION_IV_HEADLOCKR_CONTENT_API_BACKUP"),
backupEncryptionKey: env(
"ENCRYPTION_KEY_HEADLOCKR_CONTENT_API_BACKUP",
),
secret: env("CONTENT_API_SECRET"), // This is the secret used to sign the content API tokens
phoneTokenSecret: env("CONTENT_API_PHONE_TOKEN_SECRET"), // This is the secret used to sign the phone tokens
options: {
expiresIn: "5m",
audience: "headlockr-content-api",
issuer: "headlockr-content-api-auth",
},
phoneOptions: {
expiresIn: "5m",
audience: "headlockr-content-api-phone-verification-service",
issuer: "headlockr-content-api-phone-auth",
},
},
},
passkeys: {
rpId: env("HEADLOCKR_PASSKEY_RP_ID", "localhost"),
rpName: env("HEADLOCKR_PASSKEY_RP_NAME", "Headlockr"),
origins: env(
"HEADLOCKR_PASSKEY_ORIGINS",
"http://localhost:1337,http://127.0.0.1:1337",
)
.split(",")
.map((origin) => origin.trim())
.filter(Boolean),
magicLogin: {
enabled: env.bool("HEADLOCKR_PASSKEY_MAGIC_LOGIN_ENABLED", false),
},
webLogin: {
enabled: env.bool("HEADLOCKR_PASSKEY_WEB_LOGIN_ENABLED", false),
},
},
twilio: {
accountSid: env("TWILIO_ACCOUNT_SID"),
apiKeySid: env("TWILIO_API_KEY_SID"),
apiKeySecret: env("TWILIO_API_KEY_SECRET"),
from: env("TWILIO_PHONE_NUMBER"),
},
cookies: {
httpOnly: false,
secure: process.env.NODE_ENV === "production",
sameSite: "Lax",
//maxAge: 1000 * 60 * 5, // 5 minutes
path: "/",
},
},
},
New in Headlockr 5
Passkeys
Headlockr now supports passkey-based authentication. The passkeys config controls:
rpId: the relying party ID used for passkey registration and loginrpName: the label shown to users during passkey flowsorigins: allowed origins for passkey verificationmagicLogin.enabled: enables the QR-based companion app login flowwebLogin.enabled: enables browser-native passkey login
If you enable passkeys, make sure HEADLOCKR_PASSKEY_RP_ID and HEADLOCKR_PASSKEY_ORIGINS match your real environment.
Trusted devices
Trusted devices let users reduce MFA prompts on known devices after a successful login.
enabled: turns the feature on or offttlMs: how long a device remains trustedcookieName: cookie name used for the trusted-device tokensecret: signing secret for trusted-device cookiesrequireRememberMe: only trusts a device when the user explicitly opts in
If HEADLOCKR_TRUSTED_DEVICE_SECRET is omitted, Headlockr falls back to MFA_SECRET.
Required environment variables
Headlockr still autogenerates most encryption and token secrets on first boot when they are missing. In practice, the values you usually need to provide yourself are:
HEADLOCKR_LICENSE_KEYHEADLOCKR_PASSKEY_RP_IDwhen using passkeysHEADLOCKR_PASSKEY_ORIGINSwhen using passkeys- Twilio credentials when using SMS