Skip to content

Commit

Permalink
GUACAMOLE-1881: Decouple domain extraction from whether the extracted…
Browse files Browse the repository at this point in the history
… domain is used for a token.
  • Loading branch information
mike-jumper committed May 15, 2024
1 parent 50fdb34 commit cc525e5
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -316,15 +316,18 @@ public LDAPAuthenticatedUser authenticateUser(Credentials credentials)
}

/**
* Returns the current LDAP domain token from the provided user credentials.
* Returns the Windows / Active Directory domain included in the username
* of from 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.
Expand Down Expand Up @@ -399,7 +402,7 @@ private Map<String, String> getUserTokens(ConnectedLDAPConfiguration config, Cre

// 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);

Expand Down

0 comments on commit cc525e5

Please sign in to comment.