【问题标题】:How to create token with LDAP authentication in Spring Security如何在 Spring Security 中使用 LDAP 身份验证创建令牌
【发布时间】:2016-09-07 16:19:30
【问题描述】:

我使用 Spring boot 和 Spring Security 实现了 LDAP 身份验证。配置非常简单。

@Configuration
    protected static class AuthenticationConfiguration extends
            GlobalAuthenticationConfigurerAdapter {

        @Override
        public void init(AuthenticationManagerBuilder auth) throws Exception { 
            DefaultSpringSecurityContextSource contextSource = new DefaultSpringSecurityContextSource(url);
            contextSource.setUserDn(userDn);
            contextSource.setPassword(userPass);
            contextSource.setReferral("follow"); 
            contextSource.afterPropertiesSet();

            LdapAuthenticationProviderConfigurer<AuthenticationManagerBuilder> ldapAuthenticationProviderConfigurer = auth.ldapAuthentication();

            ldapAuthenticationProviderConfigurer
                .userDnPatterns("cn={0},ou=institution,ou=people")
                .userSearchBase("")
                .contextSource(contextSource); 
        }
    }

现在我想创建一个基于令牌的身份验证,以便在首次成功登录后,服务器可以通过使用服务器上创建的令牌验证请求标头来简单地验证请求。

由于 LDAP 身份验证是在后台使用 ldapAuthentiationProvider 完成的,我不确定如何从第一次登录中获取用户凭据以及如何发送令牌作为对登录的响应。我应该在表单登录过滤器中注入自定义身份验证成功处理程序以根据用户凭据创建令牌吗?如果可以,具体怎么做?

【问题讨论】:

    标签: authentication spring-security ldap token


    【解决方案1】:

    【讨论】:

      猜你喜欢
      • 2016-09-09
      • 2012-02-18
      • 2016-09-01
      • 2012-10-10
      • 2018-08-09
      • 2015-10-20
      • 2017-07-10
      • 2012-11-18
      • 2013-05-08
      相关资源
      最近更新 更多