Add initial middleware and configuration for blocking AI user agents
This commit is contained in:
16
ai_blocker/ualist_backers.py
Normal file
16
ai_blocker/ualist_backers.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
class UAList(ABC):
|
||||
|
||||
@abstractmethod
|
||||
def get_ua_list(self) -> list[str]:
|
||||
raise NotImplemented
|
||||
|
||||
|
||||
|
||||
class ConfigBackedUAList(UAList):
|
||||
def get_ua_list(self) -> list[str]:
|
||||
return list(getattr(getattr(settings, "AI_BLOCKER_CONF"), "ua_list", []))
|
||||
Reference in New Issue
Block a user