Skip to Content
Referência da APIAPI de Segurança

Security API

The Security API provides tools for protecting the tenant against unauthorized access and malicious activity. Administrators can maintain IP allow/block lists, review suspicious login events, configure CAPTCHA verification, and manage account lockouts.

Auris evaluates security rules during every authentication attempt in this order: IP rules (block/allow) -> CAPTCHA verification -> rate limiting -> credential validation -> suspicious login analysis -> adaptive MFA. Each layer operates independently and can be configured separately.

IP Rules

IP rules define allow and block lists using CIDR notation. Block rules always take precedence over allow rules. Rules can be scoped to the entire tenant or to a specific application.

List IP Rules

GET/api/ip-rulesRequires: manage:users

List all IP allow/block rules configured for the tenant. Supports filtering by rule type, scope, and active status. Rules are ordered by creation date descending.

Query parameters

ParameterTypeDescription
typestringFilter by rule type: ALLOW or BLOCK
scopestringFilter by scope: TENANT or APPLICATION
isActivebooleanFilter by active status
pageintegerPage number (default: 1)
limitintegerItems per page (default: 20, max: 100)

Success response

{ "ok": true, "data": { "data": [ { "id": "ipr_abc123", "cidr": "203.0.113.0/24", "type": "BLOCK", "scope": "TENANT", "applicationId": null, "label": "Known bad actor range", "note": "Blocked after brute-force campaign on 2025-02-10", "isTemporary": true, "expiresAt": "2025-03-10T00:00:00Z", "isActive": true, "createdAt": "2025-02-10T14:30:00Z", "updatedAt": "2025-02-10T14:30:00Z" }, { "id": "ipr_def456", "cidr": "10.0.0.0/8", "type": "ALLOW", "scope": "TENANT", "applicationId": null, "label": "Corporate VPN", "note": "Internal network range", "isTemporary": false, "expiresAt": null, "isActive": true, "createdAt": "2025-01-15T09:00:00Z", "updatedAt": "2025-01-15T09:00:00Z" }, { "id": "ipr_ghi789", "cidr": "198.51.100.50/32", "type": "BLOCK", "scope": "APPLICATION", "applicationId": "app_prod001", "label": "Suspicious IP", "note": null, "isTemporary": false, "expiresAt": null, "isActive": true, "createdAt": "2025-02-05T11:20:00Z", "updatedAt": "2025-02-05T11:20:00Z" } ], "pagination": { "page": 1, "limit": 20, "total": 3, "totalPages": 1 } } }

Create IP Rule

POST/api/ip-rulesRequires: manage:users

Create a new IP allow or block rule. CIDR notation is required — use /32 for a single IP address. Block rules always take precedence over allow rules during evaluation.

Request body

{ "cidr": "192.0.2.0/24", "type": "BLOCK", "scope": "TENANT", "label": "Datacenter range", "note": "Blocked due to automated scraping activity", "isTemporary": true, "expiresAt": "2025-04-01T00:00:00Z" }
FieldTypeRequiredDescription
cidrstringYesIP address or range in CIDR notation (e.g., 10.0.0.1/32, 192.168.0.0/16)
typestringYesALLOW or BLOCK
scopestringYesTENANT (applies to all apps) or APPLICATION (requires applicationId)
applicationIdstringNoRequired when scope is APPLICATION
labelstringNoHuman-readable label for the rule
notestringNoAdministrative note or reason
isTemporarybooleanNoWhether the rule expires automatically (default: false)
expiresAtstringNoISO 8601 expiry date. Required when isTemporary is true

Success response

{ "ok": true, "data": { "id": "ipr_jkl012", "cidr": "192.0.2.0/24", "type": "BLOCK", "scope": "TENANT", "applicationId": null, "label": "Datacenter range", "note": "Blocked due to automated scraping activity", "isTemporary": true, "expiresAt": "2025-04-01T00:00:00Z", "isActive": true, "createdAt": "2025-02-18T10:00:00Z", "updatedAt": "2025-02-18T10:00:00Z" } }

Error codes

CodeHTTPDescription
VALIDATION_ERROR400Invalid CIDR notation, missing required fields, or invalid scope/type combination
DUPLICATE_RULE409A rule with the same CIDR and scope already exists

Temporary rules are automatically cleaned up after their expiresAt timestamp. You do not need to manually delete them.

Update IP Rule

PATCH/api/ip-rules/[id]Requires: manage:users

Update an existing IP rule. All fields are optional — only provided fields are updated. Changing the CIDR or type of a rule takes effect immediately for subsequent login attempts.

Request body

{ "label": "Updated label", "note": "Extended block after continued activity", "isActive": false }

Success response

{ "ok": true, "data": { "id": "ipr_abc123", "cidr": "203.0.113.0/24", "type": "BLOCK", "scope": "TENANT", "applicationId": null, "label": "Updated label", "note": "Extended block after continued activity", "isTemporary": true, "expiresAt": "2025-03-10T00:00:00Z", "isActive": false, "createdAt": "2025-02-10T14:30:00Z", "updatedAt": "2025-02-18T10:30:00Z" } }

Error codes

CodeHTTPDescription
NOT_FOUND404IP rule does not exist
VALIDATION_ERROR400Invalid field value

Delete IP Rule

DELETE/api/ip-rules/[id]Requires: manage:users

Permanently delete an IP rule. The rule is removed immediately and will no longer be evaluated during authentication attempts.

Success response

{ "ok": true, "data": { "deleted": true, "id": "ipr_abc123" } }

Error codes

CodeHTTPDescription
NOT_FOUND404IP rule does not exist

Suspicious Login Events

Auris monitors login attempts for anomalous behavior using five detection methods: new device, new IP address, new country, impossible travel, and VPN/proxy usage. When suspicious activity is detected, an event is logged and the configured action is taken (log only, require MFA, or block).

List Suspicious Login Events

GET/api/suspicious-login/eventsRequires: manage:users

List suspicious login events across the tenant. Events are ordered by creation date descending. Use the reviewed filter to find events that need administrator attention.

Query parameters

ParameterTypeDescription
userIdstringFilter events for a specific user
severitystringFilter by severity: low, medium, high, critical
reasonstringFilter by detection reason: new_device, new_ip, new_country, impossible_travel, vpn_detected
reviewedbooleantrue for reviewed events, false for unreviewed
pageintegerPage number (default: 1)
limitintegerItems per page (default: 20, max: 100)

Success response

{ "ok": true, "data": { "data": [ { "id": "sle_abc123", "userId": "usr_xyz789", "userEmail": "[email protected]", "reason": "impossible_travel", "severity": "high", "actionTaken": "require_mfa", "details": { "previousLocation": { "country": "Italy", "city": "Rome", "lat": 41.9028, "lng": 12.4964 }, "currentLocation": { "country": "Brazil", "city": "Sao Paulo", "lat": -23.5505, "lng": -46.6333 }, "distanceKm": 9187, "timeDiffMinutes": 45, "requiredSpeedKmh": 12249 }, "ipAddress": "198.51.100.42", "reviewed": false, "reviewedAt": null, "reviewedBy": null, "createdAt": "2025-02-18T09:15:00Z" }, { "id": "sle_def456", "userId": "usr_abc123", "userEmail": "[email protected]", "reason": "vpn_detected", "severity": "medium", "actionTaken": "log", "details": { "ipAddress": "203.0.113.50", "isp": "NordVPN", "isVpn": true, "isProxy": false, "isDatacenter": true }, "ipAddress": "203.0.113.50", "reviewed": true, "reviewedAt": "2025-02-18T10:00:00Z", "reviewedBy": "usr_admin001", "createdAt": "2025-02-18T08:45:00Z" } ], "pagination": { "page": 1, "limit": 20, "total": 47, "totalPages": 3 } } }

Mark Event as Reviewed

PATCH/api/suspicious-login/events/[id]/reviewRequires: manage:users

Mark a suspicious login event as reviewed. This is an administrative acknowledgment and does not affect the user’s access. Use this to track which events have been investigated.

Success response

{ "ok": true, "data": { "id": "sle_abc123", "reviewed": true, "reviewedAt": "2025-02-18T11:00:00Z", "reviewedBy": "usr_admin001" } }

Error codes

CodeHTTPDescription
NOT_FOUND404Event does not exist
ALREADY_REVIEWED400Event has already been marked as reviewed

Get Detection Config

GET/api/suspicious-login/configRequires: manage:users

Retrieve the current suspicious login detection configuration for the tenant.

Success response

{ "ok": true, "data": { "detectNewDevice": true, "detectNewIp": true, "detectNewCountry": true, "detectImpossibleTravel": true, "detectVpn": false, "actionOnNewDevice": "log", "actionOnNewIp": "log", "actionOnNewCountry": "require_mfa", "actionOnImpossibleTravel": "require_mfa", "actionOnVpn": "log", "maxTravelSpeedKmh": 900, "geoIpProvider": "ip-api", "updatedAt": "2025-02-01T12:00:00Z" } }
FieldTypeDescription
detectNewDevicebooleanFlag logins from previously unseen device fingerprints
detectNewIpbooleanFlag logins from previously unseen IP addresses
detectNewCountrybooleanFlag logins from a new country
detectImpossibleTravelbooleanFlag when consecutive logins are geographically impossible given the time elapsed
detectVpnbooleanFlag logins from known VPN/proxy/datacenter IPs
actionOn*stringAction to take: log (record only), require_mfa (force 2FA), block (deny access)
maxTravelSpeedKmhintegerSpeed threshold for impossible travel detection (default: 900 km/h)

Update Detection Config

PATCH/api/suspicious-login/configRequires: manage:users

Update the suspicious login detection configuration. All fields are optional. Changes take effect immediately for subsequent login attempts.

Request body

{ "detectVpn": true, "actionOnVpn": "require_mfa", "actionOnImpossibleTravel": "block", "maxTravelSpeedKmh": 1000 }

Success response

{ "ok": true, "data": { "detectNewDevice": true, "detectNewIp": true, "detectNewCountry": true, "detectImpossibleTravel": true, "detectVpn": true, "actionOnNewDevice": "log", "actionOnNewIp": "log", "actionOnNewCountry": "require_mfa", "actionOnImpossibleTravel": "block", "actionOnVpn": "require_mfa", "maxTravelSpeedKmh": 1000, "geoIpProvider": "ip-api", "updatedAt": "2025-02-18T11:30:00Z" } }

Error codes

CodeHTTPDescription
VALIDATION_ERROR400Invalid action value or maxTravelSpeedKmh out of range (100-5000)

Setting actionOnImpossibleTravel or actionOnNewCountry to block can lock out legitimate users who travel frequently or use mobile networks. Consider using require_mfa instead, which adds a verification step without denying access entirely.

CAPTCHA

CAPTCHA verification adds a human challenge to authentication flows. Auris supports three providers: Cloudflare Turnstile, hCaptcha, and reCAPTCHA v3. CAPTCHA can be triggered on every attempt, only after suspicious activity, or after a configurable number of failed login attempts.

Get CAPTCHA Config

GET/api/captcha/configRequires: manage:users

Retrieve the current CAPTCHA configuration for the tenant.

Success response

{ "ok": true, "data": { "provider": "CLOUDFLARE_TURNSTILE", "trigger": "ON_SUSPICIOUS", "siteKey": "0x4AAAAAAA...", "scoreThreshold": 0.5, "enableOnLogin": true, "enableOnRegister": true, "enableOnReset": false, "updatedAt": "2025-02-15T10:00:00Z" } }

The secretKey is never returned in API responses. It can only be set via the update endpoint.

Update CAPTCHA Config

PATCH/api/captcha/configRequires: manage:users

Update the CAPTCHA configuration. All fields are optional. Set provider to null to disable CAPTCHA entirely. The siteKey and secretKey must be valid for the selected provider.

Request body

{ "provider": "CLOUDFLARE_TURNSTILE", "trigger": "AFTER_FAILURES", "siteKey": "0x4AAAAAAA_your_site_key", "secretKey": "0x4AAAAAAA_your_secret_key", "scoreThreshold": 0.5, "enableOnLogin": true, "enableOnRegister": true, "enableOnReset": true }
FieldTypeDescription
providerstringCLOUDFLARE_TURNSTILE, HCAPTCHA, RECAPTCHA_V3, or null to disable
triggerstringALWAYS (every attempt), ON_SUSPICIOUS (after suspicious activity detected), AFTER_FAILURES (after N failed logins)
siteKeystringPublic site key from the CAPTCHA provider
secretKeystringSecret key from the CAPTCHA provider (write-only, never returned)
scoreThresholdnumberScore threshold for reCAPTCHA v3 (0.0 - 1.0, default: 0.5). Ignored for other providers
enableOnLoginbooleanEnable CAPTCHA on the login page
enableOnRegisterbooleanEnable CAPTCHA on the registration page
enableOnResetbooleanEnable CAPTCHA on the password reset page

Success response

{ "ok": true, "data": { "provider": "CLOUDFLARE_TURNSTILE", "trigger": "AFTER_FAILURES", "siteKey": "0x4AAAAAAA_your_site_key", "scoreThreshold": 0.5, "enableOnLogin": true, "enableOnRegister": true, "enableOnReset": true, "updatedAt": "2025-02-18T12:00:00Z" } }

Error codes

CodeHTTPDescription
VALIDATION_ERROR400Invalid provider, missing siteKey/secretKey when provider is set, or scoreThreshold out of range

Account Lockouts

When a user exceeds the lockoutThreshold configured in security settings, their account is temporarily locked. Administrators can view locked accounts and manually unlock them.

List Locked Accounts

GET/api/admin/lockoutsRequires: manage:users

List all currently locked user accounts. Only accounts with active lockouts are returned. Lockouts that have expired naturally are not included.

Success response

{ "ok": true, "data": { "data": [ { "id": "lock_abc123", "userId": "usr_xyz789", "userEmail": "[email protected]", "userName": "Alice Smith", "failedAttempts": 5, "lockedAt": "2025-02-18T09:00:00Z", "expiresAt": "2025-02-18T09:15:00Z", "ipAddress": "203.0.113.50" }, { "id": "lock_def456", "userId": "usr_abc123", "userEmail": "[email protected]", "userName": "Bob Jones", "failedAttempts": 5, "lockedAt": "2025-02-18T08:50:00Z", "expiresAt": "2025-02-18T09:05:00Z", "ipAddress": "198.51.100.42" } ], "pagination": { "page": 1, "limit": 20, "total": 2, "totalPages": 1 } } }

Unlock Account

DELETE/api/admin/lockouts/[userId]Requires: manage:users

Immediately unlock a user account. The failed attempt counter is reset to zero. The user can attempt to log in again immediately after being unlocked.

Success response

{ "ok": true, "data": { "unlocked": true, "userId": "usr_xyz789" } }

Error codes

CodeHTTPDescription
NOT_FOUND404User is not currently locked out

Account lockouts expire automatically based on the lockoutDuration configured in security settings. Manual unlock is only needed when a legitimate user is locked out and cannot wait for the lockout to expire.

Security Evaluation Order

During every authentication attempt, Auris evaluates security layers in this order:

  1. IP Rules — If the client IP matches a BLOCK rule, the request is denied immediately with 403 IP_BLOCKED.
  2. CAPTCHA — If CAPTCHA is configured and the trigger condition is met, the client must provide a valid CAPTCHA token.
  3. Rate Limiting — Sliding window rate limits are checked (configurable per tier).
  4. Credential Validation — Username/password or other credential verification via Keycloak.
  5. Brute Force / Lockout — Failed attempt counter is incremented. If threshold is reached, account is locked.
  6. Suspicious Login Analysis — Post-authentication analysis of device, IP, geography, and travel patterns.
  7. Adaptive MFA — Risk scoring may trigger step-up authentication if the risk score exceeds thresholds.

Each layer is independent and can be disabled without affecting the others.

Permissions Reference

PermissionDescription
manage:usersManage IP rules, review suspicious login events, configure CAPTCHA, and unlock accounts

Security management operations are grouped under the manage:users permission. This ensures that only administrators with full user management access can modify security settings that affect authentication for all users in the tenant.