fix migrations for template schema
Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
This commit is contained in:
parent
742dc12656
commit
a5cc3c36ed
|
@ -15,6 +15,7 @@ from authentik.lib.models import SerializerModel
|
|||
from authentik.lib.utils.http import get_client_ip
|
||||
from authentik.policies.models import Policy
|
||||
from authentik.policies.types import PolicyRequest, PolicyResult
|
||||
from authentik.tenants.models import Tenant
|
||||
from authentik.tenants.utils import get_current_tenant
|
||||
|
||||
LOGGER = get_logger()
|
||||
|
@ -23,7 +24,8 @@ CACHE_KEY_PREFIX = "goauthentik.io/policies/reputation/scores/"
|
|||
|
||||
def reputation_expiry():
|
||||
"""Reputation expiry"""
|
||||
return now() + timedelta(seconds=get_current_tenant().reputation_expiry)
|
||||
tenant = get_current_tenant() or Tenant() # Needed if we are running in a migration
|
||||
return now() + timedelta(seconds=tenant.reputation_expiry)
|
||||
|
||||
|
||||
class ReputationPolicy(Policy):
|
||||
|
|
|
@ -4,6 +4,6 @@ from django.db import connection
|
|||
from authentik.tenants.models import Tenant
|
||||
|
||||
|
||||
def get_current_tenant() -> Tenant:
|
||||
def get_current_tenant() -> Tenant | None:
|
||||
"""Get tenant for current request"""
|
||||
return Tenant.objects.get(schema_name=connection.schema_name)
|
||||
return Tenant.objects.filter(schema_name=connection.schema_name).first()
|
||||
|
|
Reference in New Issue