admin auth and service helpers in SDK (#1059)
- `net/http` server middleware for "atproto admin auth" (which is just
Basic auth with user "admin), supporting multiple passwords for
operational flexibility (eg, new relay could use this)
- inter-service auth validation, including `net/http` middleware. fairly
complete and correct, though might have some performance issues
(purging/retrying identity resolution; and parsing keys on every
request)
The service auth code is loosely inspired by code in Discover (which is
not open source), which has been running in prod a long time now. For
example the test cases. But that code caches parsed keys much more
aggressively (with an in-process LRU).
There are some TODOs in here about XRPC error responses (aka, reply with
JSON). I'm not sure if we want to manage that here in middleware library
code, or leave it to service error handler to fill in.
The logic around LXM validation/enforcement could also use review, both
of the code and against the atproto XRPC specs.
Note that this package intentionally does not use "XRPC" in
method/variable names, as we are slowly deprecating that terminology.
authored by
bnewbold.net
and committed by