del*_*svb 6 java spring-security spring-boot
我的类路径上有Spring Security(并且已经验证了我自己的REST控制器的工作状态),但我的Actuator端点默认都是公开的(除了/shutdown).
我可以随意禁用端点(在阅读完这个问题之后),但是启用的端点始终可用而无需身份验证且没有management.security.role我的属性所需的角色.
即使我明确地设置endpoints.beans.sensitive=true了例子,它仍然可以在没有身份验证的情况下访问.
我的安全配置使用LDAP进行身份验证:
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private LdapContextSource contextSource;
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth
.ldapAuthentication()
.contextSource(contextSource)
.groupRoleAttribute("<hidden>")
.groupSearchBase("<hidden>")
.groupSearchFilter("<hidden>")
.userDnPatterns("<hidden>");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.httpBasic();
}
}
Run Code Online (Sandbox Code Playgroud)
我在此测试期间的application.properties:
# Log4J properties
logging.file=${user.home}/nubis-log.log
logging.level.org.springframework.web=INFO
logging.level.org.hibernate=INFO
logging.register-shutdown-hook=true
# SSL configuration
server.ssl.key-store=<hidden>
server.ssl.key-store-password=<hidden>
server.ssl.keyStoreType=<hidden>
server.ssl.key-password=<hidden>
# Spring actuator
endpoints.enabled=false
endpoints.info.enabled=true
endpoints.health.enabled=true
endpoints.beans.enabled=true
endpoints.beans.sensitive=true
management.security.role=ADMIN
Run Code Online (Sandbox Code Playgroud)
我的控制台输出:
[2016-04-15 12:30:05.742] boot - 2754 INFO [localhost-startStop-1] --- DelegatingFilterProxyRegistrationBean: Mapping filter: 'springSecurityFilterChain' to: [/*]
[2016-04-15 12:30:05.742] boot - 2754 INFO [localhost-startStop-1] --- FilterRegistrationBean: Mapping filter: 'webRequestLoggingFilter' to: [/*]
[2016-04-15 12:30:05.743] boot - 2754 INFO [localhost-startStop-1] --- FilterRegistrationBean: Mapping filter: 'CORSFilter' to: [/*]
[2016-04-15 12:30:05.743] boot - 2754 INFO [localhost-startStop-1] --- FilterRegistrationBean: Mapping filter: 'applicationContextIdFilter' to: [/*]
[2016-04-15 12:30:05.743] boot - 2754 INFO [localhost-startStop-1] --- ServletRegistrationBean: Mapping servlet: 'dispatcherServlet' to [/]
[2016-04-15 12:30:05.800] boot - 2754 DEBUG [localhost-startStop-1] --- DelegatingFilterProxy: Initializing filter 'springSecurityFilterChain'
[2016-04-15 12:30:07.059] boot - 2754 INFO [localhost-startStop-1] --- EndpointHandlerMapping: Mapped "{[/info || /info.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
[2016-04-15 12:30:07.061] boot - 2754 INFO [localhost-startStop-1] --- EndpointHandlerMapping: Mapped "{[/beans || /beans.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
[2016-04-15 12:30:07.063] boot - 2754 INFO [localhost-startStop-1] --- EndpointHandlerMapping: Mapped "{[/health || /health.json],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.HealthMvcEndpoint.invoke(java.security.Principal)
Run Code Online (Sandbox Code Playgroud)
可能有一个配置/属性阻止Spring Security在某个地方?我是否需要配置额外的东西才能使其与LDAP一起使用?
ndr*_*one -1
所有端点都有一个敏感属性,需要设置为true
看看Apedenix A https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html
在该页面上搜索执行器属性。
| 归档时间: |
|
| 查看次数: |
4127 次 |
| 最近记录: |