An open-source account and identity management system built for Cloudflare.
简体中文 · Deployment · Application integration · Architecture · Scaling
Start with deployment, then connect a Hono/Workers Web app or React SPA. Production needs an active Cloudflare zone, Workers Paid, R2, transactional Email Service and Turnstile. These services' usage and the connected applications' resources determine operating cost. Review operations and recovery, capacity boundaries and security reporting before rollout. Organizations, SAML and native/device clients are outside this release; see the feature boundary below.
Loginflare is a fully functional account and identity management platform for independent deployments, from small teams to large public-facing services. It combines a user account center, a developer center, an administrator console, and standard OAuth/OIDC sign-in for independent Web and SPA applications, with email or username sign-in, email verification, password recovery, and session management. The system runs as one Cloudflare Worker with D1, R2, Email Service, Turnstile, and Workers Static Assets.
Deploy an independent instance of Loginflare through Cloudflare. The management console requires administrator access. The Web/SPA examples exercise the complete integration flows. Business-specific applications can build on this project in separate branches with their own branding and rules.
The default language is en-US. Users can select zh-CN. Page URLs use lowercase language segments: /en-us/ and /zh-cn/.
| Your task | Shortest path |
|---|---|
| Run your own account service | Follow deployment, receive the setup email and create the first administrator. |
| Add sign-in to a website or frontend | Follow Connect your first application: choose Web or SPA in the Developer center, configure callbacks and run its example. Account sign-in needs no permission model setup. |
| Manage your own account | After signing in, open Account center: Profile for your name, username and avatar; Emails for login addresses; Security for passwords, passkeys and an authenticator; Sessions and Authorized applications to revoke access. See Account behavior. |
- Register, verify email, resend verification, sign in with an email address or username, and sign out.
- Configure Google, GitHub, Microsoft, Discord, X, Telegram, OIDC and OAuth 2.0 connections; support passwordless registration, explicit linking and third-party reauthentication. See Third-party sign-in.
- Recover a forgotten password and change a known password.
- Enable authenticator-based MFA (TOTP), save or reset one-use recovery codes, and verify email/username, provider, passkey and OAuth sign-ins.
- Add, name and manage passkeys after reauthentication, and use them to sign in; see Passkeys.
- Update a display name and username, upload/crop/remove a profile photo, and manage active sessions.
- Sign in to up to five accounts in one browser, switch accounts independently in each tab, and sign out of one account or all browser accounts.
- Manage primary and secondary email addresses on a dedicated page, verify new addresses with codes, and choose the primary sign-in email.
- Find users by exact ID, username, or primary email, inspect their accounts, suspend or restore ordinary accounts, and revoke their sessions.
- Create and manage your own server Web and SPA clients in the developer center, with exact redirects, consent, and client-secret rotation; administrators oversee all applications.
- Configure an independent brand logo, brand name, theme source color and Material color scheme in the administrator console.
- OpenID Connect sign-in using authorization code + PKCE S256, discovery, UserInfo, RS256 ID Tokens, refresh tokens, and application-initiated central logout.
- Manage API resources, business permission scopes, roles and user assignments; issue resource-bound access tokens and protect Workers/Hono APIs. See Access control.
- Inspect administrator-only audit logs for authentication, authorization, security and management events, with bounded retention.
- Configure signed asynchronous account Webhooks, inspect deliveries and redeliver retained events; see Business event notifications.
- Create separate service applications and service roles (machine identities), obtain short-lived client-credentials tokens, and automate the versioned Management API. See Machine identities and management.
- English and Simplified Chinese pages, error messages, and transactional emails.
- Better Auth account/session primitives, atomic D1-backed rate limiting, scheduled expiry cleanup, and server-verified Turnstile challenges.
Ordinary users can request permanent deletion under Security → Delete account, after reauthentication and confirmation of every owned application's deletion. The account and its applications become unavailable immediately; durable background cleanup removes their data and all users' grants for those applications. See Account deletion for authentication, retention and API behavior.
This release does not offer organizations, multi-tenancy, SAML, browser-based assignment of Loginflare console administrator privileges, impersonation, or administrator-set passwords. Native/device clients, dynamic client registration, upstream API token hosting and coordinated logout across all applications are also outside its scope. Those endpoints are not exposed. User roles, service roles and console administrator privileges are separate. Administrator self-deletion, administrator/machine account deletion and application ownership transfer are not exposed.
Usernames are separate from display names. The registration form asks for a unique username of 3–30 ASCII letters, numbers, underscores, or dots; usernames are stored in lowercase and sign-in is case-insensitive. Existing accounts can continue using email and choose a username in their profile. Users can change their username; an existing username cannot be cleared. Email verification is required for both sign-in methods. Only the primary email works as an email sign-in identifier.
The Email addresses page manages one primary email and additional secondary emails. Every address is unique across all accounts, regardless of its role. Adding an address requires identity confirmation and verification of a code sent to that address. A verified secondary email can become primary after identity confirmation; the previous primary remains secondary. Confirmation uses the current password, or linked-provider reauthentication and any enabled MFA for passwordless accounts. The primary address must be replaced before it can be removed. Password recovery starts with the username or primary email and sends a code to a specified verified primary or secondary address belonging to that account. Secondary emails never identify an account for sign-in.
The avatar menu lists this browser's accounts with their photos, names and email addresses. Add account preserves existing sessions and uses the normal password/provider and MFA checks. Each tab remembers its own selection across reloads; switching returns to the selected account's profile. Expired or signed-out accounts remain available for reauthentication and can be removed from the list. Signed-out hints expire after 30 days; at most ten account entries are remembered, with the oldest signed-out entries removed first. The five-account limit applies to active sign-ins. Signing out affects this browser's session for that account, including its other tabs; other devices remain signed in. Switching Loginflare accounts does not switch an application's existing session. Applications starting a new authorization choose an account when multiple accounts are signed in.
Set up MFA on the account center's Security page after confirming your current password or reauthenticating a linked identity. Scan the QR code or enter the setup key, save the recovery codes, and confirm an authenticator code to activate MFA. Each recovery code works once; resetting codes invalidates the previous set. Enabling or disabling MFA revokes other sessions and previous application grants. Password recovery keeps MFA enabled. A recovery code can replace a lost authenticator, but password recovery cannot bypass MFA if both are lost.
Administrators manage deployment-wide branding at /en-us/admin/branding. The logo is an independent image and the brand name remains editable text. Logo and avatar selection share a preview, crop, zoom, rotation and confirmation workflow. Logo crops and exported images are fixed squares; SVG adjustments preserve vector geometry, and static PNG, JPG and WebP sources are encoded as WebP before upload. A source color and one of nine Material scheme variants generate 49 matching light/dark color roles, with Tonal Spot as the default. Saving updates site branding, browser metadata and transactional email branding without changing issuer, user IDs or OAuth client IDs. See branding architecture.
Profile photos use a dedicated R2 media bucket and Better Auth's existing user.image field. Public reads can optionally use an R2 image domain; authentication keys remain in a separate private bucket. Choose a static JPG, PNG or WebP image up to 20 MiB in the account center, then drag, zoom or rotate it inside the circular crop frame. Mouse, touch and keyboard controls share the same preview. The initial/minimum zoom fills the crop frame exactly; dragging stays within the image bounds. The browser creates a 256-pixel square from the original and encodes the visible composition as WebP before upload; the Worker accepts only WebP, checks its dimensions and size and strips metadata. Header/profile photos, user management and OIDC picture claims share that address. Photo changes invalidate the existing account/admin caches across tabs. See avatar storage and lifecycle and the deployment prerequisites.
The account center, developer center and administrator console use separate navigation. Profile, email, security, active sessions and authorized applications stay in the account center. Under Authorized applications, users review permissions and revoke an application's consent and OAuth credentials; using it again requires consent. Verified accounts create and configure their own applications in the developer center. The administrator console lists all applications and their developers, links to user management, and restricts or restores application access; its application details are read-only. Ordinary users cannot enter the administrator console.
The interface follows Material Design 3 and uses Material Web (@material/web 2.5.0) Web Components inside React 19. Shared MD3 design tokens define the color, typography, shape, and interaction styles across authentication, account, and administrator pages. Roboto and Noto Sans SC variable fonts are bundled through pinned Fontsource packages and served from the instance, including the 400/500/700 weights used by Material. Character-range WOFF2 subsets use font-display: optional, with the common Roboto Latin subset preloaded. Fonts that arrive too late keep the current page on its system fallback instead of changing already visible text. Components and fonts do not depend on an external CDN.
The theme uses Cloudflare orange (#F38020) for brand accents and primary button fills, paired with dark labels. Deeper orange is used for links and focus indicators to preserve contrast on light surfaces.
The logo combines an orange entrance and sign-in arrow with the Loginflare wordmark. The SVG logo uses vector paths for both the symbol and lettering, without embedded images or font dependencies. The interface uses the same logo with theme-aware lettering, and the favicon uses the symbol alone.
Light and dark themes follow the system by default. The theme menu can select Light, Dark, or System; this browser preference persists across reloads and synchronizes between tabs. It is separate from the account's language preference. The initial theme is applied before React loads, and Turnstile follows the active theme.
Desktop scrollbars use a thin, rounded thumb in the active theme's primary color with a transparent track. Touch devices keep their native scrollbar behavior.
Material Web is licensed under Apache-2.0 and is currently in upstream maintenance mode. Loginflare pins its version and includes its third-party license notices.
Requirements: Node.js 24 LTS and pnpm 11.25.0, as declared in packageManager. The project pins its Cloudflare tooling as development dependencies. Install from the committed lockfile and generate local secrets:
pnpm install --frozen-lockfile
pnpm setup:localsetup:local creates the ignored .dev.vars file with a random authentication secret and the official Turnstile development test secret. It leaves an existing file unchanged. .dev.vars.local.example documents local variables; its placeholder authentication secret is deliberately rejected. The root .dev.vars.example declares only the first remote-install credential. Initialize the local database and start the app:
pnpm db:migrate
pnpm db:check
pnpm devOpen http://localhost:5173 (the configured authentication origin). The root entry automatically selects a supported browser language for a fresh visitor. The development email binding simulates delivery locally: inspect its output for registration-verification links and email-management/recovery codes. Local development does not need to send real email or create Cloudflare resources. Never use the Turnstile test configuration for a production deployment.
pnpm dev adds 3,000 ms to each API GET request, in addition to its normal processing time, to make loading states visible while testing locally. Set LOGINFLARE_API_DELAY_MS in the ignored .env.local file or the shell environment to adjust it (0–30,000 ms; 0 disables it), then restart the development server. /api/health, page/assets, and non-GET requests are unaffected. This middleware exists only in the Vite development server; production/staging builds and the isolated automated browser/scale suites have no artificial delay.
Development and local database commands share .cloudflare/state, using wrangler.local.jsonc. Cloudflare Workers Builds manages remote releases separately.
Register the intended administrator as an ordinary account and verify its email. Promote that exact address with the local operator command:
pnpm admin:promote -- --email admin@example.com --localThe command requires an existing, verified account and is idempotent. Sign out and sign in again after promotion. Registration never automatically creates an administrator. The web console cannot assign roles or suspend another administrator.
User, application, and active-session list APIs use signed cursor pagination over indexed creation-time and ID keys. The account-session and administrator list interfaces offer Previous, Next, and Return to latest, report only the current page's size, and preserve the cursor and exact search in the URL when opening details. They do not scan for an exact total or use an offset. Administrator application search matches an exact client ID or complete name. The developer workspace displays the owner's applications as cards, with a single creation entry when empty; its bounded request covers the personal limit of 20 applications. The account and administrator list APIs are documented in the scaling guide.
D1 is the only implemented database backend. A million registered accounts describes stored data volume, not simultaneous users or an assured request rate. Validate the intended traffic, database size, email load, and Cloudflare plan limits before a public rollout. Hyperdrive or an external SQL backend would be a separate future integration, not an existing deployment option.
Database migrations prepare native dates as ISO UTC text, populate indexed callback-origin metadata, and verify the resulting schema against the committed migrations. Back up existing data before applying migrations and keep the issuer and authentication secret with the database. Expired records and obsolete avatar files are collected by a bounded scheduled handler sharing the Worker, D1 and avatar bucket.
pnpm check runs type checking, Worker integration tests, operator-command tests, the production build, the React SPA build and local dry-run bundles of the Web, webhook-receiver and audit-export Workers. Run pnpm test:e2e as well to exercise the browser flows. The CI workflow runs both on pull requests and pushes to main, plus isolated scale checks with 10 and 10,000 generated users and three-second workload windows. Tests use local D1, simulated email, and Turnstile test keys; browser reports are retained for seven days. The million-user benchmark remains a separate manual run.
pnpm typecheck
pnpm test
pnpm test:ops
pnpm test:e2e
pnpm test:scale
pnpm buildIntegration and browser tests use local data, simulated email, and Turnstile test responses. They must not be pointed at a remote account or database. The local scale harness exercises large generated datasets without creating paid Cloudflare resources or sending real email; see Scaling for its scope and result format. Install Chromium when setting up Playwright on a new machine:
Browser tests build the application and start a separate Miniflare instance at http://localhost:5174, with fresh state and captured mail under work/e2e/<run-id>. Test fixtures emulate Turnstile, reject external browser/API requests, and disable automatic API redirects; the Worker only permits its own local JWKS request. They do not reuse the development database or server. On Windows, the test configuration uses an installed Chrome by default; set PLAYWRIGHT_CHANNEL to select another installed channel, or use bundled Chromium on other platforms. Dependency and browser installation still require their usual downloads.
pnpm exec playwright install chromium- Email verification is required before sign-in.
- Changing a password requires the current password and revokes other sessions.
- Resetting a password revokes all sessions and requires a fresh sign-in.
- Suspending an account revokes existing sessions and blocks new sign-ins. Restoring it does not restore old sessions.
- Session checks use D1 rather than a cookie-cached user snapshot.
- Only the server can set role, email verification, and suspension fields.
- Protected responses are not cached. Logs must not contain passwords, session tokens, or full verification/reset links.
Passwords contain 8–128 characters. Registration-verification tokens expire after one hour, and sessions last seven days with Better Auth's standard renewal behavior; cookie session caching is disabled. Email-management and recovery codes expire after ten minutes and allow at most five attempts. Verified recovery hands off a ten-minute token to Better Auth's native password reset. Each account can manage up to ten email addresses; unverified secondary reservations can be reclaimed after one day when that address is added again.
Sign in with a verified account, switch to Developer center → My applications, and create a server Web or SPA client. Each developer may own up to 20 applications and can manage only their own. Administration → Applications provides a global read-only view and access restrictions, including for existing instance applications. It does not provide creation, configuration editing or secret rotation. A developer cannot remove an administrator's restriction.
Register the external application's exact sign-in and sign-out callbacks in Loginflare, then configure that application's OIDC settings with the generated client ID, the issuer and, for server clients, the one-time secret. Server applications use client_secret_basic; browser SPAs use none and never receive a secret. Both require authorization code + PKCE S256 and first-use consent. Discover the provider at ${AUTH_URL}/api/auth/.well-known/openid-configuration.
See the integration guide for callbacks, token lifetimes, security-event revocation, and the standard openid-client / oidc-client-ts examples. The examples use local HTTPS subdomains and locally generated certificates; no system trust-store changes or remote resources are required.
For a business API, an administrator registers its audience, permission scopes, allowed applications and business roles. Applications request a resource access token through the same OAuth flow. The Workers/Hono example validates signatures and audience, checks live authorization and enforces endpoint permissions. Audit logs make security and access-management events available in the administrator console.
Trusted backend automation uses a separately configured machine application. The Management API exposes scoped user, login-application, business-access and audit operations under /api/management/v1, with a public OpenAPI contract. The scheduled Worker example polls audit logs with a read-only token and exports provisioning helpers without an unauthenticated operation trigger.
The webhook receiver verifies account notifications into a durable inbox. The separate audit exporter copies allowlisted audit records with persistent continuation and deduplication; source retention and bounded polling still limit completeness.
Ordinary central logout retains native offline_access refresh authorization. Applications own their local sessions; logging out of Loginflare does not sign every application out. Security actions such as password recovery and account suspension have separate credential-invalidation rules described in the integration guide.
On narrow screens, select Navigation to expand the current area's pages. Navigating to another page collapses it; desktop navigation keeps its existing groups. Administration searches match complete values exactly. Empty results show the current condition; Clear search returns to the list.
Account and administration data share an in-memory TanStack Query cache. Ordinary reads stay fresh for 60 seconds, identity/session views for 15 seconds; stale data remains visible during background updates. Writes invalidate related views and synchronize invalidation across tabs. Inactive private results, ordinary drafts and scroll positions are bounded. SPA navigation preserves useful state; F5 fetches identity and current-page data again. Passwords, verification codes and one-time client secrets are not cached or persisted. See the browser data contract for navigation, error and security boundaries.
The program, translation resources, stored preferences, and HTML lang use en-US / zh-CN; URL segments use en-us / zh-cn. An explicit page URL determines its language. Switching language keeps the current page and query parameters, including case-sensitive tokens.
The root entry chooses the saved browser preference, then the signed-in account's preference, then the first supported language in the browser's ordered language list, and finally en-US. English variants use en-US; Chinese variants use the available simplified Chinese translation, zh-CN. Both the root and localized entry paths preserve query strings and fragments and open the account center when signed in, or sign-in when anonymous. Initial translations and HTML lang use the same language decision before React renders. Unsupported or incorrectly cased language segments return 404. API routes remain under /api/*, without language prefixes. Transactional email follows the account's language preference and returns the user to the matching localized result page.
Use Deploy to Cloudflare or import your existing organization repository in Cloudflare. Enter the login hostname, first administrator’s email, and a short-lived Cloudflare token. Open the login domain after setup and create the administrator through the emailed link.
Cloudflare assigns the resource IDs. Subsequent pushes to main publish automatically and apply reviewed online migrations when needed. See the deployment guide.
Cloudflare Email Sending is currently Beta and arbitrary-recipient transactional delivery requires Workers Paid. A verified sending domain and real Turnstile configuration are required for production. Missing security configuration is an error; Loginflare does not silently skip email verification or bot protection.
Local installation, tests, and builds do not authorize remote resource creation, real email delivery, or deployment. Perform those operations deliberately against a verified target environment.
Copyright © 2026 Loginflare contributors.
Loginflare is available under either the MIT License or the Apache License 2.0, at your option. The SPDX expression is MIT OR Apache-2.0; package metadata uses (MIT OR Apache-2.0). See LICENSE.
Third-party dependencies and incorporated materials retain their own licenses and required notices. Adding them to this project does not relicense them under Loginflare's dual-license choice. Builds regenerate third-party notices from the locked runtime dependencies and include them at /assets/third-party-notices.txt.