forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
defaults.go
44 lines (36 loc) · 1.01 KB
/
defaults.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package osinserver
import (
"fmt"
"net/http"
"github.com/RangelReale/osin"
)
func NewDefaultServerConfig() *osin.ServerConfig {
config := osin.NewServerConfig()
config.AllowedAuthorizeTypes = osin.AllowedAuthorizeType{
osin.CODE,
osin.TOKEN,
}
config.AllowedAccessTypes = osin.AllowedAccessType{
osin.AUTHORIZATION_CODE,
osin.REFRESH_TOKEN,
osin.PASSWORD,
osin.CLIENT_CREDENTIALS,
osin.ASSERTION,
}
config.AllowClientSecretInParams = true
config.AllowGetAccessRequest = true
config.RedirectUriSeparator = ","
config.ErrorStatusCode = http.StatusBadRequest
return config
}
// defaultError implements ErrorHandler
type defaultErrorHandler struct{}
// NewDefaultErrorHandler returns a simple ErrorHandler
func NewDefaultErrorHandler() ErrorHandler {
return defaultErrorHandler{}
}
// HandleError implements ErrorHandler
func (defaultErrorHandler) HandleError(err error, w http.ResponseWriter, req *http.Request) {
w.WriteHeader(http.StatusInternalServerError)
fmt.Fprintf(w, "Error: %s", err)
}