From b2b1452e119f71b0afe141064dcea4036db727cd Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Wed, 15 May 2024 10:38:20 -0700 Subject: [PATCH] GUACAMOLE-1881: Decouple domain extraction from whether the extracted domain is used for a token. --- .../auth/ldap/AuthenticationProviderService.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/AuthenticationProviderService.java b/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/AuthenticationProviderService.java index 424e221f6..8673f1ff3 100644 --- a/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/AuthenticationProviderService.java +++ b/extensions/guacamole-auth-ldap/src/main/java/org/apache/guacamole/auth/ldap/AuthenticationProviderService.java @@ -316,15 +316,18 @@ public class AuthenticationProviderService { } /** - * Returns the current LDAP domain token from the provided user credentials. + * Returns the Windows / Active Directory domain included in the username + * of the provided user credentials. If the username does not contain a + * domain, null is returned. * * @param credentials * The credentials used for authentication. * * @return - * Domain name by splitting login username or null if no domain is detected. + * The domain name within the username of the provided credentials, or + * null if no domain is present. */ - private String getDomainToken(Credentials credentials) { + private String getUserDomain(Credentials credentials) { String username = credentials.getUsername(); //Regex is used to extract the domain from a username //that is in either of these formats: DOMAIN\\username or username@domain. @@ -399,7 +402,7 @@ public class AuthenticationProviderService { // Extract the domain (ie: Windows / Active Directory domain) from the // user's credentials - String domainName = getDomainToken(credentials); + String domainName = getUserDomain(credentials); if (domainName != null) tokens.put(LDAP_DOMAIN_TOKEN, domainName);