如何将弹簧安全配置与IBM Liberty Profile Basic Registry连接



我有一个运行的SpringMVC,其中Spring Security Web应用程序在IBM Liberty Profile上运行。我使用Java配置来设置所有(并且没有web.xml)。

扩展了类WebsecurityConfigurerAdapter,我设置了简单的用户列表,如下所示:

@Autowired
public void configureGlobalSecurity(AuthenticationManagerBuilder auth) throws Exception {
 auth.inMemoryAuthentication().withUser("bill").password("123456").roles("USER");
}

我不希望用户信息中的用户信息,因此我想将用户注册表移至ibm liberty配置文件服务器的server.xml。

<basicRegistry>
    <user name="bill" password="123456"/>
</basicRegistry>

我该如何配置?

额外的信息我使用带有耳朵和战争模块的多模块Maven项目。因此,在server.xml中,最后一行是

<enterpriseApplication id="hellospringEAR" location="hellospringEAR-00.00.0001-SNAPSHOT.ear" name="hellospringEAR"/>

任何提示或建议都非常感谢。

您需要使用Spring Security对容器托管安全的支持(这是JEE()方法)

@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
private static final Logger LOGGER = LoggerFactory.getLogger(SecurityConfig.class);
@Autowired
private ApplicationProperties appProperties;
@Override
protected void configure(final HttpSecurity http) throws Exception {
    http.authorizeRequests()
            .anyRequest().authenticated()
            .and().httpBasic();
    if (appProperties.isContainerManaged()) {
        LOGGER.info("using container managed");
        http.jee();
    }
    http.csrf().disable()
            .logout()
            .permitAll();
}
}

更多详细信息在这里:角色/当局不在WebSphere Liberty中工作

最新更新