pomerium/internal/httputil/httputil.go
Caleb Doxsey 3497c39b9b
authorize: add support for webauthn device policy enforcement (#2700)
* authorize: add support for webauthn device policy enforcement

* update docs

* group statuses
2021-10-25 09:41:03 -06:00

41 lines
1.2 KiB
Go

package httputil
import "net/http"
const (
// StatusDeviceUnauthorized is the status code returned when a client's
// device credential is not authorized to access a page.
StatusDeviceUnauthorized = 450
// StatusInvalidClientCertificate is the status code returned when a
// client's certificate is invalid. This is the same status code used
// by nginx for this purpose.
StatusInvalidClientCertificate = 495
)
var detailsText = map[int]string{
StatusDeviceUnauthorized: "your device fails to meet the requirements necessary to access this page, please contact your administrator for assistance",
}
// DetailsText returns extra details for an HTTP status code. It returns StatusText if not found.
func DetailsText(code int) string {
txt, ok := detailsText[code]
if ok {
return txt
}
return StatusText(code)
}
var statusText = map[int]string{
StatusDeviceUnauthorized: "device not authorized",
StatusInvalidClientCertificate: "a valid client certificate is required to access this page",
}
// StatusText returns a text for the HTTP status code. It returns http.StatusText if not found.
func StatusText(code int) string {
txt, ok := statusText[code]
if ok {
return txt
}
return http.StatusText(code)
}