this repo has no description
1package handler
2
3import (
4 "encoding/json"
5 "net/http"
6
7 "tangled.org/core/appview/oauth"
8)
9
10func OauthClientMetadata(o *oauth.OAuth) http.HandlerFunc {
11 return func(w http.ResponseWriter, r *http.Request) {
12 doc := o.ClientApp.Config.ClientMetadata()
13 doc.JWKSURI = &o.JwksUri
14 doc.ClientName = &o.ClientName
15 doc.ClientURI = &o.ClientUri
16
17 w.Header().Set("Content-Type", "application/json")
18 if err := json.NewEncoder(w).Encode(doc); err != nil {
19 http.Error(w, err.Error(), http.StatusInternalServerError)
20 return
21 }
22 }
23}
24
25func OauthJwks(o *oauth.OAuth) http.HandlerFunc {
26 return func(w http.ResponseWriter, r *http.Request) {
27 w.Header().Set("Content-Type", "application/json")
28 body := o.ClientApp.Config.PublicJWKS()
29 if err := json.NewEncoder(w).Encode(body); err != nil {
30 http.Error(w, err.Error(), http.StatusInternalServerError)
31 return
32 }
33 }
34}