Skip to content

Spring Security configuration options are picked up too early #400

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
michael-simons opened this issue Feb 25, 2014 · 6 comments
Closed
Labels
type: bug A general bug
Milestone

Comments

@michael-simons
Copy link
Contributor

Have a look at this application:

https://github.com/michael-simons/biking2

I'll use it as a deployed executable jar file.

It contains an application.properties inside the deployed jar file at classpath:application.properties with 2 defaults:

security.user.name = biking2
security.user.password = biking2

these are picked up correct.

In production I have another application.properties parallel to the jar

./biking2.jar
./application.properties

when i run java -jar biking2.jar, properties from those 2nd file are picked up but not the security.* properties, those are still the properties from the jar file.

@dsyer
Copy link
Member

dsyer commented Feb 26, 2014

I don't think it's possible for security properties to be parsed in a different order, so I suspect pilot error. Are you sure that the local properties are being read? Are you sure that you haven't got a spelling error, or whitespace problem or something in the local file?

@dsyer dsyer added the question label Feb 26, 2014
@michael-simons
Copy link
Contributor Author

Nope, i just checked it with my app. I've fixed the errors you had (michael-simons/biking2@a2b9a2b) so you can try it out yourself:

mvn clean && mvn -DskipTests=true package
mkdir f
mv target/biking2-0.2.6-SNAPSHOT.jar f/
cd f
echo "security.user.name = foo" >> application.properties
echo "security.user.password = bar" >> application.properties
java -jar biking2-0.2.6-SNAPSHOT.jar 
// i expect Spring Boot to pike up the application.properties parallel to the jar
curl -ufoo:bar -X POST -H "Content-Type: application/json" -d '{"name":"test", "boughtOn":"2014-02-26T10:24:41.083Z", "color":"ccc"}' http://localhost:8080/api/bikes     
// but i get a 401
// using the default it works
curl -ubiking2:biking2 -X POST -H "Content-Type: application/json" -d '{"name":"test", "boughtOn":"2014-02-26T10:24:41.083Z", "color":"ccc"}' http://localhost:8080/api/bikes

When i change the start to include the explicit path

java -Dspring.config.location=./application.properties -jar biking2-0.2.6-SNAPSHOT.jar

it works as expected.

Note: All properties from the file in parallel to the jar ARE picked up, wether i use the java parameter or not.

@dsyer
Copy link
Member

dsyer commented Feb 26, 2014

It works for me with your "public" branch and a SNAPSHOT of Boot. Can you verify and we can call this fixed?

@michael-simons
Copy link
Contributor Author

I made a fresh mvn clean && mvn package on master of spring-boot, used it with my app and now it works as expected. Great.

I am / was using RC3 before.

@dsyer dsyer added this to the 1.0.0.RC4 milestone Feb 26, 2014
@dsyer dsyer added bug and removed question labels Feb 26, 2014
@dsyer
Copy link
Member

dsyer commented Feb 26, 2014

OK. We did tweak the config parsing a bit, so I'll assume it was that, but can't put my finger on the relevant change.

@dsyer dsyer closed this as completed Feb 26, 2014
@michael-simons
Copy link
Contributor Author

Just to let you know, works fine with 1.0.0.RC4, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants