handleProtectedResourceMetadata serves the OAuth 2.0 Protected Resource Metadata document, as defined in RFC 9728.
(w http.ResponseWriter, r *http.Request)
| 79 | // handleProtectedResourceMetadata serves the OAuth 2.0 Protected Resource Metadata document, |
| 80 | // as defined in RFC 9728. |
| 81 | func (s *state) handleProtectedResourceMetadata(w http.ResponseWriter, r *http.Request) { |
| 82 | // Construct the authorization server issuer URL dynamically. |
| 83 | authServerIssuer := getBaseURL(r) |
| 84 | |
| 85 | metadata := ProtectedResourceMetadata{ |
| 86 | ScopesSupported: []string{"openid", "profile", "email"}, |
| 87 | AuthorizationServers: []string{authServerIssuer}, |
| 88 | } |
| 89 | var buf bytes.Buffer |
| 90 | if err := json.NewEncoder(&buf).Encode(metadata); err != nil { |
| 91 | http.Error(w, err.Error(), http.StatusInternalServerError) |
| 92 | return |
| 93 | } |
| 94 | w.Header().Set("Content-Type", "application/json") |
| 95 | w.WriteHeader(http.StatusOK) |
| 96 | w.Write(buf.Bytes()) |
| 97 | } |
| 98 | |
| 99 | func (s *state) handleServerMetadata(w http.ResponseWriter, r *http.Request) { |
| 100 | issuer := getBaseURL(r) |
nothing calls this directly
no test coverage detected