Replies: 5 comments 6 replies
-
I believe we should. |
Beta Was this translation helpful? Give feedback.
-
|
I would like to add a security related topic: The user authenticates once with the first level and a cookie is issued. The attacker requests level 2 and tries 9 times to guess the 2nd factor. After the 9th failed attempt, the attacker sends an authentication request to Keycloak with level 1, so the user account will not be locked and the failed attempts are reset. Currently, every successful authentication, including re-authentication via cookie, leads to a reset of the failed attempts. This allows the attacker to guess the 2nd factor 9 more times. Also, no interaction with the user had to take place to reset the failed attempts. In my opinion, the setup with the cookie authentication for the first level is not very unusual and therefore the attack should be taken into account. The simplest solution for this would be to specify that re-authentication using cookies should not reset the failed attempts. Or what do you think about this scenario, @mposolda? |
Beta Was this translation helpful? Give feedback.
-
|
Additional improvement: Translate scope to requestedLoA Another improvement, which was discussed during the implementation of the step up authentication and brings great added value was the possibility to configure a mapping between a scope and a requested LoA. This means that the client does not have to send a claim with the required acr value in the authentication request, but only has to send a scope, which is a required parameter in OIDC. And the scope is translated to a certain LoA (essential). |
Beta Was this translation helpful? Give feedback.
-
Indeed an option for the |
Beta Was this translation helpful? Give feedback.
-
|
Keycloak support for Step-up authentication is great and useful. The problem is that step-up authentication - and any other action like otp, deny access - is not executed after Identity Provider User log in (Username Password Form or Identity Provider Redirector). Successfully Identity Provider login does not redirect back to Client authentication. You could see from related github issue that many people are facing the same problem. Keycloak needs to provide full functionality for using it both as Service Provider and Identity Brokering. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently Keycloak "main" has basic support for step-up authentication and also opened PR #10088 for bugfixing. This discussion about other possible enhancements and ideas for improve/update current functionality.
Keycloak.js support
It can be nice to consider adding some support for
claimsoracr_valuesto the keycloak.js adapter for make it easier for users to request authentication levels from their JS applications. Question is how to make API to be easy to use and extensible for the future. I see 3 options - from "easiest" to most flexible.Option 1
The easiest to support requesting with
acroption sent tologinmethod. This will consider them always asessentialclaim. Hence no built-in support for request non-essential (voluntary) claim:Example:
Adapter will translate this into
claimsparameter withessential=truesent in the OIDC request.Option 2
Possibility to specify if "essential" or not. The
acroption itself would be object instead of String:Option 3
Introduce something like
claimsBuilderto the keycloak.js. This can help in the future if we want to have more proper support forclaimsparameter by Keycloak server (Currentlyclaimsparameter is used only foracrclaim):Currently I used the option 3 for my prototype as it would allow easiest extensibility in case we want to have more proper support for
claimsparameter in the future. That is my preference.Support in other Keycloak OIDC adapters
It is not considered due the fact they will be likely deprecated soon.
SAML support
SAML specification has some possibility to request ACR levels by
<RequestedAuthnContext>parameter in the SAML authentication request. More described in the design https://github.com/keycloak/keycloak-community/blob/main/design/multi-factor-admin-and-step-up.md#saml .Should we add support for SAML or not? If yes, should we also target SAML adapters? Is it sufficient to at least specify "Default level" for SAML client (see below) and not consider
<RequestedAuthnContext>parameter support?Protocol mapper and client scope for "acr" claim
Currently adding
acrclaim to the token is hardcoded. It will be better to add dedicated protocol mapper implementation for addingacrclaim to the token. And add dedicated client scope for that. This will be default client scope in the realm added to all new clients. Similar to currentrolesandweb originsclient scopes.Backwards compatibility
Before adding step-up authentication, Keycloak had very limited support for
acrclaim (Hardcoded to return value0in case of SSO re-authentication and value1for normal (non SSO) authentication. In theory, some client adapters (not Keycloak, but some 3rd party) rely on the current ACR claim from tokens to be present. But not really sure about that.Options for backwards compatibility are:
Possibility is to stick to same behaviour we had before adding step-up authentication (Hardcoded
acrclaim to1in case of proper authentication and0in case of SSO authentication) . Protocol mapper will just override this (if used). This is my preferred option. We can improve once we have "Client Types" support.Don't handle it for existing realms and clients and only document it. Which means the
acrclaim won't be returned for them by default. This is probably OK, but someone can have issues in case that he relies onacrclaim for some reason and has millions of clients.Update existing realms and clients during migration. Will be expensive to do and hence I consider it as no go.
Support for OIDC well-known endpoint
OIDC Discovery specification introduced
acr_values_supportedfor OIDC server to return supported acr values. Keycloak currently does not return anything in it.We can remove configuration option
ACR to LoA mappingfrom client level and instead add it to the realm level or "client policy executor" level. Have this mapping at client policy or realm level is probably sufficient granularity. As I am not sure if various clients in the realm ever need different values foracrclaim.Compromise might be to introduce "Client Policy Executor" and add mapping
ACR to LoAto this executor. This will allow it to be reused by multiple clients.Then
acr_values_supportedin Well-Known endpoint can directly return values specified by this mapping.In case that
Acr to Loa mappingis not filled for the realm, the Well-Known endpoint can just browse through the authentication flow bind to the realmbrowserand figure if there are any LoA conditions and return the number values specified by these conditions. This can be cached to not require parsing authentication flows during each call of well-known endpoint.In case of client policy executor granularity (my preference), the well-known endpoint can browse through executors and return all values supported by any executor.
Option for client to specify default level
Currently there is no option at client level to request "default level" for the particular client.
For the client, we can likely remove
Acr to LoA mappingoption (see above) and add option forDefault ACR valuesto specify the values requested by target client. There is OIDC dynamic client registration parameterdefault_acr_valuesfor that, which we can easily add to support then. See OIDC Client registration specification for more details.Note that specification considers this as voluntary claim (not essential) and hence Keycloak server is not strictly forced to return any of the specified values. When client is created, we can validate if
default_acr_valuescorresponds to some ofacr_values_supportedfor the realm.What ACR to send from SSO authentication?
Currently Keycloak returns ID Token with ACR of level 0 in case that authentication was done with SSO. Example:
acr_values=1. User authenticates with username/password. ID token is returned to client withacr: 1acr_values=1. User is not required to actively authenticate in Keycloak due the SSO. ID token is returned to client withacr: 0I think that it is more appropriate to return the last ACR achieved even from SSO authentication.
Note that OIDC specification has this snippet:
But question is what is really "Authentication using a long-lived browser cookie"? My understanding is that this is the case when user did not had SSO and in spite of that, the "active authentication" of the user was done with long-lived cookie. However in case of SSO authentication, the user was before authenticated actively with the password and now the SSO is just "SSO re-authentication". So not sure if "SSO re-authentication" is what specification really meant?
I see possibilities like:
Option for users to skip authenticator
Consider that client sends something like
acr_values=2 1. It means client prefers level 2, but level 1 is also OK. In this case, after authentication with password (level 1), Keycloak can display authenticator for 2nd level as well (WebAuthn, OTP, Recovery code). But user will see link like "Skip this authenticator" . It can be similar link to "Try another way" . Keycloak will return to client with ID token withacr=1oracr=2based on if user skipped 2nd factor or not.Client can do it's own checks and allow some functionality based on the achieved level. For example photoalbum client can allow read photos for level 1, but adding/deleting photos only to level 2.
Client policy
As specified above, we can use client policy for more fine-grained granularity like:
Beta Was this translation helpful? Give feedback.
All reactions