oidc: check for nil signing key on rotation#13716
Conversation
|
Logs |
- bypass setting ExpireAt if signing key is nil in rotate - return err if singing key is nil in signPayload
calvn
left a comment
There was a problem hiding this comment.
Mostly minor nit, but otherwise looks good!
vault/identity_store_oidc_test.go
Outdated
|
|
||
| // measure collected samples | ||
| for i := range testSet.testCases { | ||
| for i, cycle := range testSet.cycle { |
There was a problem hiding this comment.
NIt: cycle could be an int since it's just used as a counter length reference. You could have something like:
for i := 0; i < cycle; i++ {
currentCycle := cycle + 1
...
}
The for loop above could be reworked to be something similar as well.
| }, | ||
| { | ||
| // don't set SigningKey to ensure its non-existence can be handled | ||
| namedKey: &namedKey{ |
There was a problem hiding this comment.
Nit: I wonder if it would be a bit more obvious that the cases are based on different toggles if we had a test helper that generated the named keys with setSigningKey and setNextSigningKey` as params (which would also remove them from the testSet struct):
namedKey: testGenerateNamedKey("test-key-nil-signing-key", false, true)
There was a problem hiding this comment.
I think the namedKey would need to be removed from the testSet instead since we need to call generateAndSetKey with the storage for each test set. I can create an issue to track cleaning up these tests a bit.
Description
Check for a nil signing key before performing a rotation and before signing payloads. This is to prevent panics in the event that a nil signing key was written to storage.
If the current signing key is nil during rotation, we will skip setting the ExpireAt and allow the next signing key to be rotated into the current. If the signing key is nil during sign payload, we will return an error.
Background
A panic can occur for any key which was created while being on a version < v1.9.0 but was rotated while being on v1.9.0.
Repro steps: