Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple authentication methods for a user in Keycloak

Tags:

keycloak

I would like to let my users have a choice which authentication method to use. For example, they could be presented with a menu to pick an option (username/pass, username/pass+OTP, etc). Then, Keycloak should, based on their choice, assign specific scope to the token.

Is this possible to do with Keycloak (probably by somehow utilizing auth methods chaining) and how? I couldn’t find this in the documentation but it seems as a reasonable use-case to me.

like image 363
Mike Avatar asked Aug 23 '18 07:08

Mike


People also ask

Does Keycloak support MFA?

Keycloak with MFA or Multifactor AuthenticationKeycloak's implementation of MFA is based on TOTP (time-based OTP) and can be rolled out in a straight-forward manner or Google Authenticator can be used. In either case, the vulnerability of impersonation attacks like phishing remains.

How do you use an authentication Keycloak?

Configure Keycloak to authenticate your cbioportal instance. Log in to your Keycloak Identity Provider, e.g. http://localhost:8080/auth, as an admin user. ⚠️ when setting this up on something else than localhost (e.g. production), you will need to use/enable https on your Keycloak server.

What is user managed access in Keycloak?

1 Presentation – What is UMA ? UMA stands for User Management Access (UMA) It defines a means for a client, representing a requesting party, to use a permission ticket to request an OAuth 2.0 access token to gain access to a protected resource asynchronously from the time a resource owner authorizes access.


2 Answers

Here is my solution:

enter image description here

Circled authenticators are custom ones for which I provided a custom implementation. I used the fall-through mechanism, which means I that first authenticator implements a custom form: enter image description here

which lets the user choose authenticator and captures user's choice in a variable. Later, this variable is used in the following authenticators to decide whether to do the authentication or to pass on control to the next authenticator.

You can read more about Authentication SPI in the following page: https://www.keycloak.org/docs/latest/server_development/index.html#_auth_spi

And here you can see how to implement custom authenticator.

like image 188
Mike Avatar answered Oct 03 '22 07:10

Mike


Here is what i did and it works,

'My goal was give ability to client to choose authentication flow, choose between otp based email and sms.'

I created a new authentication flow, see screenshot :

enter image description here

select 'Alternative' on both flows.

On login form new link will appear 'try another way'

enter image description here

Now the client can choose between flows. see screenshot :

enter image description here

like image 42
Chawki Avatar answered Oct 03 '22 09:10

Chawki