1.9 KiB
1.9 KiB
src/AGENTS.md — backend-only notes
Non-obvious rules that trip up new code. Terse on purpose.
Auth policy
- OIDC is the master identity provider. Whenever
AuthApplicationService::oidc_enabled()returns true, magic-link login MUST be off —is_magic_link_login_allowed()returns false regardless ofOXICLOUD_AUTH_METHODS. Rationale: OIDC may enforce 2FA / step-up; a mailbox-possession bypass would silently sidestep it. - Password / magic-link handlers gate via
is_password_login_allowed()/is_magic_link_login_allowed(), never raw config orpassword_login_disabled()alone. The composed helpers merge the legacy OIDC-only flag,OXICLOUD_AUTH_METHODS, SMTP wiring, and the OIDC-master rule in one place. - Magic-link redemption distinguishes login tokens (
resource_kind = None) from invitation tokens (File / Folder). The login gate only applies to the None case; invitations follow their own admin-mediated trust chain. OXICLOUD_REQUIRE_VERIFIED_EMAILgates login onemail_verified_at IS NOT NULL. Admin-created (admin_create_user) and setup-admin (setup_create_admin) users are stamped verified at creation — admin fiat counts. OIDC-JIT already stamps verified. Admins are EXEMPT from the gate at login regardless ofemail_verified_at— pre-existing admin accounts from before this flag shipped must never be locked out of their own instance. Regular users hit the gate; the frontend detects theEmailNotVerifiederror_type and offers a resend-magic-link CTA.- Startup gate in
main.rs: magic-link-only allowlist + no SMTP = panic. Never soften to warn.
New auth surfaces
- Any new endpoint that mints or consumes credentials/tokens must consult one of the
is_*_login_allowed()helpers, not the raw allowlist. - Any new "policy-disabled" refusal must emit an
audit-target line before returning — matchesauth.login_rejected,magic_link.redemption_rejectedconventions.