前提条件(Prerequisite)

1.你的项目里引进了Spring web security

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>

<version>1.5.19.RELEASE</version
</dependency>

2. application.properties

management.context-path=/mgmt

3. 给Actuator相关的URL 加了另外的权限

http.authorizeRequests()
.antMatchers("/mgmt/**").hasAnyRole(ADMIN, SUPPORT, ACTUATOR)
.antMatchers("/**").hasRole(USER)
.and().formLogin().and().httpBasic();

出现的问题(Issue )-- 当登陆你的username and password 时 而且你这个user 是 ADMIN 或SUPPORT时, 出现下面错误页面。

Access is denied. User must have one of the these roles: ACTUATOR

解决方法(Solution)

disable manangement security in application.properties 或系统参数

management.security.enabled=false

原因(Cause)

Spring 会用一个MvcEndpointSecurityInterceptor 阻止所有非actuator角色的用户, 及时你已经重新自定义自己的权限管理。

private void sendFailureResponse(HttpServletRequest request,
HttpServletResponse response) throws Exception {
if (request.getUserPrincipal() != null) {
String roles = StringUtils.collectionToDelimitedString(this.roles, " ");
response.sendError(HttpStatus.FORBIDDEN.value(),
"Access is denied. User must have one of the these roles: " + roles);
}

最新文章

  1. iOS thirdKeyboard Develop (APP Extension)
  2. Url中處理空格、特殊字符
  3. JS_01_入门学习
  4. php blowfish加密解密具体算法
  5. php获取在线xml的数据
  6. Blackhat EU 2013 黑客大会(Full Schedule for Black Hat USA 2013)
  7. 2014 ACM/ICPC Asia Regional Guangzhou Online
  8. Notification 多次传递参数 一直都是旧的 解决
  9. Android 如何检测一个服务是否还在运行?
  10. codeforces 55D. Beautiful numbers 数位dp
  11. ORA-12514(TNS:监听程序当前无法识别...)
  12. 在Centos 5.4上安装Mysql5.5.10 (整理以前的工作文档)
  13. 201521123083《Java程序设计》第12周学习总结
  14. VS OpenCV imread imwrite nameWindow等相关报错问题
  15. ActiveMQ的两种消息模式,主题、队列
  16. 一文看懂汽车电子ECU bootloader工作原理及开发要点
  17. 【BZOJ】2331: [SCOI2011]地板
  18. elasticsearch 口水篇(3)java客户端 - Jest
  19. java se的那些细节
  20. Python3 enumerate() 函数

热门文章

  1. mybatis精讲(四)--ObjectFactory
  2. 《程序人生》系列-害敖丙差点被开除的P0事故
  3. 在Windows系统中构建还原ASP.NET Core 源码
  4. sync.Map(在并发环境中使用的map)
  5. 解密国内BAT等大厂前端技术体系-阿里篇(长文建议收藏)
  6. Python列表中的字典按照该字典下的键值进行排序
  7. 这个立冬,我线下面基了一位TMD高级专家,太牛逼了!
  8. play-with-docker搭配ffsend完成文件上传及下载(解决从docker hub拉取镜像慢问题)
  9. C#语言和SQL Server数据库技术_前四章错题
  10. [TimLinux] 养成一个习惯