Maa*_*ten 5 java spring spring-security websphere-liberty
我有一个正在运行的 springmvc 和在 IBM Liberty 配置文件上运行的 spring security Web 应用程序。我使用 java config 来设置所有内容(并且没有 web.xml)。
扩展 WebSecurityConfigurerAdapter 类,我设置了简单的用户列表,如下所示:
@Autowired
public void configureGlobalSecurity(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication().withUser("bill").password("123456").roles("USER");
}
Run Code Online (Sandbox Code Playgroud)
我不想在代码中包含用户信息,因此我想将用户注册表移动到 IBM Liberty Profile 服务器的 server.xml 中。
<basicRegistry>
<user name="bill" password="123456"/>
</basicRegistry>
Run Code Online (Sandbox Code Playgroud)
我该如何配置这个?
额外信息 我使用一个多模块 Maven 项目,带有一个 Ear 和一个 war 模块。所以在 server.xml 中最后一行是
<enterpriseApplication id="hellospringEAR" location="hellospringEAR-00.00.0001-SNAPSHOT.ear" name="hellospringEAR"/>
Run Code Online (Sandbox Code Playgroud)
非常感谢任何提示或建议。
小智 1
您需要使用 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();
}
}
Run Code Online (Sandbox Code Playgroud)
更多详细信息请参见: 角色/权限在 Websphere Liberty 中不起作用
| 归档时间: |
|
| 查看次数: |
2304 次 |
| 最近记录: |