Login security

## New sign-in notice (always on)

Embed
Preview of the card
<a href="https://lucidace.com/help/login-security"><img src="https://lucidace.com/help/_api/public/orgs/af34862a-c837-4478-8335-0505efe40459/spaces/2f4b888b-c4e6-488b-81bd-6e838fb12d2e/pages/d2af6f18-06f0-4e32-8e77-3898ea832b99/social-card.svg?v=3e7ae33eec8b" alt="Login security" width="600" height="315"></a>

New sign-in notice (always on)

Every completed sign-in (password, Google/GitHub/GitLab, SAML/OIDC SSO, 2FA, passkey) is checked against the devices the account used before: a random lc_device cookie (HttpOnly, stored only as a SHA-256 hash in known_devices) and the coarse network (IPv4 /24, IPv6 /48, from the trusted proxy's X-Forwarded-For). A new device, or a known device on a new network, emails the account through the auth mail outbox (SMTP) with the browser, network and time. The first device on record is never announced.

Emailed confirmation of new-device password logins (per org)

Organization settings -> Login security -> Confirm password sign-ins from new devices by email (PUT /v1/orgs/{org}/login-security {"confirm_new_device_logins": true}, admins). When any org of a member has it on, a password login with no 2FA from a device the member never used gets no session: POST /v1/auth/login answers {"confirmation_required": true} and a single-use link (15 minutes) goes to the account's address. Opening /confirm-sign-in?token=... calls POST /v1/auth/login/confirm and starts the session in that browser, which becomes a known device.

Logins with 2FA, passkeys, SSO or a social provider are never held: those already prove more than a password.

Verify: make it runs services/lc-api/tests/login_security_it.rs; cargo test -p lc-api login_security; pnpm --filter web test login-confirm.

Updated