quick formatting work
This commit is contained in:
parent
89d3f72333
commit
a910ebae44
|
@ -4,7 +4,6 @@ import java.security.Principal;
|
|||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -39,7 +38,6 @@ public class MyController {
|
|||
}
|
||||
|
||||
private String getUserName(Principal principal) {
|
||||
|
||||
if (principal == null) {
|
||||
return "anonymous";
|
||||
} else {
|
||||
|
@ -54,7 +52,6 @@ public class MyController {
|
|||
}
|
||||
|
||||
private Collection<String> getUserRoles(Principal principal) {
|
||||
|
||||
if (principal == null) {
|
||||
return Arrays.asList("none");
|
||||
} else {
|
||||
|
@ -71,4 +68,3 @@ public class MyController {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -16,36 +16,14 @@ import org.springframework.stereotype.Controller;
|
|||
public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(AuthenticationManagerBuilder auth)
|
||||
throws Exception {
|
||||
|
||||
auth.ldapAuthentication()
|
||||
.userSearchBase("ou=people")
|
||||
.userSearchFilter("(uid={0})")
|
||||
.groupSearchBase("ou=groups")
|
||||
.groupSearchFilter("member={0}")
|
||||
.contextSource()
|
||||
.root("dc=baeldung,dc=com")
|
||||
.ldif("classpath:users.ldif");
|
||||
|
||||
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
||||
auth.ldapAuthentication().userSearchBase("ou=people").userSearchFilter("(uid={0})").groupSearchBase("ou=groups").groupSearchFilter("member={0}").contextSource().root("dc=baeldung,dc=com").ldif("classpath:users.ldif");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
|
||||
http
|
||||
.authorizeRequests()
|
||||
.antMatchers("/", "/home").permitAll()
|
||||
.anyRequest().authenticated();
|
||||
http
|
||||
.formLogin()
|
||||
.loginPage("/login")
|
||||
.permitAll()
|
||||
.and()
|
||||
.logout()
|
||||
.logoutSuccessUrl("/");
|
||||
|
||||
|
||||
http.authorizeRequests().antMatchers("/", "/home").permitAll().anyRequest().authenticated();
|
||||
http.formLogin().loginPage("/login").permitAll().and().logout().logoutSuccessUrl("/");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue