~bigbes/sr-ht-compare

ref: 53d7b9707f1ea95fc7e5a8c1865e1b1dc14beeb4 sr-ht-compare/authz/doc.go -rw-r--r-- 1.1 KiB
53d7b970 — bigbes docs: note that static assets are embedded and need a rebuild 30 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Package authz answers two orthogonal questions for compare.sr.ht: who is
// making a request, and what may they see. Identity is derived purely from the
// SourceHut unified-login cookie (sr.ht.unified-login.v1), a Fernet token
// encrypted with the instance [sr.ht] network-key; UsernameFromRequest decrypts
// it and yields a bare username, or "" for an anonymous viewer. It never
// rejects a request — an unreadable or absent cookie simply means anonymous.
//
// Authorization is delegated entirely to git.sr.ht over its internal GraphQL
// API: compare.sr.ht owns no user or repository data of its own, so there is no
// database. GQLAuthorizer issues each query as the viewing user via
// core-go's client.Do (Authorization: Internal <fernet(...)>), letting
// git.sr.ht's own loader apply visibility rules — an anonymous or unauthorized
// viewer sees a null repository, which maps to core.ErrNotFound so private-repo
// existence is never leaked. A small mutex-guarded TTL cache memoizes positive
// and not-found results (but never transport errors) to spare git.sr.ht a round
// trip on every page load.
package authz