Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

feat: add DISABLE_EMAIL_OTP_SIGN_IN for password sign-in with SMTP

Tin3fbdfbcdc241
diff --git a/.env.sample b/.env.sample
index e243ff989..a3c6896b1 100644
--- a/.env.sample
+++ b/.env.sample
@@ -56,6 +56,9 @@ SMTP_USER=
SMTP_PASSWORD=
SMTP_FROM=
SMTP_REQUIRE_TLS=
+# When SMTP is configured, sign-in uses email verification codes by default.
+# Set to true to use email/password sign-in instead (invitations still use SMTP).
+#DISABLE_EMAIL_OTP_SIGN_IN=false
# Cloud-mode abuse mitigations (only enable on hosted multi-tenant instances).
# When KANEO_CLOUD=true: signup with disposable-email providers is blocked,
diff --git a/ENVIRONMENT_SETUP.md b/ENVIRONMENT_SETUP.md
index 40dd961e9..e934f4d0c 100644
--- a/ENVIRONMENT_SETUP.md
+++ b/ENVIRONMENT_SETUP.md
@@ -85,6 +85,8 @@ For sending emails (workspace invitations, magic links, etc.), configure these v
> **Note:** If you're using an SMTP server with a self-signed or invalid TLS certificate, set `SMTP_IGNORE_TLS=true` to bypass certificate validation.
+When SMTP is configured, sign-in uses email verification codes by default. Set `DISABLE_EMAIL_OTP_SIGN_IN=true` to use email/password sign-in instead (workspace invitation emails still use SMTP).
+
#### Cloud-mode abuse mitigations
Hosted multi-tenant instances should enable the cloud abuse gates. Self-hosted instances can leave these unset.
diff --git a/apps/api/src/auth.ts b/apps/api/src/auth.ts
index 218188e67..6764efd34 100644
--- a/apps/api/src/auth.ts
+++ b/apps/api/src/auth.ts
@@ -51,6 +51,8 @@ const githubSso = getGithubSsoOAuthCredentials();
const isRegistrationDisabled = process.env.DISABLE_REGISTRATION === "true";
const isPasswordRegistrationDisabled =
process.env.DISABLE_PASSWORD_REGISTRATION === "true";
+const isEmailOtpSignInDisabled =
+ process.env.DISABLE_EMAIL_OTP_SIGN_IN === "true";
const apiUrl = process.env.KANEO_API_URL || "http://localhost:1337";
const clientUrl = process.env.KANEO_CLIENT_URL || "http://localhost:5173";
@@ -231,18 +233,22 @@ export const auth = betterAuth({
}
},
}),
- emailOTP({
- async sendVerificationOTP({ email, otp, type }) {
- if (type === "sign-in") {
- const locale = await getUserLocale(email);
- const copy = getAuthEmailCopy(locale);
- await sendOtpEmail(email, copy.otpSubject, {
- otp,
- locale,
- });
- }
- },
- }),
+ ...(isEmailOtpSignInDisabled
+ ? []
+ : [
+ emailOTP({
+ async sendVerificationOTP({ email, otp, type }) {
+ if (type === "sign-in") {
+ const locale = await getUserLocale(email);
+ const copy = getAuthEmailCopy(locale);
+ await sendOtpEmail(email, copy.otpSubject, {
+ otp,
+ locale,
+ });
+ }
+ },
+ }),
+ ]),
organization({
// `ac` is created with a narrow `statement` shape (project/task/label/
// workspace + the default org statements), which makes its inferred
diff --git a/apps/api/src/schemas.ts b/apps/api/src/schemas.ts
index 0c3740694..81cc77b7d 100644
--- a/apps/api/src/schemas.ts
+++ b/apps/api/src/schemas.ts
@@ -248,6 +248,7 @@ export const commentSchema = v.object({
export const configSchema = v.object({
disableRegistration: v.nullable(v.boolean()),
disablePasswordRegistration: v.nullable(v.boolean()),
+ disableEmailOtpSignIn: v.nullable(v.boolean()),
isDemoMode: v.boolean(),
hasSmtp: v.boolean(),
hasGithubSignIn: v.nullable(v.boolean()),
diff --git a/apps/api/src/utils/get-settings.ts b/apps/api/src/utils/get-settings.ts
index 4a762cee1..6a0bf7cb6 100644
--- a/apps/api/src/utils/get-settings.ts
+++ b/apps/api/src/utils/get-settings.ts
@@ -8,6 +8,7 @@ function getSettings() {
disableRegistration: process.env.DISABLE_REGISTRATION === "true",
disablePasswordRegistration:
process.env.DISABLE_PASSWORD_REGISTRATION === "true",
+ disableEmailOtpSignIn: process.env.DISABLE_EMAIL_OTP_SIGN_IN === "true",
isDemoMode: process.env.DEMO_MODE === "true",
hasSmtp:
Boolean(process.env.SMTP_HOST) &&
diff --git a/apps/docs/core/installation/environment-variables.mdx b/apps/docs/core/installation/environment-variables.mdx
index 4e0d39993..e809ba951 100644
--- a/apps/docs/core/installation/environment-variables.mdx
+++ b/apps/docs/core/installation/environment-variables.mdx
@@ -83,6 +83,7 @@ Name | Description | Default |
| `DISABLE_GUEST_ACCESS` | Disable anonymous/guest sign-in. When set to `true`, the guest access button will not be shown on sign-in and sign-up pages. | `false` |
| `DISABLE_REGISTRATION` | Disable public user registration. When set to `true`, the sign-up option will not be shown on the sign-in page and new user creation is blocked (including via SSO). **Note:** Users with valid workspace invitations can still register even when this is enabled. | `false` |
| `DISABLE_PASSWORD_REGISTRATION` | Disable password-based account creation. When set to `true`, email/password sign-up is blocked, but social/OIDC registration remains available unless `DISABLE_REGISTRATION=true`. | `false` |
+| `DISABLE_EMAIL_OTP_SIGN_IN` | When SMTP is configured, sign-in uses email verification codes by default. Set to `true` to use email/password sign-in instead. Workspace invitation emails still use SMTP. | `false` |
### GitHub SSO
@@ -188,5 +189,5 @@ Name | Description |
- If you enable Google SSO, you need to set up the Google app which is used to authenticate users in the [Google Cloud Console](https://console.cloud.google.com/). See the [Google SSO guide](/core/social-providers/google).
- If you enable Discord SSO, you need to set up the Discord application which is used to authenticate users in the [Discord Developer Portal](https://discord.com/developers/applications). See the [Discord SSO guide](/core/social-providers/discord).
- If you enable Custom OAuth/OIDC, you need to configure your identity provider with the appropriate redirect URI. See the [Custom OAuth/OIDC guide](/core/social-providers/custom-oauth).
-- If you have enabled SMTP, your sign in will be done via email using a magic link.
+- If you have enabled SMTP, sign-in uses email verification codes by default. Set `DISABLE_EMAIL_OTP_SIGN_IN=true` to use email/password sign-in instead.
- If you need device authorization for clients beyond the defaults (`kaneo-cli`, `kaneo-mcp` when `DEVICE_AUTH_CLIENT_IDS` is unset), set `DEVICE_AUTH_CLIENT_IDS` to the full comma-separated list of trusted client IDs for your deployment.
diff --git a/apps/web/src/routes/auth/sign-in.tsx b/apps/web/src/routes/auth/sign-in.tsx
index 8906f352b..88148c7ff 100644
--- a/apps/web/src/routes/auth/sign-in.tsx
+++ b/apps/web/src/routes/auth/sign-in.tsx
@@ -358,7 +358,7 @@ function SignIn() {
</div>
</>
)}
- {config?.hasSmtp ? (
+ {config?.hasSmtp && !config?.disableEmailOtpSignIn ? (
<OtpSignInForm
invitationId={invitationId}
defaultEmail={defaultEmail}
diff --git a/charts/kaneo/README.md b/charts/kaneo/README.md
index 47280992e..15a295f69 100644
--- a/charts/kaneo/README.md
+++ b/charts/kaneo/README.md
@@ -141,6 +141,7 @@ When CPU autoscaling is enabled, set `kaneo.resources.requests.cpu`; Kubernetes
| `kaneo.env.existingSecret.key` | Key in the existing secret that contains `AUTH_SECRET` | `auth-secret` |
| `kaneo.env.disableRegistration` | Disable new user registration | `false` |
| `kaneo.env.disablePasswordRegistration` | Disable password-based account creation while keeping social/OIDC registration available | `false` |
+| `kaneo.env.disableEmailOtpSignIn` | Use email/password sign-in instead of verification codes when SMTP is configured | `false` |
| `kaneo.env.database.external.enabled` | Use external PostgreSQL database (set postgresql.enabled to false) | `false` |
| `kaneo.env.database.external.host` | External PostgreSQL host | `""` |
| `kaneo.env.database.external.port` | External PostgreSQL port | `5432` |
diff --git a/charts/kaneo/templates/deployment.yaml b/charts/kaneo/templates/deployment.yaml
index 975492cb8..049a3aa63 100644
--- a/charts/kaneo/templates/deployment.yaml
+++ b/charts/kaneo/templates/deployment.yaml
@@ -85,6 +85,8 @@ spec:
value: {{ .Values.kaneo.env.disableRegistration | quote }}
- name: DISABLE_PASSWORD_REGISTRATION
value: {{ .Values.kaneo.env.disablePasswordRegistration | quote }}
+ - name: DISABLE_EMAIL_OTP_SIGN_IN
+ value: {{ .Values.kaneo.env.disableEmailOtpSignIn | quote }}
{{- with .Values.kaneo.extraEnv }}
{{- toYaml . | nindent 12 }}
{{- end }}
diff --git a/charts/kaneo/values.yaml b/charts/kaneo/values.yaml
index 01890a81f..1914afd97 100644
--- a/charts/kaneo/values.yaml
+++ b/charts/kaneo/values.yaml
@@ -95,6 +95,7 @@ kaneo:
key: auth-secret
disableRegistration: false
disablePasswordRegistration: false
+ disableEmailOtpSignIn: false
# Database configuration
database:
# Use external PostgreSQL (set postgresql.enabled to false)
diff --git a/tests/api-integration/config.test.ts b/tests/api-integration/config.test.ts
index d40ee79b7..94f4fb076 100644
--- a/tests/api-integration/config.test.ts
+++ b/tests/api-integration/config.test.ts
@@ -13,6 +13,7 @@ describe("API integration: config", () => {
expect(payload).toMatchObject({
disableRegistration: false,
disablePasswordRegistration: false,
+ disableEmailOtpSignIn: false,
isDemoMode: false,
hasGuestAccess: true,
});
diff --git a/tests/api-integration/setup.ts b/tests/api-integration/setup.ts
index 55c94adf2..53623c28e 100644
--- a/tests/api-integration/setup.ts
+++ b/tests/api-integration/setup.ts
@@ -66,6 +66,7 @@ process.env.KANEO_CLIENT_URL = "http://localhost:5173";
process.env.DISABLE_GUEST_ACCESS = "false";
process.env.DISABLE_REGISTRATION = "false";
process.env.DISABLE_PASSWORD_REGISTRATION = "false";
+process.env.DISABLE_EMAIL_OTP_SIGN_IN = "false";
process.env.DEMO_MODE = "false";
process.env.SMTP_HOST = "";
process.env.SMTP_PORT = "";