Skip to content

Commit

Permalink
policies/reputation: delete reputation data from cache once save in d…
Browse files Browse the repository at this point in the history
…atabase

Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
  • Loading branch information
rissson committed Jun 10, 2024
1 parent 9379b3d commit 5294625
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion authentik/policies/reputation/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
def save_reputation(self: SystemTask):
"""Save currently cached reputation to database"""
objects_to_update = []
for _, score in cache.get_many(cache.keys(CACHE_KEY_PREFIX + "*")).items():
data = cache.get_many(cache.keys(CACHE_KEY_PREFIX + "*"))
for _, score in data.items():
rep, _ = Reputation.objects.get_or_create(
ip=score["ip"],
identifier=score["identifier"],
Expand All @@ -29,4 +30,5 @@ def save_reputation(self: SystemTask):
rep.score = score["score"]
objects_to_update.append(rep)
Reputation.objects.bulk_update(objects_to_update, ["score", "ip_geo_data"])
cache.delete_many(data.keys())
self.set_status(TaskStatus.SUCCESSFUL, "Successfully updated Reputation")

0 comments on commit 5294625

Please sign in to comment.