Adding a cache layer for OAuth2 token validation in REST API #7342
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adding a cache layer in Product REST APIs' OAuth2 token validations. It consists of two caches:
The summary of the flow:
The token is checked in TokenCache and if it exists validation info is taken from there, check the expiry and continues.
If not, the token is checked in InvalidTokenCache for invalid tokens.
If token doesn't exist in both, normal key validation DB call goes. (this doesn't include a n/w call)
Scope validation is not cached here. It is comparatively low cost operation because the retrieval of URITemplates/scope information is already cached. For the REST of the stuff, it will have a
for loop
for iterating and validating scopes which is not a costly operation.By default, the cache expiry is set to 300s (5mins). To change this, set below in deployment.toml.
It will add below configs in
api-manager.xml
underCacheConfigurations
upon server start.