Remove setting and pickle

This commit is contained in:
Hristo Kapanakov 2025-07-19 13:47:47 +03:00
commit 0d779c3465
4 changed files with 4 additions and 15 deletions

View file

@ -113,7 +113,6 @@ For usage, see [Usage - OpenID Connect](../authentication/oidc-v2.md)
| OIDC_GROUPS_CLAIM | groups | Optional if not using `OIDC_USER_GROUP` or `OIDC_ADMIN_GROUP`. This is the claim Mealie will request from your IdP and will use to compare to `OIDC_USER_GROUP` or `OIDC_ADMIN_GROUP` to allow the user to log in to Mealie or is set as an admin. **Your IdP must be configured to grant this claim** | | OIDC_GROUPS_CLAIM | groups | Optional if not using `OIDC_USER_GROUP` or `OIDC_ADMIN_GROUP`. This is the claim Mealie will request from your IdP and will use to compare to `OIDC_USER_GROUP` or `OIDC_ADMIN_GROUP` to allow the user to log in to Mealie or is set as an admin. **Your IdP must be configured to grant this claim** |
| OIDC_SCOPES_OVERRIDE | None | Advanced configuration used to override the scopes requested from the IdP. **Most users won't need to change this**. At a minimum, 'openid profile email' are required. | | OIDC_SCOPES_OVERRIDE | None | Advanced configuration used to override the scopes requested from the IdP. **Most users won't need to change this**. At a minimum, 'openid profile email' are required. |
| OIDC_TLS_CACERTFILE | None | File path to Certificate Authority used to verify server certificate (e.g. `/path/to/ca.crt`) | | OIDC_TLS_CACERTFILE | None | File path to Certificate Authority used to verify server certificate (e.g. `/path/to/ca.crt`) |
| OIDC_USE_AUTH_CACHE | False | If `True`, OIDC authentication will use server cache instead of session to store its temporary data. |
### OpenAI ### OpenAI

View file

@ -338,7 +338,6 @@ class AppSettings(AppLoggingSettings):
OIDC_GROUPS_CLAIM: str | None = "groups" OIDC_GROUPS_CLAIM: str | None = "groups"
OIDC_SCOPES_OVERRIDE: str | None = None OIDC_SCOPES_OVERRIDE: str | None = None
OIDC_TLS_CACERTFILE: str | None = None OIDC_TLS_CACERTFILE: str | None = None
OIDC_USE_AUTH_CACHE: bool = False
@property @property
def OIDC_REQUIRES_GROUP_CLAIM(self) -> bool: def OIDC_REQUIRES_GROUP_CLAIM(self) -> bool:

View file

@ -29,10 +29,7 @@ remember_me_duration = timedelta(days=14)
settings = get_app_settings() settings = get_app_settings()
if settings.OIDC_READY: if settings.OIDC_READY:
cache = None oauth = OAuth(cache=AuthCache())
if settings.OIDC_USE_AUTH_CACHE:
cache = AuthCache()
oauth = OAuth(cache=cache)
scope = None scope = None
if settings.OIDC_SCOPES_OVERRIDE: if settings.OIDC_SCOPES_OVERRIDE:
scope = settings.OIDC_SCOPES_OVERRIDE scope = settings.OIDC_SCOPES_OVERRIDE

View file

@ -1,11 +1,5 @@
import time import time
try:
import cPickle as pickle
except ImportError:
import pickle
class AuthCache: class AuthCache:
def __init__(self, threshold=500, default_timeout=300): def __init__(self, threshold=500, default_timeout=300):
self.default_timeout = default_timeout self.default_timeout = default_timeout
@ -34,14 +28,14 @@ class AuthCache:
try: try:
expires, value = self._cache[key] expires, value = self._cache[key]
if expires == 0 or expires > time.time(): if expires == 0 or expires > time.time():
return pickle.loads(value) return value
except (KeyError, pickle.PickleError): except KeyError:
return None return None
async def set(self, key, value, timeout=None): async def set(self, key, value, timeout=None):
expires = self._normalize_timeout(timeout) expires = self._normalize_timeout(timeout)
self._prune() self._prune()
self._cache[key] = (expires, pickle.dumps(value, pickle.HIGHEST_PROTOCOL)) self._cache[key] = (expires, value)
return True return True
async def delete(self, key): async def delete(self, key):