package auth import ( "encoding/json" "net/http" ) // ProtectedResourceHandler returns an RFC 9728 oauth-protected-resource metadata // handler. Mount at GET /.well-known/oauth-protected-resource (no auth required). func ProtectedResourceHandler(resourceURL, issuerURL string) http.HandlerFunc { type metadata struct { Resource string `json:"resource"` AuthorizationServers []string `json:"authorization_servers"` } body, _ := json.Marshal(metadata{ Resource: resourceURL, AuthorizationServers: []string{issuerURL}, }) return func(w http.ResponseWriter, _ *http.Request) { w.Header().Set("Content-Type", "application/json") _, _ = w.Write(body) } }