This commit is contained in:
parent
fbfa39d06d
commit
96a93189c3
@ -94,11 +94,10 @@ public class LdapAuthenticationProvider implements AuthenticationProvider {
|
|||||||
try {
|
try {
|
||||||
userDetails = userDetailsService.loadUserByUsername(AuthConstants.LDAP_PREFIX + username);
|
userDetails = userDetailsService.loadUserByUsername(AuthConstants.LDAP_PREFIX + username);
|
||||||
} catch (UsernameNotFoundException exception) {
|
} catch (UsernameNotFoundException exception) {
|
||||||
String nacosPassword = PasswordEncoderUtil.encode(AuthConstants.LDAP_DEFAULT_PASSWORD);
|
userDetailsService.createUser(AuthConstants.LDAP_PREFIX + username, AuthConstants.LDAP_DEFAULT_ENCODED_PASSWORD);
|
||||||
userDetailsService.createUser(AuthConstants.LDAP_PREFIX + username, nacosPassword);
|
|
||||||
User user = new User();
|
User user = new User();
|
||||||
user.setUsername(AuthConstants.LDAP_PREFIX + username);
|
user.setUsername(AuthConstants.LDAP_PREFIX + username);
|
||||||
user.setPassword(nacosPassword);
|
user.setPassword(AuthConstants.LDAP_DEFAULT_ENCODED_PASSWORD);
|
||||||
userDetails = new NacosUserDetails(user);
|
userDetails = new NacosUserDetails(user);
|
||||||
}
|
}
|
||||||
return new UsernamePasswordAuthenticationToken(userDetails, password, userDetails.getAuthorities());
|
return new UsernamePasswordAuthenticationToken(userDetails, password, userDetails.getAuthorities());
|
||||||
|
@ -74,10 +74,7 @@ public class AuthConstants {
|
|||||||
*/
|
*/
|
||||||
public static final String NACOS_CORE_AUTH_IGNORE_PARTIAL_RESULT_EXCEPTION = "nacos.core.auth.ldap.ignore.partial.result.exception";
|
public static final String NACOS_CORE_AUTH_IGNORE_PARTIAL_RESULT_EXCEPTION = "nacos.core.auth.ldap.ignore.partial.result.exception";
|
||||||
|
|
||||||
@Deprecated
|
public static final String LDAP_DEFAULT_ENCODED_PASSWORD = PasswordEncoderUtil.encode(System.getProperty("ldap.default.password", "nacos"));
|
||||||
public static final String LDAP_DEFAULT_PASSWORD = "nacos";
|
|
||||||
|
|
||||||
public static final String LDAP_DEFAULT_ENCODED_PASSWORD = PasswordEncoderUtil.encode(LDAP_DEFAULT_PASSWORD);
|
|
||||||
|
|
||||||
public static final String LDAP_PREFIX = "LDAP_";
|
public static final String LDAP_PREFIX = "LDAP_";
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ class LdapAuthenticationProviderTest {
|
|||||||
|
|
||||||
private List<RoleInfo> roleInfos = new ArrayList<>();
|
private List<RoleInfo> roleInfos = new ArrayList<>();
|
||||||
|
|
||||||
private String defaultPassWord = "nacos";
|
private String defaultPassWord = System.getProperty("ldap.default.password", "nacos");
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void setUp() throws NoSuchMethodException {
|
void setUp() throws NoSuchMethodException {
|
||||||
|
Loading…
Reference in New Issue
Block a user