From 7ad500f54d2c8a34f260eb6a784d28cc76dd9e51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=B6nch?= Date: Wed, 26 Nov 2025 16:16:02 +0100 Subject: [PATCH 1/2] cache more forgejo-authentication source queries The code now caches the following operations for the indicated duration: - perform token authentication: 60 seconds - get team-membership of user: 120 seconds - get user information, i.e. user-id: 120 seconds - get organization information: 300 seconds - get organization-membership of team: 300 seconds - get repo-membership of team: 300 seconds --- dump_things_service/auth/forgejo.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dump_things_service/auth/forgejo.py b/dump_things_service/auth/forgejo.py index 36b475b..41b5d37 100644 --- a/dump_things_service/auth/forgejo.py +++ b/dump_things_service/auth/forgejo.py @@ -43,9 +43,9 @@ class MethodCache: @staticmethod def cache_temporary( - duration: int = 3600, + duration: int = 300, ) -> Callable: - """ Cache results for a given time (default: 3600 seconds) """ + """ Cache results for a given time (default: 300 seconds) """ def decorator(func: Callable) -> Callable: @wraps(func) def wrapper(*args, **kwargs): @@ -132,6 +132,7 @@ class ForgejoAuthenticationSource(AuthenticationSource, MethodCache): raise InvalidTokenError(msg) return r.json() + @MethodCache.cache_temporary(duration=120) def _get_user( self, token: str, @@ -145,6 +146,7 @@ class ForgejoAuthenticationSource(AuthenticationSource, MethodCache): token, ) + @MethodCache.cache_temporary(duration=120) def _get_teams_for_user(self, token: str) -> dict: r = self._get_json_from_endpoint('user/teams', token) return {team['name']: team for team in r} @@ -208,6 +210,7 @@ class ForgejoAuthenticationSource(AuthenticationSource, MethodCache): ) return permissions + @MethodCache.cache_temporary(duration=60) def authenticate( self, token: str, -- 2.52.0 From 3575400adbee2336442785f16c24bb646b267617 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=B6nch?= Date: Wed, 26 Nov 2025 16:31:04 +0100 Subject: [PATCH 2/2] update CHANGELOG.md, bump version --- CHANGELOG.md | 10 ++++++++++ dump_things_service/__about__.py | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc320ba..545f9f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +# 5.2.1 (2025-11-26) + +## Changes + +- Improve caching in Forgejo authentication sources. All calls to a + Forgejo-authentication source are now cached with expiration duration + between one and five minutes. Authentication-related changes in Forgejo + instances might therefore become visible after up to five minutes. + + # 5.2.0 (2025-10-29) ## New features diff --git a/dump_things_service/__about__.py b/dump_things_service/__about__.py index f279ec9..4dc2ef2 100644 --- a/dump_things_service/__about__.py +++ b/dump_things_service/__about__.py @@ -1 +1 @@ -__version__ = '5.2.0' +__version__ = '5.2.1' -- 2.52.0