25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

17 lines
493 B

  1. from django.conf import settings
  2. from django.http import HttpResponseForbidden
  3. from django.utils.deprecation import MiddlewareMixin
  4. class Public(MiddlewareMixin):
  5. acceptable_paths = (
  6. "/api/v2/profile/",
  7. )
  8. def process_request(self, request):
  9. if settings.PUBLIC is False and not request.user.is_authenticated:
  10. for path in self.acceptable_paths:
  11. if not request.path.startswith(path):
  12. return HttpResponseForbidden()