sources/ldap: make sure lock is per-tenant

Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
This commit is contained in:
Marc 'risson' Schmitt 2023-12-07 09:56:05 +01:00
parent a4477a9bea
commit 75d4cdb40b
No known key found for this signature in database
GPG Key ID: 9C3FA22FABF1AA8D
1 changed files with 2 additions and 2 deletions

View File

@ -7,7 +7,7 @@ from tempfile import NamedTemporaryFile, mkdtemp
from typing import Optional from typing import Optional
from django.core.cache import cache from django.core.cache import cache
from django.db import models from django.db import connection, models
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from ldap3 import ALL, NONE, RANDOM, Connection, Server, ServerPool, Tls from ldap3 import ALL, NONE, RANDOM, Connection, Server, ServerPool, Tls
from ldap3.core.exceptions import LDAPException, LDAPInsufficientAccessRightsResult, LDAPSchemaError from ldap3.core.exceptions import LDAPException, LDAPInsufficientAccessRightsResult, LDAPSchemaError
@ -203,7 +203,7 @@ class LDAPSource(Source):
"""Redis lock for syncing LDAP to prevent multiple parallel syncs happening""" """Redis lock for syncing LDAP to prevent multiple parallel syncs happening"""
return Lock( return Lock(
cache.client.get_client(), cache.client.get_client(),
name=f"goauthentik.io/sources/ldap/sync-{self.slug}", name=f"goauthentik.io/sources/ldap/sync{connection.schema_name}-{self.slug}",
# Convert task timeout hours to seconds, and multiply times 3 # Convert task timeout hours to seconds, and multiply times 3
# (see authentik/sources/ldap/tasks.py:54) # (see authentik/sources/ldap/tasks.py:54)
# multiply by 3 to add even more leeway # multiply by 3 to add even more leeway