How to pass X-Config-Token with spring-cloud-starter-config - spring-boot

It works fine when I invoke the config server using curl -X GET http://localhost:8888/limits-service/dev -H "X-Config-Token: s.6S92v3OekCYEAWjp8unbt4ei"
But from the client microservice, upon invoking the config service http://localhost:8888/limits-service/dev how to pass the header. The following details are configured in the client microservice application.properties but gets 404 error.
spring.application.name=limits-service
spring.cloud.config.uri=http://localhost:8888/
spring.profiles.active=dev.
So how to pass X-Config-Token: s.6S92v3OekCYEAWjp8unbt4ei ?

This token can be provided within the client by setting spring.cloud.config.token in bootstrap.yml.
spring:
cloud:
config:
token: YourVaultToken

Related

Client authentication failure on Neo4J

I basically followed the steps described here: https://docs.spring.io/spring-data/neo4j/docs/current/reference/html/#configure-spring-boot-project
My application.properties contains the following:
spring.neo4j.uri=neo4j://localhost:7687
spring.neo4j.authentication.username=neo4j
spring.neo4j.authentication.password=verySecret357
I have a Neo4jConfiguration Bean which only specifies the TransactionManager, rest is (supposedly) taken care of by spring-boot-starter-data-neo4j:
#Configuration
public class Neo4jConfiguration {
#Bean
public ReactiveNeo4jTransactionManager reactiveTransactionManager(Driver driver,
ReactiveDatabaseSelectionProvider databaseNameProvider) {
return new ReactiveNeo4jTransactionManager(driver, databaseNameProvider);
}
}
Neo4j (5.3.0) runs in a Docker container I started with
docker run -d --name neo4j -p 7474:7474 -p 7687:7687 -e 'NEO4J_AUTH=neo4j/verySecret357' neo4j:4.4.11-community
I can access it through HTTP on my localhost:7474 and can authenticate using the credentials above.
Now, when I run my springboot app and try to create Nodes in Neo4j, I keep getting the same exception:
org.neo4j.driver.exceptions.AuthenticationException: The client is unauthorized due to authentication failure.
Running in debug, it however seems the client authentication scheme is correctly set:
Any thoughts on what I might be doing wrong ?
Edit: one thing though, I would assume that the "authToken" would contain a base64-encoded String (username:password) as the scheme is basic auth. It looks like it's not the case (using neo4j-java-driver:5.2.0).
Edit: seems to be related to the Docker image. A standalone neo4j instance works fine.

Quarkus - Spring Cloud Config Client

I am getting this error when trying to set header that has to be sent to Spring Config Server.
Unrecognized configuration key "quarkus.spring-cloud-config.headers" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
# application.properties
quarkus.spring-cloud-config.headers="access_token=12345"
I am not sure what I am doing wrong. Please help. Thanks in advance.
You need to use:
quarkus.spring-cloud-config.headers.access_token=12345

Spring cloud's config server plain text api with SVN and a default label

I have spring boot 2 app that acts as a config server with the following properties. Notice in particularly the "default-label" properties which is the empty string because we check out directly the folder that contains the files, and not some parent branch/folder.
spring:
application:
name: config-server
profiles:
include: subversion
cloud:
config:
server:
svn:
uri: https://...somesvnrepo.../project/trunk/config
username: fake
password: notreal
default-label:
basedir: C:\Users\John\Documents\Application\configserver_tmp
The contents of /trunk/config is straigthforward. There ae no subdirectories and just these files:
application.yml
application-dev.yml
myservice.yml
myservice-dev.yml
logback.xml
Serving the yml files works fine, but getting the logback.xml file using the "plain text api" not work at all.
Doing localhost:8888/appname/default/master/logback.xml gives the error "no label master found" which is true, I don't have that label. Any other combination of paths by omitting profiles or labels results in a 404 all the way up to just calling localhost:8888/logback.xml. Adding the ?useDefaultLabel request parameter makes no difference. Actually I don't understand the purpose of the appname, profile and label part of the url when the context is to get a plain text file that is not bound to any specific application, profile or label.
I found similar questions on the internet but they mention updating their spring boot version and then it worked for them. I'm already at the latest spring boot version (2.1.3-release).
Is this because I use SVN? Or because of of the default-label being empty?

Call /env on Spring cloud config client side, password property shows " portal.db.password=*** "

My config file on remote git repo:
myapp-uat.properties:
portal.db.userName=allen
portal.db.password=allen1235
I could load this file on client side, and I want save these properties by call /env, but get portal.db.password=***.
I wonder if I could get real value (portal.db.password=allen1235) by adding some properties in client config file or some other methods. Hope for your help.
The below is the default sanitized keywords for /env endpoint.
endpoints:
env:
keys-to-sanitize: password,secret,key,token,.*credentials.*,vcap_services
You can override the below property without password by defining below in your application.yml/properties.
endpoints:
env:
keys-to-sanitize: secret,key,token,.*credentials.*,vcap_services

Error with Spring Boot Jsp sample application

I'm trying to configure a Spring Boot application with JSP template. I'm having some problems with it so I'm comparing my application with Spring Boot's sample jsp application: https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-web-jsp
To my surprise I've got the same problem with the sample. I'm going to try to describe the steps I've followed:
Download spring-boot: git clone https://github.com/spring-projects/spring-boot
Move to a stable version: git checkout v1.4.0.RELEASE
Move to the sample application: cd spring-boot/spring-boot-samples/spring-boot-sample-web-jsp/
Run the application: mvn spring-boot:run
In the application's logs I see the available request mappings: /, /foo and /error
I do this request curl -XGET localhost:8080/ and I get this answer:
{"timestamp":1471504557212,"status":404,"error":"Not Found","message":"No message available","path":"/"}
The result that I expected was the html of welcome.jsp. It seems that there is a problem when Spring Mvc tries to render welcome.jsp.
Any idea what I am doing wrong?

Resources