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: custom OAuth auto login, allow disabling the Login Form

tiran13397b2b98aa955
diff --git a/apps/api/src/schemas.ts b/apps/api/src/schemas.ts
index 0c3740694..0445cdd89 100644
--- a/apps/api/src/schemas.ts
+++ b/apps/api/src/schemas.ts
@@ -255,5 +255,7 @@ export const configSchema = v.object({
hasDiscordSignIn: v.nullable(v.boolean()),
hasCustomOAuth: v.nullable(v.boolean()),
hasGuestAccess: v.nullable(v.boolean()),
+ disableLoginForm: v.nullable(v.boolean()),
+ customOAuthAutoLogin: v.nullable(v.boolean()),
customOAuthLogoutUrl: v.nullable(v.string()),
});
diff --git a/apps/api/src/utils/get-settings.ts b/apps/api/src/utils/get-settings.ts
index 4a762cee1..ffc7d31b2 100644
--- a/apps/api/src/utils/get-settings.ts
+++ b/apps/api/src/utils/get-settings.ts
@@ -26,6 +26,8 @@ function getSettings() {
Boolean(process.env.CUSTOM_OAUTH_CLIENT_ID) &&
Boolean(process.env.CUSTOM_OAUTH_CLIENT_SECRET),
hasGuestAccess: process.env.DISABLE_GUEST_ACCESS !== "true",
+ disableLoginForm: process.env.DISABLE_LOGIN_FORM === "true",
+ customOAuthAutoLogin: process.env.CUSTOM_OAUTH_AUTO_LOGIN === "true",
customOAuthLogoutUrl: process.env.CUSTOM_OAUTH_LOGOUT_URL || null,
};
}
diff --git a/apps/docs/core/installation/environment-variables.mdx b/apps/docs/core/installation/environment-variables.mdx
index 4e0d39993..c4eea4d4a 100644
--- a/apps/docs/core/installation/environment-variables.mdx
+++ b/apps/docs/core/installation/environment-variables.mdx
@@ -83,6 +83,8 @@ 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_LOGIN_FORM` | Hide the email/password login form on the sign-in page. When set to `true`, only SSO/OAuth buttons are shown. Useful when you want to enforce authentication exclusively through an external identity provider. | `false` |
+| `CUSTOM_OAUTH_AUTO_LOGIN` | Automatically redirect to the custom OAuth/OIDC provider instead of showing the sign-in page. When set to `true`, users are immediately redirected to your identity provider without seeing the login page. Requires a custom OAuth provider to be configured. | `false` |
### GitHub SSO
@@ -134,6 +136,7 @@ Name | Description |
| `CUSTOM_OAUTH_SCOPES` | (Optional) Comma-separated list of OAuth scopes. Default: `profile,email`.
| `CUSTOM_OAUTH_RESPONSE_TYPE` | (Optional) OAuth response type. Default: `code`.
| `CUSTOM_AUTH_PKCE` | (Optional) Enable/disable PKCE. Default: `true`.
+| `CUSTOM_OAUTH_LOGOUT_URL` | (Optional) Logout endpoint URL for your identity provider.
### Redis
diff --git a/apps/docs/core/social-providers/custom-oauth.mdx b/apps/docs/core/social-providers/custom-oauth.mdx
index bb3286996..fb4d64143 100644
--- a/apps/docs/core/social-providers/custom-oauth.mdx
+++ b/apps/docs/core/social-providers/custom-oauth.mdx
@@ -30,6 +30,7 @@ To configure a custom OAuth/OIDC provider, you need to set the following environ
| `CUSTOM_OAUTH_RESPONSE_TYPE` | OAuth response type | `code` |
| `CUSTOM_AUTH_PKCE` | Enable/disable PKCE (Proof Key for Code Exchange) | `true` |
| `CUSTOM_OAUTH_LOGOUT_URL` | Logout endpoint URL (optional) | `https://id.example.com/api/oidc/logout` |
+| `CUSTOM_OAUTH_AUTO_LOGIN` | Auto-redirect to the custom OAuth provider, bypassing the login page | `false` |
## Setup Steps
@@ -115,6 +116,16 @@ CUSTOM_OAUTH_SCOPES=openid,profile,email
Once configured, users will see a "Continue with OIDC" button on the sign-in page. The system will automatically remember the last used login method for each user.
+### Auto-Login (Skip the Login Page)
+
+If you want to bypass the login page entirely and automatically redirect users to your identity provider, set:
+
+```bash
+CUSTOM_OAUTH_AUTO_LOGIN=true
+```
+
+When enabled, users visiting the sign-in page will be immediately redirected to your custom OAuth provider without seeing the Kaneo login page. This is ideal for organizations that use a single identity provider for all authentication.
+
## Troubleshooting
### "Invalid code verifier" Error
diff --git a/apps/web/src/routes/auth/sign-in.tsx b/apps/web/src/routes/auth/sign-in.tsx
index fd52d8f78..4e0f197a3 100644
--- a/apps/web/src/routes/auth/sign-in.tsx
+++ b/apps/web/src/routes/auth/sign-in.tsx
@@ -4,7 +4,7 @@ import {
useSearch,
} from "@tanstack/react-router";
import { Github, KeyRound, UserCheck } from "lucide-react";
-import { useEffect, useState } from "react";
+import { useCallback, useEffect, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
import { z } from "zod/v4";
import PageTitle from "@/components/page-title";
@@ -68,19 +68,20 @@ function SignIn() {
);
}
}, [isInstanceStatusError, instanceStatusError, t]);
+ const autoLoginTriggered = useRef(false);
const invitationId = search.invitationId;
const defaultEmail = search.email;
- const getSafeRedirectPath = () => {
+ const getSafeRedirectPath = useCallback(() => {
const redirectPath = search.redirect;
if (redirectPath?.startsWith("/") && !redirectPath.includes("//")) {
return redirectPath;
}
return undefined;
- };
+ }, [search.redirect]);
- const getCallbackUrl = () => {
+ const getCallbackUrl = useCallback(() => {
const baseUrl = import.meta.env.VITE_CLIENT_URL;
const redirectPath = getSafeRedirectPath();
if (redirectPath) {
@@ -90,7 +91,7 @@ function SignIn() {
return `${baseUrl}/invitation/accept/${invitationId}`;
}
return `${baseUrl}/dashboard`;
- };
+ }, [invitationId, getSafeRedirectPath]);
const handleGuestAccess = async () => {
setIsGuestLoading(true);
@@ -110,7 +111,7 @@ function SignIn() {
}
};
- const handleCustomOAuth = async () => {
+ const handleCustomOAuth = useCallback(async () => {
setIsCustomOAuthLoading(true);
try {
const result = await authClient.signIn.oauth2({
@@ -128,7 +129,7 @@ function SignIn() {
} finally {
setIsCustomOAuthLoading(false);
}
- };
+ }, [getCallbackUrl, t]);
const handleSignInGoogle = async () => {
setIsGoogleLoading(true);
@@ -201,13 +202,25 @@ function SignIn() {
}
};
+ useEffect(() => {
+ if (
+ config?.customOAuthAutoLogin &&
+ config?.hasCustomOAuth &&
+ !autoLoginTriggered.current
+ ) {
+ autoLoginTriggered.current = true;
+ handleCustomOAuth();
+ }
+ }, [config, handleCustomOAuth]);
+
// Treat "no users yet" as still loading so the skeleton stays visible
// while the useEffect above redirects to /auth/sign-up. Otherwise the
// form briefly paints before the redirect fires.
if (
isConfigLoading ||
isInstanceStatusLoading ||
- instanceStatus?.hasUsers === false
+ instanceStatus?.hasUsers === false ||
+ (config?.customOAuthAutoLogin && config?.hasCustomOAuth)
) {
return (
<>
@@ -379,38 +392,44 @@ function SignIn() {
)}
</div>
- <div className="relative my-6">
- <div className="absolute inset-0 flex items-center">
- <div className="w-full border-t border-border" />
- </div>
- <div className="relative flex justify-center text-sm">
- <span className="px-2 bg-card text-muted-foreground">
- {t("auth:forms.or")}
- </span>
+ {!config?.disableLoginForm && (
+ <div className="relative my-6">
+ <div className="absolute inset-0 flex items-center">
+ <div className="w-full border-t border-border" />
+ </div>
+ <div className="relative flex justify-center text-sm">
+ <span className="px-2 bg-card text-muted-foreground">
+ {t("auth:forms.or")}
+ </span>
+ </div>
</div>
- </div>
+ )}
</>
)}
- {config?.hasSmtp ? (
- <OtpSignInForm
- invitationId={invitationId}
- defaultEmail={defaultEmail}
- redirect={getSafeRedirectPath()}
- onSuccess={handleSignInSuccess}
- />
- ) : (
- <SignInForm
- defaultEmail={defaultEmail}
- onSuccess={handleSignInSuccess}
- />
- )}
+ {!config?.disableLoginForm &&
+ (config?.hasSmtp ? (
+ <OtpSignInForm
+ invitationId={invitationId}
+ defaultEmail={defaultEmail}
+ redirect={getSafeRedirectPath()}
+ onSuccess={handleSignInSuccess}
+ />
+ ) : (
+ <SignInForm
+ defaultEmail={defaultEmail}
+ onSuccess={handleSignInSuccess}
+ />
+ ))}
{config?.disableRegistration ||
- config?.disablePasswordRegistration ? (
+ config?.disablePasswordRegistration ||
+ config?.disableLoginForm ? (
<div className="text-center pt-4">
<p className="text-sm text-muted-foreground">
{config?.disableRegistration
? t("auth:signIn.registrationDisabled")
- : t("auth:signIn.passwordRegistrationDisabled")}
+ : config?.disableLoginForm
+ ? ""
+ : t("auth:signIn.passwordRegistrationDisabled")}
</p>
</div>
) : (
diff --git a/tests/api-integration/config.test.ts b/tests/api-integration/config.test.ts
index d40ee79b7..bf9b53a27 100644
--- a/tests/api-integration/config.test.ts
+++ b/tests/api-integration/config.test.ts
@@ -13,6 +13,8 @@ describe("API integration: config", () => {
expect(payload).toMatchObject({
disableRegistration: false,
disablePasswordRegistration: false,
+ disableLoginForm: expect.any(Boolean),
+ customOAuthAutoLogin: expect.any(Boolean),
isDemoMode: false,
hasGuestAccess: true,
});