Spring / Spring CredHub Interview questions
How can you design a credential rotation strategy using Spring CredHub's regenerate operation?
A workable rotation strategy leans on three things CredHub already gives you: generated (not written) credentials, version history, and permission scoping — combined with a schedule your app controls.
- Generate, don't write. Only credentials created with
generate()remember their parameters and can be rotated with a singleregenerate()call later. - Trigger regeneration on a schedule. A Spring
@Scheduledjob (or an external rotation trigger) calls the credentials operations'regenerate()method at whatever cadence your security policy requires. - Overlap old and new briefly. Because the previous value is retained in history, consumers can tolerate a short window where either the old or new value is valid — important for anything with connection pools that don't reconnect instantly, like a database password.
- Scope permissions tightly. Only the actor performing rotation needs
WRITE; consuming apps only needREAD, ideally granted per-actor through V2 permissions so a compromised consumer can't rotate credentials it merely reads.
The main pitfall to design around is that regeneration doesn't notify consumers — an app holding a cached value has no idea it just went stale. Pairing rotation with either a short cache TTL or an explicit refresh signal, such as a config-refresh event, is what actually closes the loop, since CredHub's job ends at "the value changed," not "everyone who cares now knows."
More Related questions...