mirror of
https://github.com/tailscale/tailscale.git
synced 2025-04-21 06:01:42 +00:00
cmd/tsidp: allow CORS requests to openid-configuration (#15229)
Add support for Cross-Origin XHR requests to the openid-configuration endpoint to enable clients like Grafana's auto-population of OIDC setup data from its contents. Updates https://github.com/tailscale/tailscale/issues/10263 Signed-off-by: Patrick O'Doherty <patrick@tailscale.com>
This commit is contained in:
parent
03f7f1860e
commit
8f0080c7a4
@ -765,6 +765,18 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (s *idpServer) serveOpenIDConfig(w http.ResponseWriter, r *http.Request) {
|
func (s *idpServer) serveOpenIDConfig(w http.ResponseWriter, r *http.Request) {
|
||||||
|
h := w.Header()
|
||||||
|
h.Set("Access-Control-Allow-Origin", "*")
|
||||||
|
h.Set("Access-Control-Allow-Method", "GET, OPTIONS")
|
||||||
|
// allow all to prevent errors from client sending their own bespoke headers
|
||||||
|
// and having the server reject the request.
|
||||||
|
h.Set("Access-Control-Allow-Headers", "*")
|
||||||
|
|
||||||
|
// early return for pre-flight OPTIONS requests.
|
||||||
|
if r.Method == "OPTIONS" {
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
return
|
||||||
|
}
|
||||||
if r.URL.Path != oidcConfigPath {
|
if r.URL.Path != oidcConfigPath {
|
||||||
http.Error(w, "tsidp: not found", http.StatusNotFound)
|
http.Error(w, "tsidp: not found", http.StatusNotFound)
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user