Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for supplying multiple public keys, in order to gracefully support certificate rotation #241

Open
wants to merge 24 commits into
base: master
Choose a base branch
from

Conversation

thepeachbeetle
Copy link

This is a simplified patch and supersedes the previously submitted PR (#240)

We have a requirement for multiple public key to be valid for a period of time whilst performing a certificate rotation. A rotation across the whole global infrastructure is a non atomic operation that can potentially take some time to roll out. During this time, client requests may be initiated using either the current 'old' key, or a new key that is being rolled out, until such a time as the new key is fully rolled out.

It is therefore desirable for the service receiving the requests to be able to validate signatures generated with either of those keys.

This change exposes via the SigningKeyResolver interface, the ability to supply either a single key (using the existing signatures) or a Collection of keys via the new methods added here. The remainder of the change should be transparent to the application, it is mainly plumbing to get the collection of keys to the various signature validator implementations and having them iterate over a list of possible keys untill one matches.

I appreciate that there would be further work needed to update the test suite, but i wanted to post this PR at this point first to get some feedback on this approach before going any further

… when validating a token signature

this facilitates the supporting of certificate rotation, and there being multiple valid keys available during a rotation cycle
…ttempted when validating a token signature"

This reverts commit ba3ae16.
This reverts commit e8ba619.
…gning key resolver

this allows existing subclasses of the SigningKeyResolverAdaptor to work un-modified with these changes
the new methods are only necessary to override if you wish to take advantage of the ability to supply a collection of keys
@coveralls
Copy link

Coverage Status

Coverage decreased (-2.6%) to 97.419% when pulling c1e9e9e on thepeachbeetle:attempt-1 into 8797f1d on jwtk:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.4%) to 99.633% when pulling ef42b0d on thepeachbeetle:attempt-1 into 8797f1d on jwtk:master.

@jcarvalho
Copy link

Isn't this behavior usually achieved using Key IDs? (kid field on the JWT header)

@thepeachbeetle
Copy link
Author

@jcarvalho Yes, whilst you could certainly do that, it is not often possible or practical to enforce upon the client that they specify the correct key id matching the key that they are using to sign. This adds a lot of complexty on both the client side and server side to manage an associated of keys to id's and potential for things to go wrong and be hard to diagnose.

The intent of this PR is to take away any of that complexity from a client, to simply give them a new key and say 'start using this as soon as possible, old key is valid until such a time', as long as the service validating the tokens is able to find all the currently valid public keys through its SigningKeyResover, then everything becomes simple and transparent

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 99.725% when pulling 2191bf8 on thepeachbeetle:attempt-1 into 8797f1d on jwtk:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 99.818% when pulling 25860fb on thepeachbeetle:attempt-1 into 8797f1d on jwtk:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.09%) to 99.909% when pulling 3affd83 on thepeachbeetle:attempt-1 into 8797f1d on jwtk:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling c1c25ba on thepeachbeetle:attempt-1 into 8797f1d on jwtk:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 1e22d8f on thepeachbeetle:attempt-1 into 8797f1d on jwtk:master.

…tion_Success test to address intermittent test failure
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling abde7e0 on thepeachbeetle:attempt-1 into 8797f1d on jwtk:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling aebb76f on thepeachbeetle:attempt-1 into 8797f1d on jwtk:master.

thepeachbeetle added 2 commits July 27, 2017 18:49
Merge pull request #2 from thepeachbeetle/master
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 7bb498f on thepeachbeetle:attempt-1 into 8797f1d on jwtk:master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants