
Auth is performed via basic auth, create a user in the admin if you want to get access. Change-Id: Ie6a4f7e440387b4472661284408213872f453473
27 lines
1.1 KiB
Python
27 lines
1.1 KiB
Python
# Copyright (c) 2019 Red Hat, Inc.
|
|
#
|
|
# This file is part of ARA Records Ansible.
|
|
#
|
|
# ARA is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# ARA is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with ARA. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
from django.conf import settings
|
|
from rest_framework import permissions
|
|
|
|
|
|
class APIAccessPermission(permissions.BasePermission):
|
|
def has_permission(self, request, view):
|
|
if request.method in permissions.SAFE_METHODS:
|
|
return request.user.is_authenticated if settings.READ_LOGIN_REQUIRED else True
|
|
return request.user.is_authenticated if settings.WRITE_LOGIN_REQUIRED else True
|