Bonjour, j'ai entrain de développer une application avec spring boot et j'ai besoin de faire l'authentification a partir d'un serveur ldap

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
 
 
@Configuration 
//@Order(SecurityProperties.BASIC_AUTH_ORDER) 
public class SecurityConfig extends WebSecurityConfigurerAdapter{
 
 
    public static Account acc=new Account();
 
         @Value("${ldap.urls}")
	private String ldapUrls;
 
	@Value("${ldap.base.dn}")
	private String ldapBaseDn;
 
	@Value("${ldap.user.dn.pattern}")
	private String ldapUserDnPattern;
 
	@Value("${ldap.enabled}")
	private String ldapEnabled;
 
 
 
        @Bean
public AuthenticationManager authenticationManagerBean() throws Exception {
    // ALTHOUGH THIS SEEMS LIKE USELESS CODE,
    // ITS REQUIRED TO PREVENT SPRING BOOT AUTO-CONFIGURATION
    return super.authenticationManagerBean();
}
 
 
 
        //@Override
	protected void configure(HttpSecurity http) throws Exception {
        http
        	.authorizeRequests()
				.anyRequest().authenticated()
				.and()
			.formLogin().and().httpBasic().disable();
 
 
 
 
 
	}
 
    @Bean
public InetOrgPersonContextMapper userContextMapper() {
    return new InetOrgPersonContextMapper();
}
 
       @Override
	protected void configure(AuthenticationManagerBuilder auth) throws Exception {
 
             GrantedAuthoritiesMapper grantedAuthoritiesMapper = null;
 
 
			auth
				.ldapAuthentication().userDnPatterns("uid={0},ou=users").authoritiesMapper(grantedAuthoritiesMapper)
 
				.contextSource()
					.url("ldap://localhost:10389/" + ldapBaseDn)
 
 
					.and()
 
                                .passwordCompare()
                    .passwordAttribute("userPassword")
                                .and()
                                .passwordEncoder(new LdapShaPasswordEncoder());
 
 
 
 
 
 
 
 
 
 
 
 
 
    }
 
    }
je ne connais pas comment utiliser la fonctionne antMatchers et hasRole avec mon code



quelqu'un m'aide
merci.