mirror of
https://github.com/pomerium/pomerium.git
synced 2025-06-10 14:52:43 +02:00
- authenticate: add cors preflight check support for sign_in endpoint - internal/httputil: indicate responses that originate from pomerium vs the app - proxy: detect XHR requests and do not redirect on failure. - authenticate: removed default session duration; should be maintained out of band with rpc.
26 lines
855 B
Go
26 lines
855 B
Go
package httputil // import "github.com/pomerium/pomerium/internal/httputil"
|
|
|
|
import (
|
|
"net/http"
|
|
)
|
|
|
|
// HealthCheck is a simple healthcheck handler that responds to GET and HEAD
|
|
// http requests.
|
|
func HealthCheck(w http.ResponseWriter, r *http.Request) {
|
|
if r.Method != http.MethodGet && r.Method != http.MethodHead {
|
|
http.Error(w, http.StatusText(http.StatusMethodNotAllowed), http.StatusMethodNotAllowed)
|
|
return
|
|
}
|
|
w.Header().Set("Content-Type", "text/plain")
|
|
w.WriteHeader(http.StatusOK)
|
|
if r.Method == http.MethodGet {
|
|
w.Write([]byte(http.StatusText(http.StatusOK)))
|
|
}
|
|
}
|
|
|
|
// Redirect wraps the std libs's redirect method indicating that pomerium is
|
|
// the origin of the response.
|
|
func Redirect(w http.ResponseWriter, r *http.Request, url string, code int) {
|
|
w.Header().Set(HeaderPomeriumResponse, "true")
|
|
http.Redirect(w, r, url, code)
|
|
}
|