Improving performance using cache for remote validation
This recipe will show how to improve the performance of the Resource Server when it has to remotely validate access tokens. To help on performance, we will use a cache strategy to avoid making requests to/oauth/check_token
every time an OAuth's protected resource is requested.
Getting ready
This recipe is an improvement on the previous recipe that we will create a new Resource Server which will cache issued access tokens. So to run this recipe, we need the application remote-authserver
created for the Remote validation using token introspection recipe. This recipe will rely on Redis for cache, the MySQL database, and will be developed using Java 8 with Spring Boot.
How to do it...
Follow the next steps to improve the performance of a Resource Server that uses RemoteTokenValidation
to check for access token validity with Spring Security OAuth2:
- You can just copy the
remote-resource
application created for the Remote Validation using token introspection...