0
我目前在使用Spring.io教程。鏈接是Authenicating-ladp和securing-webldapAuthentication與inMemoryAuthentication有什麼區別?
我可以看到,他們是非常相似,除了配置。
LDAP
@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
auth
.ldapAuthentication()
.userDnPatterns("uid={0},ou=people")
.groupSearchBase("ou=groups")
.contextSource(contextSource())
.passwordCompare()
.passwordEncoder(new LdapShaPasswordEncoder())
.passwordAttribute("userPassword");
}
@Bean
public DefaultSpringSecurityContextSource contextSource() {
return new DefaultSpringSecurityContextSource(Arrays.asList("ldap://localhost:8389/"), "dc=springframework,dc=org");
}
保護的Web
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth
.inMemoryAuthentication()
.withUser("user").password("password").roles("USER");
}
有什麼親和使用各的利弊?哪一個最適合最佳實踐?
你擡頭看看「LDAP」和「內存中」是什麼意思? – OrangeDog