Repository navigation
COG-1158: Move datasource credentials to DB_USER/DB_PASSWORD env vars - #333
Open
patrickbradley-cog wants to merge 2 commits into
Open
patrickbradley-cog wants to merge 2 commits into
patrickbradley-cog wants to merge 2 commits into
Conversation
Co-Authored-By: patrick.bradley <patrick.bradley@cognition.ai>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
Co-Authored-By: patrick.bradley <patrick.bradley@cognition.ai>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Linear: COG-1158 — W1 · Move datasource credentials in application.properties to environment variables
Removes the plaintext DB password from
UserFront/src/main/resources/application.properties(W1 forward-compatible refactor; still Boot 1.5.4 / Java 8).testWhileIdle,validationQuery,ddl-autoand theMySQL5Dialectline are untouched (W2/W3 pivots).Why there's a small new class (
config/DataSourcePasswordCheck). On Boot 1.5 the@ConfigurationPropertiesbinder resolves placeholders leniently: whenDB_PASSWORDis unset, the literal string${DB_PASSWORD}is used as the password and startup only dies later with a misleadingAccess denied for user 'root'. The ticket requires startup to fail loudly, so aBeanFactoryPostProcessorcallsenvironment.getRequiredProperty("spring.datasource.password")(strict nested-placeholder resolution) before any bean is created:It checks the resolved
spring.datasource.password, notDB_PASSWORDdirectly, so anything that overrides the datasource password (the Testcontainers initializer,SPRING_DATASOURCE_PASSWORD, a profile file) still works. It runs afterApplicationContextInitializers, so the harness's initializer overrides are already in place when the check runs.Local dev.
UserFront/application-local.properties.[REDACTED SECRET]is committed. Copy it toUserFront/application-local.properties(git-ignored inUserFront/.gitignore) and run fromUserFront/withSPRING_PROFILES_ACTIVE=local. It lives in the module root, notsrc/main/resources, because Boot loadsfile:./application-{profile}.propertiesfrom the working directory. That means it works with bothmvn spring-boot:runandjava -jar, and it never gets packaged into the jar. The two variables are documented inREADME.md.Follow-ups / merge notes
avengers1993is gone from HEAD (git grep avengers1993 HEAD→ no match) but is still in git history. Whoever owns any database that used it should rotate it.masteryet. The Testcontainers harness (COG-1141) isn't merged either, so the "harness overrides datasource" path was simulated withSPRING_DATASOURCE_PASSWORD(see below).Verification (JDK Temurin 8u, MySQL 5.7 in docker on :3306, root password
s3cr3t-local)Environment-only note: with the current JDK 8 update, TLSv1/1.1 are disabled and the Boot-managed Connector/J 5.1.42 can't handshake with MySQL 5.7. So every local run passed
...onlinebanking?useSSL=falseas a runtime override (--spring.datasource.url/SPRING_DATASOURCE_URL). This happens onmastertoo and is not changed by this PR.java -jarwith noDB_PASSWORDIllegalStateException: Datasource password is not configured: set the DB_PASSWORD environment variableDB_PASSWORD=wrong java -jar …Access denied for user 'root'(real password actually used)DB_PASSWORD=s3cr3t-local java -jar …Started UserFrontApplication in 3.202 seconds; Tomcat on 8080SPRING_PROFILES_ACTIVE=local java -jar …with a localapplication-local.properties, no env varsThe following profiles are active: local→Started UserFrontApplication in 3.133 secondsDB_PASSWORD=s3cr3t-local mvn -B verifyTests run: 1, Failures: 0, Errors: 0→BUILD SUCCESSSPRING_DATASOURCE_PASSWORD=s3cr3t-local mvn -B verify(override, noDB_PASSWORD, like the harness)Tests run: 1, Failures: 0, Errors: 0→BUILD SUCCESSmvn -B verifywith nothing setcontextLoadserrors with the explicitDB_PASSWORDmessage (expected, fails fast)End-to-end flow against MySQL with
DB_PASSWORDset:(Seeded
role(0,'ROLE_USER')first. The app expects that row to exist.)Link to Devin session: https://app.devin.ai/sessions/433572ebc8644182ba2fd6afcb1285e5
Open in Devin Desktop: https://app.devin.ai/desktop/session/433572ebc8644182ba2fd6afcb1285e5?variant=devin
Requested by: @patrickbradley-cog
Devin Review