MCPcopy
hub / github.com/1Panel-dev/MaxKB / handle

Method handle

apps/common/auth/handle/impl/user_token.py:307–319  ·  view source on GitHub ↗
(self, request, token: str, get_token_details)

Source from the content-addressed store, hash-verified

305 return 'id' in auth_details and auth_details.get('type') == AuthenticationType.SYSTEM_USER.value
306
307 def handle(self, request, token: str, get_token_details):
308 version, get_key = Cache_Version.TOKEN.value
309 cache_token = cache.get(get_key(token), version=version)
310 if cache_token is None:
311 raise AppAuthenticationFailed(1002, _('Login expired'))
312 auth_details = get_token_details()
313 timeout = CONFIG.get_session_timeout()
314 cache.touch(token, timeout=timeout, version=version)
315 user = QuerySet(User).get(id=auth_details['id'])
316 if not user.is_active or user.password != cache_token.password:
317 raise AppAuthenticationFailed(1002, _('Authentication information is incorrect'))
318 auth = get_auth(user)
319 return user, auth

Callers 3

authenticateMethod · 0.45
authenticateMethod · 0.45
authenticateMethod · 0.45

Calls 4

get_authFunction · 0.85
get_session_timeoutMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected