default required actions in model
This commit is contained in:
parent
3f62cd9271
commit
c52d16da6d
8 changed files with 33 additions and 14 deletions
|
@ -28,8 +28,8 @@ public class UserFederationManager implements UserProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserModel addUser(RealmModel realm, String id, String username, boolean addDefaultRoles) {
|
public UserModel addUser(RealmModel realm, String id, String username, boolean addDefaultRoles, boolean addDefaultRequiredActions) {
|
||||||
UserModel user = session.userStorage().addUser(realm, id, username.toLowerCase(), addDefaultRoles);
|
UserModel user = session.userStorage().addUser(realm, id, username.toLowerCase(), addDefaultRoles, addDefaultRequiredActions);
|
||||||
return registerWithFederation(realm, user);
|
return registerWithFederation(realm, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ import java.util.Set;
|
||||||
public interface UserProvider extends Provider {
|
public interface UserProvider extends Provider {
|
||||||
// Note: The reason there are so many query methods here is for layering a cache on top of an persistent KeycloakSession
|
// Note: The reason there are so many query methods here is for layering a cache on top of an persistent KeycloakSession
|
||||||
|
|
||||||
UserModel addUser(RealmModel realm, String id, String username, boolean addDefaultRoles);
|
UserModel addUser(RealmModel realm, String id, String username, boolean addDefaultRoles, boolean addDefaultRequiredActions);
|
||||||
UserModel addUser(RealmModel realm, String username);
|
UserModel addUser(RealmModel realm, String username);
|
||||||
boolean removeUser(RealmModel realm, UserModel user);
|
boolean removeUser(RealmModel realm, UserModel user);
|
||||||
|
|
||||||
|
|
|
@ -796,7 +796,7 @@ public class RepresentationToModel {
|
||||||
convertDeprecatedSocialProviders(userRep);
|
convertDeprecatedSocialProviders(userRep);
|
||||||
|
|
||||||
// Import users just to user storage. Don't federate
|
// Import users just to user storage. Don't federate
|
||||||
UserModel user = session.userStorage().addUser(newRealm, userRep.getId(), userRep.getUsername(), false);
|
UserModel user = session.userStorage().addUser(newRealm, userRep.getId(), userRep.getUsername(), false, false);
|
||||||
user.setEnabled(userRep.isEnabled());
|
user.setEnabled(userRep.isEnabled());
|
||||||
user.setEmail(userRep.getEmail());
|
user.setEmail(userRep.getEmail());
|
||||||
user.setEmailVerified(userRep.isEmailVerified());
|
user.setEmailVerified(userRep.isEmailVerified());
|
||||||
|
|
|
@ -266,7 +266,7 @@ public class FileUserProvider implements UserProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserAdapter addUser(RealmModel realm, String id, String username, boolean addDefaultRoles) {
|
public UserAdapter addUser(RealmModel realm, String id, String username, boolean addDefaultRoles, boolean addDefaultRequiredActions) {
|
||||||
if (inMemoryModel.hasUserWithUsername(realm.getId(), username.toLowerCase()))
|
if (inMemoryModel.hasUserWithUsername(realm.getId(), username.toLowerCase()))
|
||||||
throw new ModelDuplicateException("User with username " + username + " already exists in realm.");
|
throw new ModelDuplicateException("User with username " + username + " already exists in realm.");
|
||||||
|
|
||||||
|
@ -284,6 +284,13 @@ public class FileUserProvider implements UserProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (addDefaultRequiredActions) {
|
||||||
|
for (String r : realm.getDefaultRequiredActions()) {
|
||||||
|
userModel.addRequiredAction(r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return userModel;
|
return userModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,7 +365,7 @@ public class FileUserProvider implements UserProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserModel addUser(RealmModel realm, String username) {
|
public UserModel addUser(RealmModel realm, String username) {
|
||||||
return this.addUser(realm, KeycloakModelUtils.generateId(), username.toLowerCase(), true);
|
return this.addUser(realm, KeycloakModelUtils.generateId(), username.toLowerCase(), true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -250,8 +250,8 @@ public class DefaultCacheUserProvider implements CacheUserProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserModel addUser(RealmModel realm, String id, String username, boolean addDefaultRoles) {
|
public UserModel addUser(RealmModel realm, String id, String username, boolean addDefaultRoles, boolean addDefaultRequiredActions) {
|
||||||
return getDelegate().addUser(realm, id, username, addDefaultRoles);
|
return getDelegate().addUser(realm, id, username, addDefaultRoles, addDefaultRequiredActions);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -119,8 +119,8 @@ public class NoCacheUserProvider implements CacheUserProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserModel addUser(RealmModel realm, String id, String username, boolean addDefaultRoles) {
|
public UserModel addUser(RealmModel realm, String id, String username, boolean addDefaultRoles, boolean addDefaultRequiredActions) {
|
||||||
return getDelegate().addUser(realm, id, username, addDefaultRoles);
|
return getDelegate().addUser(realm, id, username, addDefaultRoles, addDefaultRequiredActions);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class JpaUserProvider implements UserProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserModel addUser(RealmModel realm, String id, String username, boolean addDefaultRoles) {
|
public UserModel addUser(RealmModel realm, String id, String username, boolean addDefaultRoles, boolean addDefaultRequiredActions) {
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
id = KeycloakModelUtils.generateId();
|
id = KeycloakModelUtils.generateId();
|
||||||
}
|
}
|
||||||
|
@ -68,13 +68,18 @@ public class JpaUserProvider implements UserProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (addDefaultRequiredActions) {
|
||||||
|
for (String r : realm.getDefaultRequiredActions()) {
|
||||||
|
userModel.addRequiredAction(r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return userModel;
|
return userModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserModel addUser(RealmModel realm, String username) {
|
public UserModel addUser(RealmModel realm, String username) {
|
||||||
return addUser(realm, KeycloakModelUtils.generateId(), username.toLowerCase(), true);
|
return addUser(realm, KeycloakModelUtils.generateId(), username.toLowerCase(), true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -242,7 +242,7 @@ public class MongoUserProvider implements UserProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserAdapter addUser(RealmModel realm, String id, String username, boolean addDefaultRoles) {
|
public UserAdapter addUser(RealmModel realm, String id, String username, boolean addDefaultRoles, boolean addDefaultRequiredActions) {
|
||||||
UserAdapter userModel = addUserEntity(realm, id, username.toLowerCase());
|
UserAdapter userModel = addUserEntity(realm, id, username.toLowerCase());
|
||||||
|
|
||||||
if (addDefaultRoles) {
|
if (addDefaultRoles) {
|
||||||
|
@ -257,6 +257,13 @@ public class MongoUserProvider implements UserProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (addDefaultRequiredActions) {
|
||||||
|
for (String r : realm.getDefaultRequiredActions()) {
|
||||||
|
userModel.addRequiredAction(r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return userModel;
|
return userModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,7 +334,7 @@ public class MongoUserProvider implements UserProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserModel addUser(RealmModel realm, String username) {
|
public UserModel addUser(RealmModel realm, String username) {
|
||||||
return this.addUser(realm, null, username, true);
|
return this.addUser(realm, null, username, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue