revert reputation expiry migration
Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
This commit is contained in:
parent
89aa6539b2
commit
9f22ee95cc
|
@ -99,6 +99,9 @@ ldap:
|
||||||
tls:
|
tls:
|
||||||
ciphers: null
|
ciphers: null
|
||||||
|
|
||||||
|
reputation:
|
||||||
|
expiry: 86400
|
||||||
|
|
||||||
cookie_domain: null
|
cookie_domain: null
|
||||||
disable_update_check: false
|
disable_update_check: false
|
||||||
disable_startup_analytics: false
|
disable_startup_analytics: false
|
||||||
|
|
|
@ -11,12 +11,11 @@ from rest_framework.serializers import BaseSerializer
|
||||||
from structlog import get_logger
|
from structlog import get_logger
|
||||||
|
|
||||||
from authentik.core.models import ExpiringModel
|
from authentik.core.models import ExpiringModel
|
||||||
|
from authentik.lib.config import CONFIG
|
||||||
from authentik.lib.models import SerializerModel
|
from authentik.lib.models import SerializerModel
|
||||||
from authentik.lib.utils.http import get_client_ip
|
from authentik.lib.utils.http import get_client_ip
|
||||||
from authentik.policies.models import Policy
|
from authentik.policies.models import Policy
|
||||||
from authentik.policies.types import PolicyRequest, PolicyResult
|
from authentik.policies.types import PolicyRequest, PolicyResult
|
||||||
from authentik.tenants.models import Tenant
|
|
||||||
from authentik.tenants.utils import get_current_tenant
|
|
||||||
|
|
||||||
LOGGER = get_logger()
|
LOGGER = get_logger()
|
||||||
CACHE_KEY_PREFIX = "goauthentik.io/policies/reputation/scores/"
|
CACHE_KEY_PREFIX = "goauthentik.io/policies/reputation/scores/"
|
||||||
|
@ -24,8 +23,7 @@ CACHE_KEY_PREFIX = "goauthentik.io/policies/reputation/scores/"
|
||||||
|
|
||||||
def reputation_expiry():
|
def reputation_expiry():
|
||||||
"""Reputation expiry"""
|
"""Reputation expiry"""
|
||||||
tenant = get_current_tenant() or Tenant() # Needed if we are running in a migration
|
return now() + timedelta(seconds=CONFIG.get_int("reputation.expiry"))
|
||||||
return now() + timedelta(seconds=tenant.reputation_expiry)
|
|
||||||
|
|
||||||
|
|
||||||
class ReputationPolicy(Policy):
|
class ReputationPolicy(Policy):
|
||||||
|
|
|
@ -98,7 +98,6 @@ class SettingsSerializer(ModelSerializer):
|
||||||
"gdpr_compliance",
|
"gdpr_compliance",
|
||||||
"impersonation",
|
"impersonation",
|
||||||
"footer_links",
|
"footer_links",
|
||||||
"reputation_expiry",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@ def create_default_tenant(apps, schema_editor):
|
||||||
gdpr_compliance=CONFIG.get_bool("gdpr_compliance", True),
|
gdpr_compliance=CONFIG.get_bool("gdpr_compliance", True),
|
||||||
impersonation=CONFIG.get_bool("impersonation", True),
|
impersonation=CONFIG.get_bool("impersonation", True),
|
||||||
footer_links=CONFIG.get("footer_links", default=[]),
|
footer_links=CONFIG.get("footer_links", default=[]),
|
||||||
reputation_expiry=CONFIG.get_int("reputation_expiry", default=86400),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
Domain = apps.get_model("authentik_tenants", "Domain")
|
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.",
|
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={
|
options={
|
||||||
"verbose_name": "Tenant",
|
"verbose_name": "Tenant",
|
||||||
|
|
|
@ -54,10 +54,6 @@ class Tenant(TenantMixin, SerializerModel):
|
||||||
default=list,
|
default=list,
|
||||||
blank=True,
|
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):
|
def save(self, *args, **kwargs):
|
||||||
if self.schema_name == "template":
|
if self.schema_name == "template":
|
||||||
|
|
|
@ -1,13 +1,9 @@
|
||||||
"""Tenant utils"""
|
"""Tenant utils"""
|
||||||
from django.db import connection
|
from django.db import connection
|
||||||
from django.db.utils import ProgrammingError
|
|
||||||
|
|
||||||
from authentik.tenants.models import Tenant
|
from authentik.tenants.models import Tenant
|
||||||
|
|
||||||
|
|
||||||
def get_current_tenant() -> Tenant | None:
|
def get_current_tenant() -> Tenant | None:
|
||||||
"""Get tenant for current request"""
|
"""Get tenant for current request"""
|
||||||
try:
|
return Tenant.objects.get(schema_name=connection.schema_name)
|
||||||
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
|
|
||||||
|
|
21
schema.yml
21
schema.yml
|
@ -38447,13 +38447,6 @@ components:
|
||||||
additionalProperties: {}
|
additionalProperties: {}
|
||||||
description: The option configures the footer links on the flow executor
|
description: The option configures the footer links on the flow executor
|
||||||
pages.
|
pages.
|
||||||
reputation_expiry:
|
|
||||||
type: integer
|
|
||||||
maximum: 9223372036854775807
|
|
||||||
minimum: 0
|
|
||||||
format: int64
|
|
||||||
description: Configure how long reputation scores should be saved for in
|
|
||||||
seconds.
|
|
||||||
PatchedStaticDeviceRequest:
|
PatchedStaticDeviceRequest:
|
||||||
type: object
|
type: object
|
||||||
description: Serializer for static authenticator devices
|
description: Serializer for static authenticator devices
|
||||||
|
@ -41362,13 +41355,6 @@ components:
|
||||||
additionalProperties: {}
|
additionalProperties: {}
|
||||||
description: The option configures the footer links on the flow executor
|
description: The option configures the footer links on the flow executor
|
||||||
pages.
|
pages.
|
||||||
reputation_expiry:
|
|
||||||
type: integer
|
|
||||||
maximum: 9223372036854775807
|
|
||||||
minimum: 0
|
|
||||||
format: int64
|
|
||||||
description: Configure how long reputation scores should be saved for in
|
|
||||||
seconds.
|
|
||||||
required:
|
required:
|
||||||
- domains
|
- domains
|
||||||
- name
|
- name
|
||||||
|
@ -41402,13 +41388,6 @@ components:
|
||||||
additionalProperties: {}
|
additionalProperties: {}
|
||||||
description: The option configures the footer links on the flow executor
|
description: The option configures the footer links on the flow executor
|
||||||
pages.
|
pages.
|
||||||
reputation_expiry:
|
|
||||||
type: integer
|
|
||||||
maximum: 9223372036854775807
|
|
||||||
minimum: 0
|
|
||||||
format: int64
|
|
||||||
description: Configure how long reputation scores should be saved for in
|
|
||||||
seconds.
|
|
||||||
SeverityEnum:
|
SeverityEnum:
|
||||||
enum:
|
enum:
|
||||||
- notice
|
- notice
|
||||||
|
|
Reference in New Issue