forked from CGM_Public/pretix_original
Device security profiles: Improve logging
This commit is contained in:
@@ -19,9 +19,12 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License along with this program. If not, see
|
# You should have received a copy of the GNU Affero General Public License along with this program. If not, see
|
||||||
# <https://www.gnu.org/licenses/>.
|
# <https://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
import logging
|
||||||
|
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class FullAccessSecurityProfile:
|
class FullAccessSecurityProfile:
|
||||||
identifier = 'full'
|
identifier = 'full'
|
||||||
@@ -36,7 +39,13 @@ class AllowListSecurityProfile:
|
|||||||
|
|
||||||
def is_allowed(self, request):
|
def is_allowed(self, request):
|
||||||
key = (request.method, f"{request.resolver_match.namespace}:{request.resolver_match.url_name}")
|
key = (request.method, f"{request.resolver_match.namespace}:{request.resolver_match.url_name}")
|
||||||
return key in self.allowlist
|
if key in self.allowlist:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
logger.info(
|
||||||
|
f'Request {key} not allowed in profile {self.identifier}'
|
||||||
|
)
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
class PretixScanSecurityProfile(AllowListSecurityProfile):
|
class PretixScanSecurityProfile(AllowListSecurityProfile):
|
||||||
|
|||||||
Reference in New Issue
Block a user