~bigbes/sr-ht-compare

ref: 4f3961888c6889fc2ea19c9bcbb68359015d3475 sr-ht-compare/authz/doc.go -rw-r--r-- 1.1 KiB
4f396188 — bigbes rename the service to diff.sr.ht 9 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Package authz answers one question for diff.sr.ht: what may a given viewer
// see. Who the viewer is, is not this package's question any more — the
// unified-login cookie is decoded by sr-ht-ecore/login, which every custom
// service on the instance shares, and a handler reads the answer with
// login.FromContext. The copy that used to live here decoded the same cookie
// and did not validate the name it found, which is the whole reason that decode
// is one package now.
//
// Authorization is delegated entirely to git.sr.ht over its internal GraphQL
// API: diff.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