MCPcopy
hub / github.com/AgentOps-AI/agentops / _decode_session_cookie

Function _decode_session_cookie

app/api/agentops/auth/views.py:150–160  ·  view source on GitHub ↗

Decode the session cookie to get the Session object. Raises AuthException if the cookie is invalid or expired. Returns None if the session is not found.

(cookie: str)

Source from the content-addressed store, hash-verified

148
149
150def _decode_session_cookie(cookie: str) -> Session | None:
151 """
152 Decode the session cookie to get the Session object.
153 Raises AuthException if the cookie is invalid or expired.
154 Returns None if the session is not found.
155 """
156 try:
157 data = jwt.decode(cookie, AUTH_COOKIE_SECRET, algorithms=[AUTH_JWT_ALGO])
158 return Session.get(data['session_id'])
159 except (KeyError, jwt.InvalidTokenError):
160 raise AuthException("Could not decode internal session JWT.")
161
162
163def _validate_request(request: Request) -> None:

Callers 1

_get_sessionMethod · 0.85

Calls 3

AuthExceptionClass · 0.85
decodeMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…