micro-auth-request is a tiny service that helps you to decouple the authentication from the services behind reverse proxy or ingress. It's mainly designed to be used by Nginx or nginx-ingress (for Kubernetes) as reverse-proxy and Google as the authentication provider but you can also use it with other reverse proxies like Traefik for your microservices or monolith.
The first time that unauthenticated request comes in:
After that each request gets authenticated using the previously-stored JWT token:
nginx auth_request implements client authorization based on the result of a subrequest. The procedure is fairly simple, for any income request, nginx redirect the header of that request to micro-auth-request, based on the request headers (token, cookie, ...), it makes decistion if the user is authenticate or not. The original request will pass to the original service only if micro-auth-request return 200 to nginx. If authentication is required, micro-auth-request helps to use google for it and manage the procedure automatically.
There are many ways to run micro-auth-request in your production environment.
GOOGLE_CLIENT_ID=<YOUR_CLIENT_ID> GOOGLE_CLIENT_SECRET=<YOUR_CLIENT_SECRET> npx micro-auth-request
docker run -d -e OOGLE_CLIENT_ID=<YOUR_CLIENT_ID> -e GOOGLE_CLIENT_SECRET=<YOUR_CLIENT_SECRET> -p 8080:8080 abdollahpour/micro-auth-request
Or if you are using kubernetes, using HELM:
helm repo add micro-auth-request 'https://raw.githubusercontent.com/abdollahpour/micro-auth-request-helm/master/' helm repo update helm install \ --set google.clinet_id=<YOUR_CLIENT_ID> \ --set google.clinet_secret=<YOUR_CLIENT_SECRET> \ --set ingress.enable=true \ --set ingress.hosts=yourdomain.com \ micro-auth-request micro-auth-request
for more information please visit the helm chart.
Using micro-auth-request you can cover four scenarios:
Check the example directory for more information.
If you want to enrich the user info (add roles for example), you can edit
src/controller/redirect and easily fetch more information from another service of the database.
If you need another authentication provider rather than Google, implement a new one. Copy
src/service/google.js and use if as boilerplate for your own service. Then switch to it on
You need to use this service over SSL and add HSTS headers. If you use our helm chart, you'll get them all by default but if you have your own setup you need to handle them on the reverse-proxy/ingress.
Add SCIM protocol support to fetch user details
🧺 A practical store microservices sample, built with Golang, Domain-Driven Design, CQRS, Event Sourcing, Vertical Slice Architecture, Event-Driven Architecture, and the latest technologies.
Booking Modular Monolith is a Sample application for booking ticket. This application based on different software architecture and technologies like .Net Core, CQRS, DDD, Vertical Slice Architecture, Docker, kubernetes, cap, Grpc, Identity Server, Redis,...
Booking Microservices is a Sample application for booking ticket. This application based on different software architecture and technologies like .Net Core, CQRS, DDD, Vertical Slice Architecture, Docker, kubernetes, tye, masstransit, RabbitMQ, Grpc, yarp...
A curated list of awesome articles and resources for learning and practicing Go and its related technologies.
A curated list of awesome articles, videos, and other resources to learn and practice software architecture, patterns, and principles.
Curated list of awesome tips and tricks, resources, videos and articles in .net, software architecture, microservice and cloud-native
Fearless refactoring, it does a lot of smart checks to find certain errors.
a simple blog and otp Authentication with django rest framework