Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting required action on new keycloak user account

Tags:

keycloak

I am using a client to create a new keycloak user. Something like this:

keycloak.realm(realm)
        .users()
        .create(user);

The user variable is a UserRepresentation object, and I'm trying to add an Update Password required action:

user.setRequiredActions(singletonList("Update Password"))

User gets created ok, the problem is that I don't have the required action set

enter image description here

Not sure what I'm doing wrong, should I specify a different value in the required actions list?

Thanks

like image 345
Radu Avatar asked Jul 26 '17 13:07

Radu


People also ask

What is required action in Keycloak?

Required Actions are tasks that a user must finish before they are allowed to log in. A user must provide their credentials before required actions are executed. Once a required action is completed, the user will not have to perform the action again.

How do I create an initial admin user for a Keycloak?

You can only create an initial admin user on the Welcome Page if you connect using localhost . This is a security precaution. You can also create the initial admin user at the command line with the add-user-keycloak.sh script. For more details see Server Installation and Configuration and Server Administration.

How does a user log into a Keycloak?

To access the admin console, open http://localhost:8080/auth/admin/ in a browser. You will be redirected to the Keycloak login pages, where you can log in with the admin username and password you created in the previous section while installing Keycloak.


1 Answers

Figured out what was up.

Keycloak has an enum to represent various user actions:

public static enum RequiredAction {
    VERIFY_EMAIL, UPDATE_PROFILE, CONFIGURE_TOTP, UPDATE_PASSWORD, TERMS_AND_CONDITIONS
}

So the value should be "UPDATE_PASSWORD" not "Update password"

like image 119
Radu Avatar answered Oct 15 '22 09:10

Radu