Riesgo adaptativo
Adaptive risk gives each sign-in a score from what Casdoor sees about it, and acts on the score: a sign-in that looks normal goes through, a risky one has to pass multi-factor authentication (MFA), and a very risky one is blocked.
- A user who signs in from the usual device and place is not asked for anything more.
- A user who signs in from a new country, from a script, or right after many wrong passwords has to pass MFA, even on a device that remembers the MFA.
- A user without MFA of their own verifies the email or the phone of the account instead.
- Every sign-in with a signal is recorded on the Sign-in risks page.
Adaptive risk needs the commercial edition or higher. See pricing.
Habilitarlo
-
In the Casdoor admin console, go to User Management > Organizations and edit the organization.
-
Open the Security tab and find the Adaptive risk section.
-
Turn on Enable adaptive risk, adjust the fields below, and click Save.
The policy applies to the next sign-in.

| Campo | Descripción |
|---|---|
| Enable adaptive risk | Scores the sign-ins of the users of the organization. |
| Ask for MFA at score | The score from which the user has to pass MFA. The default is 40. |
| Block at score | The score from which the sign-in is refused. The default is 100. |
| Impossible travel within hours | A sign-in from another country than the last one within this many hours counts as impossible travel. The default is 2. |
| Signal scores | The score of each signal. Leave a score empty to use the default shown in it. |
| Trusted networks | IP addresses and CIDR ranges, such as 10.0.0.0/8. A sign-in from them gets no score. |
| Blocked countries | Countries whose sign-ins get the Blocked country signal. Write them the way the IP database or the country header names them, such as KP. |
| Country header | The request header in which a CDN in front of Casdoor passes the visitor's country, such as CF-IPCountry. |
Señales
The score of a sign-in is the sum of the scores of its signals, at most 100.
| Signal | Default score | When it counts |
|---|---|---|
| New device | 20 | The browser has never signed in to this account before. |
| New location | 30 | The city, or the network when there is no IP database, has never been seen for this account. |
| New country | 40 | The country has never been seen for this account. |
| Impossible travel | 70 | The country differs from the one of the last sign-in, within Impossible travel within hours. |
| Many accounts failed from the IP | 40 | Three or more accounts had a wrong password from this IP address in the last 30 minutes. |
| Repeated wrong passwords | 30 | This account had three or more wrong passwords in the last 30 minutes. |
| Script or headless browser | 20 | The user agent is a command-line tool, an HTTP library or a headless browser, such as curl or python-requests. |
| Untrusted device | 40 | Device trust is set to Untrusted devices add risk and the sign-in doesn't come from a trusted device. |
| Blocked country | 100 | The country is one of Blocked countries. |
The new device, new location and new country signals count only after the user has signed in once, so the first sign-in of an account isn't treated as new. The failed passwords are counted in the memory of the Casdoor process.
The country comes from the IP database that the ipDbFile configuration item points to (the ipip.net format), otherwise from Country header. Without either, the country signals are not checked. Set Country header only when Casdoor is reachable through that CDN alone, because a client can send any header.
What the user sees
| Score | Result |
|---|---|
| Below Ask for MFA at score | The sign-in goes through as usual. The user's own MFA is asked as usual. |
| Desde Solicitar MFA en la puntuación | El usuario debe pasar la MFA. Un dispositivo que recuerda la MFA no se la omite. A un usuario que no ha configurado la MFA se le envía un código al correo electrónico o al teléfono de la cuenta, excepto al que usó para iniciar sesión. Se rechaza a los usuarios que no tienen ninguno de los dos. |
| Desde Bloquear en la puntuación | El inicio de sesión se rechaza con "Este inicio de sesión parece riesgoso y ha sido bloqueado, por favor contacte a su administrador". La API devuelve el código de error risk-denied. |
Un inicio de sesión que no tiene paso de MFA, como la concesión de autorización de dispositivos OAuth 2.0, solo se bloquea: no se solicita MFA. No se vuelve a puntuar a un usuario que ya tiene una sesión de Casdoor e inicia sesión en otra aplicación.
Revisar inicios de sesión riesgosos
En la consola de administración de Casdoor, vaya a Auditing > Sign-in risks. La página muestra los recuentos de los últimos siete días por decisión y por señal, y cada inicio de sesión con una señal: el usuario, la dirección IP, la ubicación, la puntuación, las señales, la decisión y si el usuario finalmente inició sesión.

Combinarlo con flujos
Un flujo en el disparador Before sign-in ve la puntuación, las señales y la decisión del riesgo adaptativo como risk.score, risk.signals y risk.decision. Úselo para reglas que una puntuación no puede expresar, por ejemplo, para enviar un correo electrónico al equipo de seguridad sobre cada inicio de sesión con Impossible travel, o para rechazar a los contratistas independientemente de su puntuación.