Skip to content

Commit

Permalink
added new option to explicitly enable AD mode for LDAP auth
Browse files Browse the repository at this point in the history
  • Loading branch information
albogdano committed Jan 28, 2021
1 parent 65f51bc commit ea796be
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,11 @@ public Authentication authenticate(Authentication authentication) {
Map<String, String> ldapSettings = auth.getLdapSettings();
if (!ldapSettings.isEmpty()) {
String adDomain = ldapSettings.get("security.ldap.active_directory_domain"); // set this to enable AD
String adEnabled = ldapSettings.get("security.ldap.ad_mode_enabled"); // set this to enable AD explicitly
String ldapServerURL = ldapSettings.get("security.ldap.server_url");
String searchFilter = ldapSettings.get("security.ldap.user_search_filter");
AbstractLdapAuthenticationProvider ldapProvider;
if (StringUtils.isBlank(adDomain)) {
ldapProvider = new LdapAuthenticationProvider(new LDAPAuthenticator(ldapSettings));
} else {
if ("true".equals(adEnabled) || !StringUtils.isBlank(adDomain)) {
// Fix for https://github.com/Erudika/scoold/issues/67
authentication = new LDAPAuthentication(StringUtils.substringBefore(auth.getName(), "@"), auth.getCredentials());
String rootDn = ldapSettings.get("security.ldap.base_dn");
Expand All @@ -63,6 +62,8 @@ public Authentication authenticate(Authentication authentication) {
if (!StringUtils.isBlank(searchFilter)) {
((ActiveDirectoryLdapAuthenticationProvider) ldapProvider).setSearchFilter(searchFilter);
}
} else {
ldapProvider = new LdapAuthenticationProvider(new LDAPAuthenticator(ldapSettings));
}
ldapProvider.setUserDetailsContextMapper(new InetOrgPersonContextMapper());
return ldapProvider.authenticate(authentication);
Expand Down

0 comments on commit ea796be

Please sign in to comment.