mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: make scim auth header case insensitive for 'bearer' (#15538)
Fixes status codes to return more than 500. The way we were using the package, it always returned a status code 500
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
package scim
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"github.com/imulab/go-scim/pkg/v2/spec"
|
||||
)
|
||||
|
||||
type ServiceProviderConfig struct {
|
||||
Schemas []string `json:"schemas"`
|
||||
@@ -44,3 +49,37 @@ type AuthenticationScheme struct {
|
||||
SpecURI string `json:"specUri"`
|
||||
DocURI string `json:"documentationUri"`
|
||||
}
|
||||
|
||||
// HTTPError wraps a *spec.Error for correct usage with
|
||||
// 'handlerutil.WriteError'. This error type is cursed to be
|
||||
// absolutely strange and specific to the SCIM library we use.
|
||||
//
|
||||
// The library expects *spec.Error to be returned on unwrap, and the
|
||||
// internal error description to be returned by a json.Marshal of the
|
||||
// top level error.
|
||||
type HTTPError struct {
|
||||
scim *spec.Error
|
||||
internal error
|
||||
}
|
||||
|
||||
func NewHTTPError(status int, eType string, err error) *HTTPError {
|
||||
return &HTTPError{
|
||||
scim: &spec.Error{
|
||||
Status: status,
|
||||
Type: eType,
|
||||
},
|
||||
internal: err,
|
||||
}
|
||||
}
|
||||
|
||||
func (e HTTPError) Error() string {
|
||||
return e.internal.Error()
|
||||
}
|
||||
|
||||
func (e HTTPError) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(e.internal)
|
||||
}
|
||||
|
||||
func (e HTTPError) Unwrap() error {
|
||||
return e.scim
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user