I have an own OAuth2 provider where you can ask for a token and validate it. I want to protect my REST API (resource server) with OAuth2, so, in every single request, the access token must be validated, against OAuth2 server.
I have been doing this validation in the REST API code itself, by intercepting every request and doing another request to OAuth2 server.
I wonder if there is any way to do it in the Nginx server instead of in the REST API. This way, it would be easier to setup in another REST API, instead of copy/paste the code (or share a library).
Maybe, should I create my own nginx module? Or running an script in every request? If so, how can I do it?
Any advice will be appreciated.
Yes, you can use the auth-request module in nginx.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With