Skip to content

Decrypt source credentials even when the converter is not injected - #2544

Merged
p-hoffmann merged 2 commits into
webapi-3.0from
p-hoffmann/encrypted-converter-static-encryptor
Sep 24, 2026
Merged

p-hoffmann merged 2 commits into
webapi-3.0from
p-hoffmann/encrypted-converter-static-encryptor

Conversation

@p-hoffmann

@p-hoffmann p-hoffmann commented Sep 14, 2026 •

Copy link
Copy Markdown
Member

No description provided.

EncryptedStringConverter received its encryptor only through an @Autowired
setter, relying on Hibernate resolving the converter from Spring. When that
injection does not happen, as in the GraalVM native image, the encryptor stays
null and EncryptorUtils.decrypt returns the value unchanged, so the JDBC driver
is handed the literal ENC(...) username and password and every source query
fails with "password authentication failed".

The encryptor is now held statically and set directly by the
defaultStringEncryptor bean, so every converter instance sees it however it was
created. A converter used without an encryptor now fails instead of silently
reading ENC(...) values or writing plaintext.
@p-hoffmann
p-hoffmann marked this pull request as draft September 14, 2026 19:57
p-hoffmann added a commit to OHDSI/trex that referenced this pull request Sep 16, 2026
…ter injection

The native image runs Spring in AOT mode, which registers no
AutowiredAnnotationBeanPostProcessor. Hibernate's SpringBeanContainer creates
EncryptedStringConverter at runtime via createBean, so its @Autowired
encryptor setter never ran and ENC(...) credentials reached the JDBC driver
unchanged. OHDSI/WebAPI#2544 has the defaultStringEncryptor bean set the
encryptor statically on the converter.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
p-hoffmann added a commit to OHDSI/trex that referenced this pull request Sep 16, 2026
…ter injection

The native image runs Spring in AOT mode, which registers no
AutowiredAnnotationBeanPostProcessor. Hibernate's SpringBeanContainer creates
EncryptedStringConverter at runtime via createBean, so its @Autowired
encryptor setter never ran and ENC(...) credentials reached the JDBC driver
unchanged. OHDSI/WebAPI#2544 has the defaultStringEncryptor bean set the
encryptor statically on the converter.
p-hoffmann added a commit to OHDSI/trex that referenced this pull request Sep 24, 2026
The bump to the webapi-3.0 tip regressed the boot smoke test:

  SMOKE_DECRYPT=failed
  FAIL: CleanupScheduler could not reach a source with encrypted credentials
  FATAL: password authentication failed for user "ENC(OatX+nJuuK4p...)"

Cause: what develop pinned before this branch (f1612bee) is not on
webapi-3.0 at all. It sits on p-hoffmann/encrypted-converter-static-encryptor
(OHDSI/WebAPI#2544, still open) and carries "Decrypt source credentials even
when the converter is not injected" -- a fix the native image depends on,
because Hibernate builds the @converter itself, the @Autowired setter never
runs in a closed-world image, the encryptor stays null and ENC(...) reaches
the JDBC driver verbatim. Moving to the tip silently dropped it, which is
exactly what the smoke test is there to catch.

#2544 has now been updated from webapi-3.0 (merge f2533fe0), so its head is
the webapi-3.0 tip -- BigQuery driver swap and circe 1.14.1 included -- plus
that one fix. Pin there. Its diff against webapi-3.0 is only the three files
of the fix.

Re-pin to the webapi-3.0 tip once #2544 merges; until it does, every bump
straight to the tip reintroduces this failure.
@p-hoffmann
p-hoffmann marked this pull request as ready for review September 24, 2026 23:38
@p-hoffmann
p-hoffmann merged commit ba0f901 into webapi-3.0 Sep 24, 2026
6 checks passed
p-hoffmann added a commit to OHDSI/trex that referenced this pull request Sep 24, 2026
OHDSI/WebAPI#2544 landed on webapi-3.0 as ba0f901f, so the tip now carries
the decrypt fix the native image needs, and the submodule no longer has to
point at an unmerged branch head. Pin ba0f901f.

That tip is the previous pin's content by another route: webapi-3.0 through
circe 1.14.1, the BigQuery JDBC driver swap (#2547), and the converter fix
as a squash of #2544 rather than the merge this branch pinned.

This also retires the note the previous commit left behind: a bump straight
to the webapi-3.0 tip is now the correct thing to do, and no longer drops
the fix that made the boot smoke test fail with SMOKE_DECRYPT=failed.
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

Successfully merging this pull request may close these issues.

1 participant