Use authentication.RemoteUserAuthentication when EXTERNAL_AUTH defined

Change-Id: I0ab7f62bfcd2ac3d274aa4016c5debfae7f704b0
Related: https://github.com/ansible-community/ara/issues/123
Depends-On: https://review.opendev.org/#/c/746145
This commit is contained in:
Michal Arbet 2020-08-13 15:56:53 +02:00
parent a19e98620a
commit d5ed9d90b1

View File

@ -223,6 +223,12 @@ ROOT_URLCONF = "ara.server.urls"
APPEND_SLASH = False
PAGE_SIZE = settings.get("PAGE_SIZE", 100)
if EXTERNAL_AUTH:
REST_FRAMEWORK_AUTH = ("rest_framework.authentication.RemoteUserAuthentication",)
else:
REST_FRAMEWORK_AUTH = ("rest_framework.authentication.BasicAuthentication",)
REST_FRAMEWORK = {
"DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.LimitOffsetPagination",
"PAGE_SIZE": PAGE_SIZE,
@ -236,7 +242,7 @@ REST_FRAMEWORK = {
"rest_framework.parsers.FormParser",
"rest_framework.parsers.MultiPartParser",
),
"DEFAULT_AUTHENTICATION_CLASSES": ("rest_framework.authentication.BasicAuthentication",),
"DEFAULT_AUTHENTICATION_CLASSES": REST_FRAMEWORK_AUTH,
"DEFAULT_PERMISSION_CLASSES": ("ara.api.auth.APIAccessPermission",),
"TEST_REQUEST_DEFAULT_FORMAT": "json",
"UNICODE_JSON": False,