Spring boot client and cloud config server HTTP authentication

I’m configuring a spring boot 1.5.4 client with spring cloud config server 1.3.1. The client and the server works without any authentication. However, I’m trying to configure HTTP Basic authentication which is not working. It continues to be accessible even without authentication when I reach the spring cloud config server URL over browser. I may be missing something fundamental.

My client bootstrap.properties file is


spring.application.name=service1
spring.cloud.config.uri=https://config.example.com
spring.cloud.config.username=username
spring.cloud.config.password=xxxx
spring.profiles.active=profile1,profile2
management.security.enabled=true

And my cloud config server application.properties looks like –


server.port=443
spring.application.name=spring-config
spring.cloud.config.server.git.uri=https://gitlab.com/services/service1.git
spring.cloud.config.server.git.username=serviceuser
spring.cloud.config.server.git.password=servicepass
spring.cloud.config.server.git.clone-on-start=true
security.user.name=username
security.user.password=xxxx
spring.cloud.config.server.health.enabled=false
spring.cloud.config.server.bootstrap=true
spring.cloud.config.server.prefix=/config

When I access `https://config.example.com/service1/label I do not get any sort of authentication but I do see my config service1-label.properties in JSON

Any help is appreciated!

Answer

To use the default Spring Boot configured HTTP Basic security, just include Spring Security on the classpath (e.g. through spring-boot-starter-security).

Attribution
Source : Link , Question Author : Chida , Answer Author : kimbad

Leave a Comment