Grails Spring Security X509 for Authentication and LDAP for



一些指针比这里需要的更多。

我正在尝试让X509和LDAP在我的应用程序中工作。我希望用户使用他们的PKI证书进行身份验证,然后让APP从我们的LDAP服务器获得他们的权限。

目前我有LDAP与客户userDetailsContextMapper一起工作,但是如何正确添加x509有点难倒我。

我想我想要的是一个PreAuthenticatedAuthenticationProvider,使用注入的ldapUserDetails服务。

我该怎么做呢?我是否需要一个UserDetailsByNameServiceWrapper来包装LdapUserDetailsService,以便在预认证提供程序中使用?

我问这个问题是因为不幸的是,测试平台和开发环境目前是分离的,我没有设置本地LDAP或PKI来测试,所以大约需要6个小时的过程才能将新的war放到开发环境中…限制性的,我知道……所以我想第一次就把它做好。

干杯!

注意:以下工作在Spring-Security-Core v1.2.7.3,配置名称在2.0RC2中是不同的

根据几个不同的想法,这是我想到的。这假设您已经让LDAP使用自定义和UserDetailsContextMapper(请参阅:LDAP文档):

确保LDAPPreAuthenticatedAuthentication提供商都在提供商列表中:

grails.plugins.springsecurity.providerNames = [
                                       'preAuthenticatedAutehnticationProvider',
                                       'ldapAuthProvider',
                                       'daoAutehnticationProvider',
                                       'anonymousAuthenticationProvider', 
                                       'rememberMeAuthenticationProvider']

然后在spring资源(grails-app/conf/spring/resources.groovy)中配置以下bean:

ldapUserDetailsService(org.springframework.security.ldap.userdetails.LdapUserDetailsService, 
                       ref('ldapUserSearch'),
                       ref('ldapAuthoritiesPopulator')) {
    userDetailsMapper = ref('ldapUserDetailsMapper')
}
userDetailsByNameServiceWrapper(org.springframework.security.core.userdetails.UserDetailsByNameServiceWrapper) {
    userDetailsService = ref('ldapUserDetailsService')
}
preAuthenticatedAuthenticationProvider(org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationProvider) {
    preAuthenticatedUserDetailsService = ref('userDetailsByNameServiceWrapper')
}

还有你的叔叔和你有几个阿姨!

作为参考,我用来提出这个解决方案的页面是:

  1. 没有发现使用spring安全的AuthenticationProvider

    在UserDetailsByNameServiceWrapper中包装你的LdapUserDetailsService代替LdapAuthenticationProvider配置一个PreAuthenticatedAuthenticationProvider,它将能够处理由CustomX509AuthenticationFilter发出的PreAuthenticatedAuthenticationToken。将包装好的LdapUserDetailsService注入PreAuthenticatedAuthenticationProvider。

  2. http://blog.serindu.com/2011/05/26/grails-spring-security-using-preauthenticated-authentication-provider/介绍如何在grails

  3. 中连接preAuthenticationAuthenticationProvider。http://forum.spring.io/forum/spring-projects/security/108467-combine-pre-authentication-with-ldap-for-user-details-and-authorities
  4. 有一个LdapUserDetailsService它做了LdapAuthenticationProvider做的所有好的事情-除了身份验证

  5. http://pwu-developer.blogspot.co.uk/2012/02/grails-security-with-cas-and-ldap.html更多关于如何连接ldapUserDetailsService

希望这对其他人有帮助!

最新更新