-
Notifications
You must be signed in to change notification settings - Fork 143
Description
Is your feature request related to a problem? Please describe.
I'd like the ability to more easily rotate keys by being able to add a list of valid decryption keys.
Describe the solution you'd like
Change
New(hashKey, blockKey []byte)to
New(hashKey, blockKey []byte, decodeKeys ...[]byte)and add a check that if a cookie cannot be decoded with the hashKey to try with the decode keys until one matches or all fail. This would allow users to have some logic like
New(todaysKey(), nil, tomorrowsKey(), yesterdaysKey())and rotate keys automatically even in a distributed environment. It would also preserve backwards compatibility withNew(hashKey, nil).
Describe alternatives you've considered
There's the obvious, just don't rotate the keys. Or coordinate a failover mechanism by chaining decodes using multiple secure cookies. This seems like a more straightforward approach however.