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

Class ChatAuthentication

apps/common/auth/common.py:35–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33
34
35class ChatAuthentication:
36 def __init__(self, auth_type: str | None, **kwargs):
37 self.auth_type = auth_type
38 for k, v in kwargs.items():
39 self.__setattr__(k, v)
40
41 def to_dict(self):
42 return self.__dict__
43
44 def to_string(self):
45 value = json.dumps(self.to_dict())
46 authentication = encrypt(value)
47 cache_key = hashlib.sha256(authentication.encode()).hexdigest()
48 authentication_cache.set(cache_key, value, version=Cache_Version.CHAT.get_version(), timeout=60 * 60 * 2)
49 return authentication
50
51 @staticmethod
52 def new_instance(authentication: str):
53 auth = json.loads(_decrypt(authentication))
54 return ChatAuthentication(**auth)
55
56
57class ChatUserToken:

Callers 2

authMethod · 0.90
new_instanceMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected