I have configured a Spring Cloud Config server to force BASIC authentication and here is my application.yml file:
# Config Repo:
spring:
cloud:
config:
server:
git:
uri: file:///${HOME}/microservices_config_repo
# Show sensitive information for endpoints:
endpoints:
sensitive: true
# Security for endpoints:
management:
security:
enabled: true
security:
user:
name: user1
password: changeme
My issue I am having is that when I start the server up as:
mvn spring-boot:run
The server endpoints FORCE BASIC Authentication.
But when I start the Application.main() method, BASIC Authentication is enabled, but NOT enforced.
Meaning I can access configuration on:
http://localhost:8888/client-config
and
http://user1:changeme#localhost:8888/client-config
Can anyone help me understand why this is occuring and how to enforce BASIC Authentication while running the Application.main(), and not just through the Maven spring-boot plugin?
Note, when I use maven to package the app into a jar, then run the generated jar, BASIC Authentication is enforced, but still not through the IDE running just the Application.main directly.
Maybe the format the oy Yaml for example to me seems works like this:
server:
port:9999
spring:
application:
name: config-server-sample
cloud:
config:
name: ${spring.application.name}
fail-fast: true
server:
git:
uri: url
username: xx
password: zz
default-label: master
basedir: '${user.home}/${spring.application.name}/default'
timeout: 10
clone-on-start: true
force-pull: true
security:
basic:
enabled: true
path: /**
ignored: /health**,/info**,/metrics**,/trace**
user:
name: admin
password: tupassword
Related
I'm trying to read secret values using spring vault. All the properties for client application is stored in github and spring config server is used to access the properties. When I add the vault configuration to client application bootstrap.yml as below, the values are read properly.
bootstrap.yml
spring:
application:
name: client-app
cloud:
config:
uri: http://config-server:8080
vault:
enabled: true
authentication: APPROLE
app-role:
role-id: 12345
secret-id: 12345
role: pres-read
app-role-path: approle
connection-timeout: 5000
read-timeout: 15000
kv:
enabled: true
backend: secrets
application-name: client-app
uri: https://vault/
application.yml in config server
spring:
cloud:
config:
server:
git :
uri: https://github/repo.git
username: abc
password: pass
refreshRate: 300
Based on https://docs.spring.io/spring-cloud-vault/docs/current/reference/html/config-data.html#vault.configdata , it should be possible to load the vault config from properties yml in github. But if i move the above vault config to my client-app.yml in github, the properties are not read from the vault. How do I achieve this?
How to use application.yml in spring cloud config client application?
spring:
application:
name: app-cli
profiles:
active: DEV
config:
import: "configserver:"
cloud:
config:
name: ${spring.application.name}
uri: http://192.168.0.12:8888
username: thirumal
password: thirumal
request-read-timeout: 200
request-connect-timeout: 100
fail-fast: true
The client app is configure with all the required properties, still it's not connecting to config-server.
The lib implementation 'org.springframework.cloud:spring-cloud-starter-config'
Spring Config-Client is in initial startup so It would not have cached the data from config server,
if either Config-Server or GIT or both are down - what can be done in that case to get the data and maintain service availability.
You can use the following (basedir) element of yml file with following hierarchy.
The "basedir" element will cache your config data whenever application restarts and keep that on the specified path which is specified against this key as a value.
Example :
basedir : C:\POC_CONFIG_SERVER\config-repo-am
server:
port: 8888
spring:
application:
name: cloud-config-server
cloud:
config:
server:
git:
uri: ${uri}
force-pull: true
skip-ssl-validation: true
skipSslValidation: true
username: ${username}
password: '${password}'
default-label: master
basedir: ${basedir}
I am struggling to fix this issue.
I am trying to use the spring cloud-config with github repo but it not fetching any config.
The server is working fine with file-based configuration but not working with GIT.
spring:
profiles:
active: native
cloud:
config:
discovery:
enabled: false
server:
git:
uri: https://github.com/${GIT_USER}/config-server
searchPaths: organizationservice,personservice,zuulservice
username: ${GIT_USER}
password: ${GIT_PASS}
skipSslValidation: true
cloneOnStart: true
Boot and cloud version
springBootVersion = '2.1.7.RELEASE'
springCloudVersion= "Greenwich.SR2"
I would like to read some configurations from multiple git repositories, something like:
spring:
profiles:
active: base, app1, app2
cloud:
config:
server:
base:
uri: http://${GIT_HOST}/base/base.git
username: ${GIT_USERNAME}
password: ${GIT_PASSWORD}
app1:
uri: http://${GIT_HOST}/group1/app1.git
username: ${GIT_USERNAME}
password: ${GIT_PASSWORD}
app2:
uri: http://${GIT_HOST}/group2/app2.git
username: ${GIT_USERNAME}
password: ${GIT_PASSWORD}
At startup I see the following exception:
Caused by: java.lang.IllegalStateException: You need to configure a uri for the git repository
The documentation shows an example using two different repos, git and svn. Can't we use multiple repos of the same kind?
Due to the link of document you said, the svn and git after server is the type, not profile. So you cannot use base, app1, app2.
But in your case, I think you can use this kind of config: document link.
spring:
cloud:
config:
server:
git:
uri: https://git/common/config-repo.git
repos:
team-a:
pattern: team-a-*
cloneOnStart: true
uri: http://git/team-a/config-repo.git
team-b:
pattern: team-b-*
cloneOnStart: false
uri: http://git/team-b/config-repo.git
team-c:
pattern: team-c-*
uri: http://git/team-a/config-repo.git