fix tests and lint
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
parent
8797b6309f
commit
63fea84405
|
@ -169,6 +169,7 @@ class License(SerializerModel):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def non_expired(cls) -> QuerySet["License"]:
|
def non_expired(cls) -> QuerySet["License"]:
|
||||||
|
"""Filter all non expired licenses"""
|
||||||
return License.objects.filter(expiry__gte=now())
|
return License.objects.filter(expiry__gte=now())
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -8,8 +8,8 @@ from grpc import (
|
||||||
UnaryUnaryClientInterceptor,
|
UnaryUnaryClientInterceptor,
|
||||||
insecure_channel,
|
insecure_channel,
|
||||||
intercept_channel,
|
intercept_channel,
|
||||||
ssl_channel_credentials,
|
|
||||||
secure_channel,
|
secure_channel,
|
||||||
|
ssl_channel_credentials,
|
||||||
)
|
)
|
||||||
from grpc._interceptor import _ClientCallDetails
|
from grpc._interceptor import _ClientCallDetails
|
||||||
|
|
||||||
|
@ -58,10 +58,10 @@ def get_enterprise_token() -> str:
|
||||||
try:
|
try:
|
||||||
from authentik.enterprise.models import License
|
from authentik.enterprise.models import License
|
||||||
|
|
||||||
license = License.non_expired().order_by("-expiry").first()
|
valid_license = License.non_expired().order_by("-expiry").first()
|
||||||
if not license:
|
if not valid_license:
|
||||||
return get_install_id()
|
return get_install_id()
|
||||||
return license.key
|
return valid_license.key
|
||||||
except ImportError:
|
except ImportError:
|
||||||
return get_install_id()
|
return get_install_id()
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@ from django.http import HttpRequest
|
||||||
from django.utils.translation import gettext as __
|
from django.utils.translation import gettext as __
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from django.views import View
|
from django.views import View
|
||||||
from grpc import RpcError
|
|
||||||
from rest_framework.serializers import BaseSerializer, Serializer
|
from rest_framework.serializers import BaseSerializer, Serializer
|
||||||
from structlog.stdlib import get_logger
|
from structlog.stdlib import get_logger
|
||||||
|
|
||||||
|
@ -201,8 +200,6 @@ class MobileTransaction(ExpiringModel):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
LOGGER.debug("Sent notification", id=response, tx_id=self.tx_id)
|
LOGGER.debug("Sent notification", id=response, tx_id=self.tx_id)
|
||||||
except RpcError as exc:
|
|
||||||
LOGGER.warning("failed to push", exc=exc, code=exc.code(), tx_id=self.tx_id)
|
|
||||||
except ValueError as exc:
|
except ValueError as exc:
|
||||||
LOGGER.warning("failed to push", exc=exc, tx_id=self.tx_id)
|
LOGGER.warning("failed to push", exc=exc, tx_id=self.tx_id)
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
"""Mobile stage"""
|
"""Mobile stage"""
|
||||||
|
from django.conf import settings
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from rest_framework.fields import CharField
|
from rest_framework.fields import CharField
|
||||||
from django.conf import settings
|
|
||||||
from authentik.core.api.utils import PassiveSerializer
|
from authentik.core.api.utils import PassiveSerializer
|
||||||
from authentik.flows.challenge import (
|
from authentik.flows.challenge import (
|
||||||
Challenge,
|
Challenge,
|
||||||
|
|
|
@ -130,8 +130,7 @@ class AuthenticatorValidationChallengeResponse(ChallengeResponse):
|
||||||
device = MobileDevice.objects.filter(pk=challenge.get("device_uid")).first()
|
device = MobileDevice.objects.filter(pk=challenge.get("device_uid")).first()
|
||||||
case "sms":
|
case "sms":
|
||||||
device = SMSDevice.objects.filter(pk=int(challenge.get("device_uid"))).first()
|
device = SMSDevice.objects.filter(pk=int(challenge.get("device_uid"))).first()
|
||||||
if not device:
|
if device:
|
||||||
raise ValidationError("invalid challenge selected")
|
|
||||||
select_challenge(self.stage.request, self.stage, device)
|
select_challenge(self.stage.request, self.stage, device)
|
||||||
return challenge
|
return challenge
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,9 @@ extension-pkg-whitelist = ["lxml", "xmlsec"]
|
||||||
# Allow constants to be shorter than normal (and lowercase, for settings.py)
|
# Allow constants to be shorter than normal (and lowercase, for settings.py)
|
||||||
const-rgx = "[a-zA-Z0-9_]{1,40}$"
|
const-rgx = "[a-zA-Z0-9_]{1,40}$"
|
||||||
|
|
||||||
ignored-modules = ["binascii", "socket", "zlib"]
|
ignored-modules = [
|
||||||
|
"authentik_cloud_gateway_client"
|
||||||
|
]
|
||||||
generated-members = ["xmlsec.constants.*", "xmlsec.tree.*", "xmlsec.template.*"]
|
generated-members = ["xmlsec.constants.*", "xmlsec.tree.*", "xmlsec.template.*"]
|
||||||
ignore = ["migrations", "tests"]
|
ignore = ["migrations", "tests"]
|
||||||
max-attributes = 12
|
max-attributes = 12
|
||||||
|
|
Reference in a new issue