使用 JBoss <安全域> 的 Spring Security

标签 spring authentication jboss spring-security ldap

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

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 中使用这个安全域

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();
    }
}

最佳答案

JBoss 身份验证需要

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

可以通过以下方法添加:

auth.authenticationProvider(...);

除此之外

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

应该注册。

关于使用 JBoss <安全域> 的 Spring Security,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28172056/

相关文章:

java - Maven 项目中缺少 org.apache.commons.dbcp 包

JavaMailSender - 将动态值设置到邮件模板中

java - Spring data jpa存储库通过多元素查找

authentication - JBoss 服务器上的客户端身份验证

.net - 如何使用 'network service' 帐户启动控制台应用程序?

php - 使用 PHP、MySQL 和 MD5 创建登录

java - 在 Jboss EAP 6.3 中编写一个 Java 程序连接到 HornetQ 消息服务?

java - Spring数据事务控制

spring - 在 Spring Boot 执行器中设置 endpoints.health.sensitive=false 时无效

docker - 如何将docker变量传递给jboss-cli.sh?