title: Django - How to implement authentication service in microservices architecture
body: <p>Basically, I have several independent services. I want to build a service for authentication. When client get a token from authentication service. Client use it for further request to others services. Client need to attach that token in header of request. The services receiving token need to verify the token by sending it to authentication server. So all requests that clients make to protected routes need to be verified by authentication service. The thing is I do not know the best place to put the code that automatically sends token to authentication service and receive the result. 
  Here is what i tried so far:
  I implemented a middleware like that:</p>
  
  <pre><code>class VerifyTokenMiddleware(object):
  
  def process_request(self, request):
      if not request.META.get('HTTP_AUTHORIZATION'):
          return HttpResponse(status=404)
      auth_header = request.META.get('HTTP_AUTHORIZATION')
      token = auth_header[4:]
      response = requests.post(AUTH_URL, {"token": token})
      if response.status_code == 400:
          return HttpResponse(status=403)
      return None
  </code></pre>
  
  <p>However, the problem of my solution is every requests to services(not auth service) have to pass through that middleware. Therefore, client cannot access unprotected routes like before. 
  Any help is extremely appreciated. :D</p>
  
  <p>I used django restframework jwt <a href="https://github.com/GetBlimp/django-rest-framework-jwt" rel="noreferrer">https://github.com/GetBlimp/django-rest-framework-jwt</a>. </p>