Skip to content
anythingai.space
Backend for AIintermediate11 min · 10 steps

Authentication with JWT

A JSON Web Token carries signed claims about the caller that every request can verify locally, which is the base for permission-filtered retrieval, user-scoped tools and audit.

{"user_id": "E99999"}Body says E99999, so the API returns E99999'sticketsUseror an attackerAssistant APIaud api://it-assistanttrusts body
errorrequestresponsedatatool call
1 / 10
ProblemStep 1 of 10

Every request has to prove who sent it

The assistant filters documents by the user's groups, fetches their tickets and logs their actions. All of that depends on knowing who is calling, on every single request.

Trusting a user_id in the request body (or one the model produced) lets anyone be anyone. Calling the identity provider on every request works, but adds a network hop and makes the IdP a bottleneck.

Watch outIdentity comes from a verified token. Never from the request body, and never from the model.

Lesson 6 of 20 in Backend for AI