GUACAMOLE-1149: Merge correct regression in TOTP support if user accounts are not automatically created.

This commit is contained in:
Virtually Nick
2020-08-21 07:22:26 -04:00
committed by GitHub
2 changed files with 15 additions and 2 deletions

View File

@@ -133,7 +133,8 @@ public class JDBCAuthenticationProviderService implements AuthenticationProvider
// If auto account creation is enabled, add user to DB. // If auto account creation is enabled, add user to DB.
if (environment.autoCreateAbsentAccounts()) { if (environment.autoCreateAbsentAccounts()) {
userService.createObject(new PrivilegedModeledAuthenticatedUser(user.getCurrentUser()), user); ModeledUser createdUser = userService.createObject(new PrivilegedModeledAuthenticatedUser(user.getCurrentUser()), user);
user.setModel(createdUser.getModel());
} }
} }

View File

@@ -261,6 +261,18 @@ public class UserService extends ModeledDirectoryObjectService<ModeledUser, User
super.beforeUpdate(user, object, model); super.beforeUpdate(user, object, model);
// Refuse to update if the user is a skeleton and does not actually
// exist in the database (this will happen if the user is authenticated
// via a non-database authentication provider)
if (object.isSkeleton()) {
logger.info("Data cannot be stored for user \"{}\" as they do not "
+ "have an account within the database. If this is "
+ "unexpected, consider allowing automatic creation of "
+ "user accounts.", object.getIdentifier());
throw new GuacamoleUnsupportedException("User does not exist "
+ "within the database and cannot be updated.");
}
// Username must not be blank // Username must not be blank
if (model.getIdentifier() == null || model.getIdentifier().trim().isEmpty()) if (model.getIdentifier() == null || model.getIdentifier().trim().isEmpty())
throw new GuacamoleClientException("The username must not be blank."); throw new GuacamoleClientException("The username must not be blank.");