From ee04f39e28ef6895665f71a00a94dc73bb90ad1e Mon Sep 17 00:00:00 2001 From: "gcp-cherry-pick-bot[bot]" <98988430+gcp-cherry-pick-bot[bot]@users.noreply.github.com> Date: Wed, 11 Sep 2024 13:22:01 +0000 Subject: [PATCH] enterprise: fix API mixin license validity check (cherry-pick #11331) (#11342) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marc 'risson' Schmitt Co-authored-by: Simonyi Gergő <28359278+gergosimonyi@users.noreply.github.com> Co-authored-by: Jens Langhammer fix API mixin license validity check (#11331) --- authentik/enterprise/api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/authentik/enterprise/api.py b/authentik/enterprise/api.py index 5cfc5c3fc5..bdacbcba5d 100644 --- a/authentik/enterprise/api.py +++ b/authentik/enterprise/api.py @@ -18,7 +18,7 @@ from authentik.core.api.used_by import UsedByMixin from authentik.core.api.utils import ModelSerializer, PassiveSerializer from authentik.core.models import User, UserTypes from authentik.enterprise.license import LicenseKey, LicenseSummarySerializer -from authentik.enterprise.models import License, LicenseUsageStatus +from authentik.enterprise.models import License from authentik.rbac.decorators import permission_required from authentik.tenants.utils import get_unique_identifier @@ -29,7 +29,7 @@ class EnterpriseRequiredMixin: def validate(self, attrs: dict) -> dict: """Check that a valid license exists""" - if LicenseKey.cached_summary().status != LicenseUsageStatus.UNLICENSED: + if not LicenseKey.cached_summary().status.is_valid: raise ValidationError(_("Enterprise is required to create/update this object.")) return super().validate(attrs)