2012-08-01 21:30:18 +00:00
|
|
|
from django.conf import settings
|
2020-05-31 13:38:27 +08:00
|
|
|
from django.http import HttpResponseForbidden
|
2012-08-01 21:30:18 +00:00
|
|
|
|
|
|
|
|
|
2020-07-17 13:42:35 +08:00
|
|
|
class Public:
|
2019-02-22 17:40:02 +08:00
|
|
|
|
2020-05-31 13:38:27 +08:00
|
|
|
acceptable_paths = (
|
|
|
|
|
"/api/v2/profile/",
|
|
|
|
|
)
|
|
|
|
|
|
2020-07-17 13:42:35 +08:00
|
|
|
def __init__(self, get_response):
|
|
|
|
|
self.get_response = get_response
|
|
|
|
|
|
2012-08-01 21:30:18 +00:00
|
|
|
def process_request(self, request):
|
2019-02-22 17:40:02 +08:00
|
|
|
if settings.PUBLIC is False and not request.user.is_authenticated():
|
2020-05-31 13:38:27 +08:00
|
|
|
for path in self.acceptable_paths:
|
|
|
|
|
if not request.path.startswith(path):
|
|
|
|
|
return HttpResponseForbidden()
|