开启spring boot actuator 安全认证

通过本文配置,会对actuator 除了health外的所有端点,开启用户名密码验证,对于自己开发的接口不会要求用户名密码验证。

 

版本:

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.4.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Dalston.SR1</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

 

maven依赖:

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

 

配置:

management:
  security:
    enabled: true
security:
  user:
    name: xxx
    password: xxx
  basic:
    enabled: false

 

posted @ 2018-04-11 16:52  剑握在手  阅读(4743)  评论(0编辑  收藏  举报
返回顶部↑