Skip to main content
The first two tutorials cover authors reading their own documents (embed token) and fully public documents (share token). This one covers the case in between: another signed-in user reads a document, and your app decides whether they may. (ex: a student viewing a teacher’s lesson). Embed tokens can’t express this: they are scoped to one identity’s own documents, and minting the author’s token for a reader would let them edit. Instead, the renderer accepts a per-document, expiring HMAC signature that your backend computes after running whatever access check you like:
Qirtaas holds the same signing secret and recomputes the HMAC to verify. The signature is your backend’s short-lived approval stamp: “this reader may read this document until exp”. The ACL itself never leaves your database. Example scenario: a course platform. Teachers author lesson documents (the creation flow, unchanged); enrolled students read them.

1. Backend — the data model

We will track lessons (which contain Qirtaas documents) and student enrollments.

2. Backend — gated signature endpoint

We will add a signing helper function …
… then we will expose a function in the backend that signs documents after performing ACL checks.

4. Frontend — render with getSignature

Give the renderer getSignature instead of getToken. The renderer sends the pair as ?sig=&exp= query parameters on its read:
src/LessonView.tsx

Security checklist

  • The signing secret lives in backend env/config only.
  • Check access before signing, and sign only the specific document the check covered. Never sign ids taken from the request unchecked.
  • Signatures grant read-only access to one document. There is no wildcard signature, so a leaked one is contained to a single document until its exp.
Full reference: Authentication — signatures.