forked from CGM_Public/pretix_original
API: Log ID of revoked device connection
This commit is contained in:
@@ -19,6 +19,8 @@
|
|||||||
# 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.contrib.auth.models import AnonymousUser
|
from django.contrib.auth.models import AnonymousUser
|
||||||
from django_scopes import scopes_disabled
|
from django_scopes import scopes_disabled
|
||||||
from rest_framework import exceptions
|
from rest_framework import exceptions
|
||||||
@@ -29,6 +31,8 @@ from pretix.api.auth.devicesecurity import (
|
|||||||
)
|
)
|
||||||
from pretix.base.models import Device
|
from pretix.base.models import Device
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class DeviceTokenAuthentication(TokenAuthentication):
|
class DeviceTokenAuthentication(TokenAuthentication):
|
||||||
model = Device
|
model = Device
|
||||||
@@ -46,6 +50,7 @@ class DeviceTokenAuthentication(TokenAuthentication):
|
|||||||
raise exceptions.AuthenticationFailed('Device has not been initialized.')
|
raise exceptions.AuthenticationFailed('Device has not been initialized.')
|
||||||
|
|
||||||
if device.revoked:
|
if device.revoked:
|
||||||
|
logging.warning(f'Connection attempt of revoked device {device.pk}.')
|
||||||
raise exceptions.AuthenticationFailed('Device access has been revoked.')
|
raise exceptions.AuthenticationFailed('Device access has been revoked.')
|
||||||
|
|
||||||
return AnonymousUser(), device
|
return AnonymousUser(), device
|
||||||
|
|||||||
Reference in New Issue
Block a user