From b090bf6d52694b61c9ab52927557ed598c0e3d3f Mon Sep 17 00:00:00 2001 From: Linus Rath <139418639+rathlinus@users.noreply.github.com> Date: Thu, 12 Mar 2026 22:05:29 +0100 Subject: [PATCH] feat: add support for OAuth-only login mode and update configuration handling --- .env.example | 4 ++++ app/[locale]/login/page.tsx | 37 ++++++++++++++++++++++++++++++++++- app/api/auth/session/route.ts | 4 ++++ app/api/config/route.ts | 1 + hooks/use-config.ts | 4 ++++ 5 files changed, 49 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 34e78622..668a2442 100644 --- a/.env.example +++ b/.env.example @@ -27,6 +27,10 @@ JMAP_SERVER_URL=https://your-jmap-server.com # Set to "true" to use OAuth instead of basic JMAP authentication # OAUTH_ENABLED=true +# Set to "true" to only allow OAuth login (hides username/password form) +# Requires OAUTH_ENABLED=true +# OAUTH_ONLY=true + # OAuth client ID registered with your identity provider # OAUTH_CLIENT_ID=your-client-id diff --git a/app/[locale]/login/page.tsx b/app/[locale]/login/page.tsx index 7ffe5cf6..bd770b9e 100644 --- a/app/[locale]/login/page.tsx +++ b/app/[locale]/login/page.tsx @@ -29,7 +29,7 @@ export default function LoginPage() { const params = useParams(); const { login, isLoading, error, clearError, isAuthenticated } = useAuthStore(); const { theme, setTheme, initializeTheme } = useThemeStore(); - const { appName, jmapServerUrl: serverUrl, oauthEnabled, oauthClientId, oauthIssuerUrl, rememberMeEnabled, devMode, loginCompanyName, loginImprintUrl, loginPrivacyPolicyUrl, loginWebsiteUrl, isLoading: configLoading, error: configError } = useConfig(); + const { appName, jmapServerUrl: serverUrl, oauthEnabled, oauthOnly, oauthClientId, oauthIssuerUrl, rememberMeEnabled, devMode, loginCompanyName, loginImprintUrl, loginPrivacyPolicyUrl, loginWebsiteUrl, isLoading: configLoading, error: configError } = useConfig(); const [formData, setFormData] = useState({ username: "", @@ -491,6 +491,41 @@ export default function LoginPage() { Dev mode — logging in as dev@localhost
+ ) : oauthOnly ? ( + /* OAuth-only mode: show SSO button only */ ++ {t("error.oauth_discovery_failed")} +
+