Skip to content

feat(trust): add IP and device trust to skip repeated OTP#34

Merged
kidager merged 4 commits intomainfrom
feat/trust-ips-devices
Jan 26, 2026
Merged

feat(trust): add IP and device trust to skip repeated OTP#34
kidager merged 4 commits intomainfrom
feat/trust-ips-devices

Conversation

@kidager
Copy link
Member

@kidager kidager commented Jan 26, 2026

Summary

  • Allow users to skip OTP verification when logging in from a trusted IP or device
  • IP trust: automatically trusts the IP after successful OTP, configurable duration (minutes)
  • Device trust: user opts-in via checkbox, stores trust in cookie + database, configurable duration (days) or permanent

Changes

Core Features:

  • TrustStore SPI with JPA implementation for persisting trusted IPs/devices
  • HMAC-signed device trust cookies to prevent tampering
  • Automatic cleanup task for expired trust entries
  • Admin-configurable durations for both trust types

Internationalization:

  • "Don't ask for code" checkbox label with proper CLDR plural rules (33 locales)
  • Moved plural logic from FreeMarker to Java (PluralRules.java) for testability
  • Handles complex plural forms (Russian, Polish, Arabic, Slovenian, etc.)

Testing:

  • Unit tests for entities, config helpers, plural rules, trust duration
  • E2E tests for IP trust, device trust, cookie tampering, cross-realm isolation
  • Consolidated CI workflow (unit + e2e tests in parallel)

Configuration

ip-trust-enabled: true/false
ip-trust-duration:
device-trust-enabled: true/false
device-trust-duration: <days, 0=permanent>

Test plan

  • Unit tests pass (just test)
  • E2E tests pass (just test-e2e)
  • IP trust skips OTP on second login from same IP
  • Device trust checkbox appears when enabled
  • Tampered cookies are rejected
  • Plural forms display correctly in multiple locales

@kidager kidager self-assigned this Jan 26, 2026
kidager added a commit to for-keycloak/spinel-theme that referenced this pull request Jan 26, 2026
@kidager kidager marked this pull request as ready for review January 26, 2026 23:35
@kidager kidager merged commit 94b0f31 into main Jan 26, 2026
9 checks passed
@kidager kidager deleted the feat/trust-ips-devices branch January 26, 2026 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant