Repository navigation
fix(appauth): [OCISDEV-1570] key app passwords by a stable user id, migrate old keys on load - #777
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
… on load The json app auth manager stored the app passwords of each user under UserId.String(). That is the protobuf text format. Protobuf-go changes its whitespace between builds. After an upgrade, the manager did not find the stored app passwords, and every app password failed with "password not found". - Store the app passwords under the key "<idp>|<opaque id>". - Move the buckets with the old keys to the new key once, in New(). - Merge buckets of one user that differ only in whitespace. The stable bucket wins on a conflict. - Keep keys that are not a user id. Save the file only when a key changed. Co-authored-by: Paul Faure <[email protected]> Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
d290117 to
6f38083
Compare
|
The code looks fine, but there are some conceptual problems:
If we can't invest time for a proper migration workflow (also including all the possible services, not just this one), it might be better to move the code to a cli command so the admins can execute it only once when they want, as I suggested in #755 (comment) |
Given the current architecture of the app-auth, this doesn't really matter, because the file is loaded in its entirety at the start of the application anyway, and one iteration over the map shouldn't take too long. |
| // protobuf-go varies its whitespace between binaries, so the same user gets a | ||
| // different key after a rebuild and loses access to the stored app passwords. | ||
| func userKey(id *userpb.UserId) string { | ||
| return id.GetIdp() + "|" + id.GetOpaqueId() |
There was a problem hiding this comment.
Should we include a prefix so the new keys are easily identified later? Something like "kv90"
There was a problem hiding this comment.
Given the lifetime of the keys and any number of keys can be created for a user at any time, I don’t think this is critical.
…rate old keys on load (#779) Backport of #777 to stable-8.2. The json app auth manager stored the app passwords of each user under UserId.String(). Protobuf-go changes the whitespace of that text between builds. After an upgrade, the manager did not find the stored app passwords. - Store the app passwords under the key "<idp>|<opaque id>". - Move the buckets with the old keys to the new key once, in New(). Co-authored-by: Claude Sonnet 5.5 <[email protected]>
Problem
The json app auth manager in
pkg/appauth/manager/json/json.gostored the app passwords of each user underUserId.String().That is the protobuf text format.
Protobuf-go changes its whitespace between builds.
After an upgrade, the manager does not find the stored app passwords.
Every request with an existing app password fails with
password not found.Changes
userKey(id)returns<idp>|<opaque id>. It replaces everyUserId.String()lookup.migrateLegacyKeys()runs once inNew().New()saves the file only when a key changed, or when the purge of expired tokens runs. A failed save is not fatal. The next start repeats the migration.Tests
userKey(...).pkg/appauth/manager/json/json_migrate_test.go:{}andnullload as an empty state.go test -race ./pkg/appauth/...passes.Notes
userKeyignores the user type. Callers can pass the same user with a different type.Changelog:
changelog/unreleased/bugfix-appauth-stable-user-key.md🤖 Generated with Claude Code