Phase 9, part 4: secrets in the database, encrypted
The server and multi-tenant editions keep keys and tokens in a secrets table (schema 30, the first migration for both databases), each sealed with AES-256-GCM under a key derived from SUPERMARKET_SECRET_KEY and bound to its name. A wrong key stops the start with a clear message; SUPERMARKET_SECRET_KEY_OLD reseals everything under a new key. Values are read when asked for, so several copies of the app agree on a refreshed token. The local edition keeps secrets.json. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -41,6 +41,9 @@ func newTestServer(t *testing.T, c *core.Core) (*Server, http.Handler) {
|
||||
}
|
||||
t.Cleanup(func() { d.Close() })
|
||||
sec, err := secrets.Open(filepath.Join(dir, "secrets.json"))
|
||||
if db.OnPostgres() { // as the server edition keeps them
|
||||
sec, err = secrets.OpenDB(d, []byte("0123456789abcdef0123456789abcdef"), nil)
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user