【问题标题】:Spring Security using JBoss <security-domain>Spring Security 使用 JBoss <security-domain>
【发布时间】:2015-03-26 03:51:33
【问题描述】:

我正在使用 Spring Security 和基于 Java 的 @Configuration 构建应用程序。我们的 JBoss EAP 6 服务器配置了一个 security-domain,它在 jboss-web.xml-File 中定义。

jboss-web.xml

<!DOCTYPE jboss-web PUBLIC
    "-//JBoss//DTD Web Application 4.2//EN"
    "http://www.jboss.org/j2ee/dtd/jboss-web_4_2.dtd">
<jboss-web>
    <security-domain>ldapcomponent</security-domain> 
</jboss-web>

有没有办法在我的 Spring Security WebSecurityConfigurerAdapter 中使用这个 security-domain

Spring Security Java 配置

@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(securedEnabled = true)
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {

    @Autowired
    public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
        auth.?????
    }

    @Override
    protected void configure(final HttpSecurity http) throws Exception {
        http.authorizeRequests().anyRequest().authenticated()
            .anyRequest().hasRole("my-required-role").and().httpBasic();
    }
}

【问题讨论】:

    标签: spring authentication jboss spring-security ldap


    【解决方案1】:

    JBoss 身份验证需要一个

    org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationProvider
    

    可以通过方法添加:

    auth.authenticationProvider(...);
    

    除此之外

    org.springframework.security.web.authentication.preauth.j2ee.J2eePreAuthenticatedProcessingFilter 
    

    应该注册。

    【讨论】:

    • 如何设置使用 JBoss 安全域的 PreAuthenticatedAuthenticationProvider?
    猜你喜欢
    • 1970-01-01
    • 2017-03-03
    • 2015-09-11
    • 1970-01-01
    • 1970-01-01
    • 2014-02-15
    • 2012-11-27
    • 2019-01-03
    • 2021-08-02
    相关资源
    最近更新 更多