Сервер конфигурации Spring Cloud отключает конечную точку шифрования и дешифрования - PullRequest
0 голосов
/ 02 ноября 2018

Я пытаюсь отключить шифрование и дешифрование конечных точек на сервере конфигурации Spring Cloud. Мой файл Bootstrap.yml

spring:
  cloud:
    config:
      server:
        encrypt:
          enabled: false

encrypt:
  keyStore:
    location: ####
    password: ####
    alias: ####
    secret: ###

Я пробовал этот файл свойств с различными версиями весеннего облака и весенней загрузки Пробная весенняя загрузка версии 1.5.8.RELEASE и springCloudVersion = 'Dalston.SR4'

также пытался

springBootVersion = '2.0.5.RELEASE' а также springCloudVersion = 'Finchley.SR1'

но все же у меня работают конечные точки шифрования и дешифрования.

1 Ответ

0 голосов
/ 02 ноября 2018

Используйте Spring Security для блокировки этого URI, при этом URL-адреса конечной точки конфигурации недоступны для общего доступа.

package com.debopam.configserver;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

/**
 * @author Debopam
 *
 */
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    @Autowired
    public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
        auth.inMemoryAuthentication()
        .withUser("configUser").password("configPassword").roles("SYSTEM")
            .and()
        .withUser("admin").password("admin").roles("SUPERUSER","ADMIN")
            .and()
        .withUser("actuator").password("actuator").roles("ACTUATOR");;
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests()
            .antMatchers("/encrypt**").hasAnyRole("SUPERUSER","ADMIN")
            .antMatchers("/decrypt**").hasAnyRole("SUPERUSER","ADMIN")
            .anyRequest().hasRole("SYSTEM").and().httpBasic().and().csrf().disable();


    }
}
...