Skip to content
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

Change Spring Boot default application.properties to be generated in root directory #114

Open
mraible opened this issue Mar 13, 2021 · 4 comments

Comments

@mraible
Copy link
Contributor

mraible commented Mar 13, 2021

Currently, when you create a Spring Boot App with the Okta CLI (using Spring Security or the Okta Spring Boot Starter), it adds all your configuration to src/main/resources/application.properties. This isn't great because people often have non-sensitive configuration information in this file and they'll likely want to check it in.

I think it's better to generate application.properties in the root directory. This will file will still be read when you start the app, and it's unlikely people will check it in by mistake.

@bdemers
Copy link
Contributor

bdemers commented Mar 24, 2021

Yeah, I've struggled with this one a bit for that exact reason.

I'll have to try this out, but... what about something like this: https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-external-config-files-importing

src/main/resources/application.properties

spring.config.import=optional:file:./okta-secrets.properties # or a better name here

This should allow env vars to take precedence as well

@mraible
Copy link
Contributor Author

mraible commented Mar 24, 2021

The spring.config.import stuff will only work with Spring Boot 2.4+. That might be an issue.

@bdemers
Copy link
Contributor

bdemers commented Mar 24, 2021

Doh, that would explain why I hadn't heard of it before...

Another option might be to try something like this and create a ./config/okta/application.properties

But I might be overthinking it, and maybe just stick it in the root dir, along with a comment in the header of the file:

Here be dragons... don't commit this file... bla bla

@mraible
Copy link
Contributor Author

mraible commented Jan 25, 2022

FWIW, I'm in the process of changing the sample that's generated with okta start spring-boot to use spring-dotenv. okta-samples/okta-spring-boot-sample#22

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

No branches or pull requests

2 participants