mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUACAMOLE-5: Provide most recent Credentials to updateUserContext(). Doing otherwise relies on the AuthenticatedUser being updated, which is not guaranteed to happen.
This commit is contained in:
@@ -95,7 +95,8 @@ public abstract class InjectedAuthenticationProvider implements AuthenticationPr
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserContext updateUserContext(UserContext context,
|
public UserContext updateUserContext(UserContext context,
|
||||||
AuthenticatedUser authenticatedUser) throws GuacamoleException {
|
AuthenticatedUser authenticatedUser, Credentials credentials)
|
||||||
|
throws GuacamoleException {
|
||||||
|
|
||||||
// No need to update the context
|
// No need to update the context
|
||||||
return context;
|
return context;
|
||||||
|
@@ -20,8 +20,6 @@
|
|||||||
package org.apache.guacamole.auth.ldap;
|
package org.apache.guacamole.auth.ldap;
|
||||||
|
|
||||||
|
|
||||||
import org.apache.guacamole.auth.ldap.AuthenticationProviderService;
|
|
||||||
import org.apache.guacamole.auth.ldap.LDAPAuthenticationProviderModule;
|
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
@@ -97,7 +95,8 @@ public class LDAPAuthenticationProvider implements AuthenticationProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserContext updateUserContext(UserContext context,
|
public UserContext updateUserContext(UserContext context,
|
||||||
AuthenticatedUser authenticatedUser) throws GuacamoleException {
|
AuthenticatedUser authenticatedUser,
|
||||||
|
Credentials credentials) throws GuacamoleException {
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -130,6 +130,11 @@ public interface AuthenticationProvider {
|
|||||||
* this AuthenticationProvider or any other installed
|
* this AuthenticationProvider or any other installed
|
||||||
* AuthenticationProvider.
|
* AuthenticationProvider.
|
||||||
*
|
*
|
||||||
|
* @param credentials
|
||||||
|
* The credentials which were most recently submitted. These are not
|
||||||
|
* guaranteed to be the same as the credentials associated with the
|
||||||
|
* AuthenticatedUser when they originally authenticated.
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
* An updated UserContext describing the permissions, connection,
|
* An updated UserContext describing the permissions, connection,
|
||||||
* connection groups, etc. accessible or associated with the given
|
* connection groups, etc. accessible or associated with the given
|
||||||
@@ -140,6 +145,7 @@ public interface AuthenticationProvider {
|
|||||||
* If an error occurs while updating the UserContext.
|
* If an error occurs while updating the UserContext.
|
||||||
*/
|
*/
|
||||||
UserContext updateUserContext(UserContext context,
|
UserContext updateUserContext(UserContext context,
|
||||||
AuthenticatedUser authenticatedUser) throws GuacamoleException;
|
AuthenticatedUser authenticatedUser,
|
||||||
|
Credentials credentials) throws GuacamoleException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -251,7 +251,8 @@ public abstract class SimpleAuthenticationProvider
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserContext updateUserContext(UserContext context,
|
public UserContext updateUserContext(UserContext context,
|
||||||
AuthenticatedUser authorizedUser) throws GuacamoleException {
|
AuthenticatedUser authorizedUser, Credentials credentials)
|
||||||
|
throws GuacamoleException {
|
||||||
|
|
||||||
// Simply return the given context, updating nothing
|
// Simply return the given context, updating nothing
|
||||||
return context;
|
return context;
|
||||||
|
@@ -183,7 +183,7 @@ public class AuthenticationProviderFacade implements AuthenticationProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserContext updateUserContext(UserContext context,
|
public UserContext updateUserContext(UserContext context,
|
||||||
AuthenticatedUser authenticatedUser)
|
AuthenticatedUser authenticatedUser, Credentials credentials)
|
||||||
throws GuacamoleException {
|
throws GuacamoleException {
|
||||||
|
|
||||||
// Ignore auth attempts if no auth provider could be loaded
|
// Ignore auth attempts if no auth provider could be loaded
|
||||||
@@ -193,7 +193,7 @@ public class AuthenticationProviderFacade implements AuthenticationProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Delegate to underlying auth provider
|
// Delegate to underlying auth provider
|
||||||
return authProvider.updateUserContext(context, authenticatedUser);
|
return authProvider.updateUserContext(context, authenticatedUser, credentials);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -288,6 +288,10 @@ public class AuthenticationService {
|
|||||||
* The AuthenticatedUser that has successfully authenticated or re-
|
* The AuthenticatedUser that has successfully authenticated or re-
|
||||||
* authenticated.
|
* authenticated.
|
||||||
*
|
*
|
||||||
|
* @param credentials
|
||||||
|
* The Credentials provided by the user in the most recent
|
||||||
|
* authentication attempt.
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
* A List of all UserContexts associated with the given
|
* A List of all UserContexts associated with the given
|
||||||
* AuthenticatedUser.
|
* AuthenticatedUser.
|
||||||
@@ -296,7 +300,8 @@ public class AuthenticationService {
|
|||||||
* If an error occurs while creating or updating any UserContext.
|
* If an error occurs while creating or updating any UserContext.
|
||||||
*/
|
*/
|
||||||
private List<UserContext> getUserContexts(GuacamoleSession existingSession,
|
private List<UserContext> getUserContexts(GuacamoleSession existingSession,
|
||||||
AuthenticatedUser authenticatedUser) throws GuacamoleException {
|
AuthenticatedUser authenticatedUser, Credentials credentials)
|
||||||
|
throws GuacamoleException {
|
||||||
|
|
||||||
List<UserContext> userContexts = new ArrayList<UserContext>(authProviders.size());
|
List<UserContext> userContexts = new ArrayList<UserContext>(authProviders.size());
|
||||||
|
|
||||||
@@ -309,7 +314,7 @@ public class AuthenticationService {
|
|||||||
|
|
||||||
// Update existing UserContext
|
// Update existing UserContext
|
||||||
AuthenticationProvider authProvider = oldUserContext.getAuthenticationProvider();
|
AuthenticationProvider authProvider = oldUserContext.getAuthenticationProvider();
|
||||||
UserContext userContext = authProvider.updateUserContext(oldUserContext, authenticatedUser);
|
UserContext userContext = authProvider.updateUserContext(oldUserContext, authenticatedUser, credentials);
|
||||||
|
|
||||||
// Add to available data, if successful
|
// Add to available data, if successful
|
||||||
if (userContext != null)
|
if (userContext != null)
|
||||||
@@ -379,7 +384,7 @@ public class AuthenticationService {
|
|||||||
|
|
||||||
// Get up-to-date AuthenticatedUser and associated UserContexts
|
// Get up-to-date AuthenticatedUser and associated UserContexts
|
||||||
AuthenticatedUser authenticatedUser = getAuthenticatedUser(existingSession, credentials);
|
AuthenticatedUser authenticatedUser = getAuthenticatedUser(existingSession, credentials);
|
||||||
List<UserContext> userContexts = getUserContexts(existingSession, authenticatedUser);
|
List<UserContext> userContexts = getUserContexts(existingSession, authenticatedUser, credentials);
|
||||||
|
|
||||||
// Update existing session, if it exists
|
// Update existing session, if it exists
|
||||||
String authToken;
|
String authToken;
|
||||||
|
Reference in New Issue
Block a user