MCPcopy Create free account
hub / github.com/TaskingAI/TaskingAI / Apikey

Class Apikey

backend/app/models/auth/apikey.py:11–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9
10
11class Apikey(ModelEntity):
12 object: str = "Apikey"
13
14 apikey_id: str
15 name: str
16 encrypted_apikey: str
17 apikey: str
18 created_timestamp: int
19 updated_timestamp: int
20
21 @staticmethod
22 def build(row: Dict):
23 encrypted_apikey = row["encrypted_apikey"]
24 apikey = aes_decrypt(encrypted_apikey)
25 return Apikey(
26 apikey_id=row["apikey_id"],
27 encrypted_apikey=encrypted_apikey,
28 apikey=apikey,
29 name=row["name"],
30 created_timestamp=row["created_timestamp"],
31 updated_timestamp=row["updated_timestamp"],
32 )
33
34 def to_response_dict(self) -> Dict:
35 response_dict = super().to_response_dict()
36 apikey = self.apikey
37 response_dict["apikey"] = apikey[:2] + "*" * (len(apikey) - 4) + apikey[-2:]
38 return response_dict
39
40 @staticmethod
41 def object_name() -> str:
42 return "apikey"
43
44 @staticmethod
45 def object_plural_name() -> str:
46 return "apikeys"
47
48 @staticmethod
49 def table_name() -> str:
50 return "apikey"
51
52 @staticmethod
53 def id_field_name() -> str:
54 return "apikey_id"
55
56 @staticmethod
57 def primary_key_fields() -> List[str]:
58 return ["apikey_id"]
59
60 @staticmethod
61 def generate_random_id() -> str:
62 return generate_random_id(8)
63
64 @staticmethod
65 def generate_random_apikey(apikey_id):
66 return "tk" + apikey_id + generate_random_id(22)
67
68 @staticmethod

Callers 1

buildMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected