When trying to create a Django Rest Framework based web app, we encountered the following problem: Our whole app should and is protected by our settings.py:
REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.IsAuthenticated',
),
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
'rest_framework.authentication.SessionAuthentication'
),
But for one single route (which provides the schema for the front end code generation) we would like to have basic auth (test:test@host/special_route). The idea was to add the route to nginx like here. Our nginx conf looks as follows:
server {
...
location /special_route {
auth_basic "API Schema";
auth_basic_user_file /etc/nginx/.htpasswd;
}
}
Now when accessing this route the authentication popup shows and the password and username are validated, but on success it shows 404. When deleting this piece of code it shows up without the 404, so I am guessing it's not a Django problem.
I tried adding basic authentication to the auth classes, reloading and restarting the server and changing the special_route to avoid misspells. I even experimentally deleted the location and applied the config to the whole server, which worked as expected.
special_routesome part of your django app? In yourlocationblock there is noproxy_passor similar directive, perhaps you left that out? Its a little difficult to understand what you want to happen.