我的Spring启动服务器上下文路径:/ test

我使用nginx配置为“https://localhost:8443/test”基本路径设置了身份验证设置,该基本路径中的其余api是边缘服务。

问题:我不希望我的健康服务作为边缘服务公开并进行身份验证。但是执行器的运行状况检查是作为管理员服务提供的,并且管理员的上下文路径不会覆盖应用程序的基本路径。

我可以在应用程序中进行哪些调整以区分其余API和执行器的运行状况检查API之间的上下文路径。

Dropwizard非常容易做到这一点。

最佳答案

您可以使用spring-security来保护管理端点:

spring-boot-starter-security添加到您的依赖项中:

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

这本身将保护所有端点。如果只希望保护mgmt的安全,请添加以下属性:
security.basic.enabled=false

您还可以为此设置其他用户/密码:
security.user.name=admin
security.user.password=new_password

归功于this post

10-07 19:09
查看更多