[keycloak-user] Java admin client API - encrypt password
Andreas Lau
andreas.lau at outlook.com
Mon Oct 8 04:34:43 EDT 2018
Hey community,
I have a program that has to create user accounts programmatically. So I use the keycloak java client api like this:
Keycloak kc = KeycloakBuilder.builder()
.serverUrl("http://your.keycloak.domain/auth")
.realm("master")
.username("admin")
.password("secret")
.clientId("admin-cli")
.resteasyClient(
new ResteasyClientBuilder()
.connectionPoolSize(10).build()
).build();
UserRepresentation userRepresentation = new UserRepresentation();
String email = "test at test.de";
userRepresentation.setEmail(email);
userRepresentation.setUsername(email);
kc.realm("myclientapp").users().create(userRepresentation);
I have a couple of questions regarding the code:
- Is this a proper way of using the java client api?
- Is there a way of encrypt the password (I am usually not a big fan of dealing with clear text passwords inside the code)?
- Currently I use the master admin user to connect to keycloak. How can I create, and restrict a user-mgmt-admin that is restricted to only handle user mgmt tasks?
I hope some of you can provide me some help, Thanks in advance.
Andreas
More information about the keycloak-user
mailing list