MCPcopy Index your code
hub / github.com/AgentOps-AI/agentops / JWTPayload

Class JWTPayload

app/api/agentops/api/auth.py:27–68  ·  view source on GitHub ↗

Dataclass to represent the payload of a JWT token. This is used for type checking and validation of the JWT payload.

Source from the content-addressed store, hash-verified

25
26@dataclass
27class JWTPayload:
28 """
29 Dataclass to represent the payload of a JWT token.
30 This is used for type checking and validation of the JWT payload.
31 """
32
33 exp: int
34 aud: str
35 project_id: str
36 project_prem_status: str
37 api_key: str
38 dev: bool = False
39
40 def asdict(self) -> dict:
41 """Convert the payload to a dictionary format."""
42 properties = {
43 "exp": self.exp,
44 "aud": self.aud,
45 "project_id": self.project_id,
46 "project_prem_status": self.project_prem_status,
47 "api_key": self.api_key,
48 }
49
50 if self.dev:
51 properties["dev"] = self.dev
52
53 return properties
54
55 @classmethod
56 def from_project(cls, project: ProjectModel, dev: bool = False) -> "JWTPayload":
57 """
58 Create a new instance of JWTPayload with the given project_id and role.
59 The expiration time is set to 30 days from now.
60 """
61 return cls(
62 exp=_generate_jwt_timestamp(),
63 aud="authenticated",
64 project_id=str(project.id),
65 project_prem_status=project.org.prem_status.value,
66 api_key=str(project.api_key),
67 dev=dev,
68 )
69
70
71def generate_jwt(project: ProjectModel) -> str:

Callers 6

valid_jwt_payloadFunction · 0.90
expired_jwt_payloadFunction · 0.90
valid_jwt_payloadFunction · 0.90
expired_jwt_payloadFunction · 0.90
verify_jwtFunction · 0.85
generate_dev_tokenFunction · 0.85

Calls

no outgoing calls

Tested by 4

valid_jwt_payloadFunction · 0.72
expired_jwt_payloadFunction · 0.72
valid_jwt_payloadFunction · 0.72
expired_jwt_payloadFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…