SecurityConfiguration.java 文件源码

java
阅读 26 收藏 0 点赞 0 评论 0

项目:demo-spring-security 作者:
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    CustomJdbcUserDetailsService customJdbcUserDetailsService = new CustomJdbcUserDetailsService();
    customJdbcUserDetailsService.setDataSource(dataSource);

    DaoAuthenticationProvider customJdbcProvider = new DaoAuthenticationProvider();
    customJdbcProvider.setUserDetailsService(customJdbcUserDetailsService);

    CustomLdapAuthoritiesPopulator customLdapAuthoritiesPopulator = new CustomLdapAuthoritiesPopulator(customJdbcUserDetailsService);

    auth.jdbcAuthentication().dataSource(dataSource);
    auth.inMemoryAuthentication().withUser("memdemo").password("secret").roles("USER").and().withUser("memadmin").password("53cr37").roles("ADMIN");
    auth.authenticationProvider(customJdbcProvider);
    auth.ldapAuthentication().userDnPatterns("uid={0},ou=users").groupSearchBase("ou=groups").groupRoleAttribute("ou").contextSource()
            .ldif("classpath:com/iampfac/howto/spring/security/users.ldif").root("dc=example,dc=org");

    auth.ldapAuthentication().ldapAuthoritiesPopulator(customLdapAuthoritiesPopulator).userDnPatterns("uid={0},ou=users").contextSource()
            .ldif("classpath:com/iampfac/howto/spring/security/mix.ldif").root("dc=example,dc=org");
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号