revert reputation expiry migration

Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
This commit is contained in:
Marc 'risson' Schmitt 2023-11-21 18:43:23 +01:00
parent 89aa6539b2
commit 9f22ee95cc
No known key found for this signature in database
GPG Key ID: 9C3FA22FABF1AA8D
7 changed files with 6 additions and 43 deletions

View File

@ -99,6 +99,9 @@ ldap:
tls:
ciphers: null
reputation:
expiry: 86400
cookie_domain: null
disable_update_check: false
disable_startup_analytics: false

View File

@ -11,12 +11,11 @@ from rest_framework.serializers import BaseSerializer
from structlog import get_logger
from authentik.core.models import ExpiringModel
from authentik.lib.config import CONFIG
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()
CACHE_KEY_PREFIX = "goauthentik.io/policies/reputation/scores/"
@ -24,8 +23,7 @@ CACHE_KEY_PREFIX = "goauthentik.io/policies/reputation/scores/"
def reputation_expiry():
"""Reputation expiry"""
tenant = get_current_tenant() or Tenant() # Needed if we are running in a migration
return now() + timedelta(seconds=tenant.reputation_expiry)
return now() + timedelta(seconds=CONFIG.get_int("reputation.expiry"))
class ReputationPolicy(Policy):

View File

@ -98,7 +98,6 @@ class SettingsSerializer(ModelSerializer):
"gdpr_compliance",
"impersonation",
"footer_links",
"reputation_expiry",
]

View File

@ -24,7 +24,6 @@ def create_default_tenant(apps, schema_editor):
gdpr_compliance=CONFIG.get_bool("gdpr_compliance", True),
impersonation=CONFIG.get_bool("impersonation", True),
footer_links=CONFIG.get("footer_links", default=[]),
reputation_expiry=CONFIG.get_int("reputation_expiry", default=86400),
)
Domain = apps.get_model("authentik_tenants", "Domain")
@ -105,13 +104,6 @@ class Migration(migrations.Migration):
help_text="The option configures the footer links on the flow executor pages.",
),
),
(
"reputation_expiry",
models.PositiveBigIntegerField(
default=86400,
help_text="Configure how long reputation scores should be saved for in seconds.",
),
),
],
options={
"verbose_name": "Tenant",

View File

@ -54,10 +54,6 @@ class Tenant(TenantMixin, SerializerModel):
default=list,
blank=True,
)
reputation_expiry = models.PositiveBigIntegerField(
help_text=_("Configure how long reputation scores should be saved for in seconds."),
default=86400,
)
def save(self, *args, **kwargs):
if self.schema_name == "template":

View File

@ -1,13 +1,9 @@
"""Tenant utils"""
from django.db import connection
from django.db.utils import ProgrammingError
from authentik.tenants.models import Tenant
def get_current_tenant() -> Tenant | None:
"""Get tenant for current request"""
try:
return Tenant.objects.filter(schema_name=connection.schema_name).first()
except ProgrammingError: # We're inside a migration and this table doesn't exist yet
return None
return Tenant.objects.get(schema_name=connection.schema_name)

View File

@ -38447,13 +38447,6 @@ components:
additionalProperties: {}
description: The option configures the footer links on the flow executor
pages.
reputation_expiry:
type: integer
maximum: 9223372036854775807
minimum: 0
format: int64
description: Configure how long reputation scores should be saved for in
seconds.
PatchedStaticDeviceRequest:
type: object
description: Serializer for static authenticator devices
@ -41362,13 +41355,6 @@ components:
additionalProperties: {}
description: The option configures the footer links on the flow executor
pages.
reputation_expiry:
type: integer
maximum: 9223372036854775807
minimum: 0
format: int64
description: Configure how long reputation scores should be saved for in
seconds.
required:
- domains
- name
@ -41402,13 +41388,6 @@ components:
additionalProperties: {}
description: The option configures the footer links on the flow executor
pages.
reputation_expiry:
type: integer
maximum: 9223372036854775807
minimum: 0
format: int64
description: Configure how long reputation scores should be saved for in
seconds.
SeverityEnum:
enum:
- notice