feat: serve latha-auth atproto OAuth client metadata
Build and Push Image / build (push) Successful in 40s

Add GET /oauth/atproto-client-metadata.json next to the existing OAuth
relay routes so AT Protocol authorization servers can resolve the
latha-auth public client (client_id is this URL).
This commit is contained in:
nandi committed 2026-11-18 06:20:41 +00:00
1 parent 4a9ec8b2ad
commit 6f3cb6777b
3 files changed
+70

No files matched your search

+41
View File
@@ -128,3 +128,44 @@ func TestOAuthRelayTTLExpiration(t *testing.T) {
t.Fatalf("expected expired entry to be rejected, got (%q, %v)", code, ok)
}
}
func TestAtprotoClientMetadata(t *testing.T) {
srv := newTestServer(t)
ts := httptest.NewServer(srv.Handler())
defer ts.Close()
resp, err := http.Get(ts.URL + "/oauth/atproto-client-metadata.json")
if err != nil {
t.Fatalf("get client metadata: %v", err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
t.Fatalf("expected 200, got %d", resp.StatusCode)
}
if ct := resp.Header.Get("Content-Type"); !strings.HasPrefix(ct, "application/json") {
t.Fatalf("expected application/json content type, got %q", ct)
}
body, err := io.ReadAll(resp.Body)
if err != nil {
t.Fatalf("read body: %v", err)
}
var out struct {
ClientID string `json:"client_id"`
RedirectURIs []string `json:"redirect_uris"`
Scope string `json:"scope"`
DPoPBoundAccessTokens bool `json:"dpop_bound_access_tokens"`
}
if err := json.Unmarshal(body, &out); err != nil {
t.Fatalf("unmarshal client metadata: %v", err)
}
// client_id must exactly match the public URL this is served from.
if out.ClientID != "https://deploy.site.latha.org/oauth/atproto-client-metadata.json" {
t.Fatalf("client_id = %q", out.ClientID)
}
if len(out.RedirectURIs) != 1 || out.RedirectURIs[0] != "https://deploy.site.latha.org/oauth/callback" {
t.Fatalf("redirect_uris = %v", out.RedirectURIs)
}
if !out.DPoPBoundAccessTokens {
t.Fatal("dpop_bound_access_tokens must be true")
}
}