在我的项目中,我有以下bootstrap.properties文件:
spring.application.name=vault-demo
management.endpoints.web.exposure.include=*除此之外,我还定义了以下依赖关系:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator</artifactId>
</dependency>配置服务器能够访问该属性,但当我在GitHub中更新该属性并将其发送到/refresh时,将得到一个403: Forbidden。我是否需要对我的应用程序或bootstrap.properties做任何更改?
发布于 2018-09-12 20:21:44
我得到了解决方案,我需要添加一个安全配置,例如:
@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter{
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable();
}
}此外,我还必须添加以下依赖项:
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-rsa</artifactId>
<version>1.0.5.RELEASE</version>
</dependency>我在以下GitHub问题中找到了这个解决方案:https://github.com/spring-cloud/spring-cloud-config/issues/950
发布于 2019-02-26 14:55:10
我注意到Spring 2云配置不需要在提交(或其他事件)之后被“连接到/refresh端点”,因为新版本总是请求远程diferrent,并比较最后一个commitId,如果是不同的commitId,则开始获取更改。
如果调试并看到日志跟踪,在请求http://host:8888/{service}/{profile}/{label_branch}总是询问github之后,您会注意到如果exist更改了一个“启动了提取过程”,请查看类似于github协商的跟踪:
o.e.jgit.transport.PacketLineOut - git> 希望4a766a1677.o.e.jgit.transport.PacketLineOut - git> 拥有93cd4a98b5b3bb7d895.最后o.e.jgit.transport.PacketLineOut - git> done
下载后: o.e.jgit.transport.PacketLineIn - git< ACK 0f8d2413183d5.普通的等等。
如果您查看跟踪而不存在更改(最后一个commitId是相同的,则不会显示协商和下载跟踪)。
我认为这不是一个很好的性能行为,因此会存在一个禁用它的属性,因此需要一个“强制刷新挂钩行为”,但是我在Spring 2上找不到它。另一方面,我喜欢它,因为您不需要通知对配置服务器的HTTP访问,所以安全配置不会受到损害。
我和Greenwich.RELEASE试过
希望这有助于并澄清这种行为。
https://stackoverflow.com/questions/52299072
复制相似问题