Skip to content

Commit

Permalink
added caching for ldap get_user
Browse files Browse the repository at this point in the history
  • Loading branch information
sametd authored and jameshawkes committed Nov 11, 2024
1 parent 4edae1d commit 7065b2b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions polytope_server/common/authorization/ldap_authorization.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from ldap3 import SUBTREE, Connection, Server

from ..auth import User
from ..caching import cache
from . import authorization


Expand All @@ -40,6 +41,7 @@ def __init__(self, name, realm, config):
self.username_attribute = config.get("username-attribute", None)
super().__init__(name, realm, config)

@cache(lifetime=120)
def get_roles(self, user: User) -> list:
if user.realm != self.realm():
raise ValueError(
Expand Down

0 comments on commit 7065b2b

Please sign in to comment.