Repository navigation
fix(account): refresh stored provider credentials on re-registration; stop logging them at INFO - #37
Merged
Merged
Conversation
… stop logging them at INFO At every start, the configured providers are registered on their accounts (`RegisterAccountWithProvider`). For an account that already had a client for the provider, only the client API key (a hash of the provider key) was updated: the stored provider, and with it the provider API key that every provider call uses, was kept. A rotated provider key therefore never reached the provider calls, while the refreshed client API key suggested it had. The existing client now takes the provider of the registration and keeps its own settings (name, contact emails, address, access token). The rule lives in `SoftPayClientRegistration.registeredClient`, covered by a unit test. `PaymentGuardian.registerProvidersAccount` also logged the whole registered account at INFO, whose `toString` prints each client's provider API key in clear at every start. It now logs only the client id. Version 0.9.13. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #37 +/- ##
==========================================
+ Coverage 40.82% 40.85% +0.02%
==========================================
Files 155 155
Lines 10924 10925 +1
Branches 1660 1789 +129
==========================================
+ Hits 4460 4463 +3
+ Misses 6464 6462 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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
Two fixes around the payment provider credentials:
Version 0.9.13.
Re-registration refreshes the provider credentials
At every start, the configured providers are registered on their accounts (
RegisterAccountWithProvider). When the account already held a client for that provider, the handler only refreshed the client API key, which is a hash of the provider key. It kept the stored provider, and with it the provider API key that every provider call uses. After a key rotation (same provider id, new key), every provider call therefore kept using the old key, while the refreshed client API key suggested the rotation had been applied.The existing client now takes the provider of the registration and keeps its own settings: name, contact emails, address and access token. Its
clientIdis unchanged, so account keys and webhook hashes don't move.The rule lives in
SoftPayClientRegistration.registeredClient, a pure function the behavior calls, so it can be unit-tested without an actor system.The startup log no longer prints the provider API key
PaymentGuardian.registerProvidersAccountlogged the whole registered account at INFO (Registered provider account for <id>: $account). The account'stoStringincludes each client's provider, and therefore the provider API key, in clear, at every start. The line now logs only the client id.The persistence library still logs every command and event at DEBUG, and these include the provider. Keep DEBUG off for the account entities in production.
Release note
Versions up to 0.9.12 logged the provider API keys at INFO on every start, so retained logs may contain them. Rotate the provider keys after upgrading to 0.9.13. The first fix above is what makes a rotated key take effect.
Test plan
SoftPayClientRegistrationSpec(3 tests):scalafmtSbtCheck scalafmtCheck Test/scalafmtCheck: clean.+ Test/compile: compiles on Scala 2.12 and 2.13.🤖 Generated with Claude Code