-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.go
39 lines (36 loc) · 1.19 KB
/
server.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
package oauth2s
import (
"github.com/admpub/oauth2/v4/server"
)
func NewServer(config *Config) (*server.Server, error) {
srv := server.NewServer(server.NewConfig(), config.Manager())
passwordAuthorization := config.HandlerInfo.PasswordAuthorization
if passwordAuthorization == nil {
passwordAuthorization = passwordAuthorizationHandler
}
srv.SetPasswordAuthorizationHandler(passwordAuthorization)
userAuthorize := config.HandlerInfo.UserAuthorize
if userAuthorize == nil {
userAuthorize = userAuthorizeHandler
}
srv.SetUserAuthorizationHandler(userAuthorize)
internalError := config.HandlerInfo.InternalError
if internalError == nil {
internalError = InternalErrorHandler
}
srv.SetInternalErrorHandler(internalError)
responseError := config.HandlerInfo.ResponseError
if responseError == nil {
responseError = ResponseErrorHandler
}
srv.SetResponseErrorHandler(responseError)
refreshingValidation := config.HandlerInfo.RefreshingValidation
if refreshingValidation != nil {
srv.SetRefreshingValidationHandler(refreshingValidation)
}
refreshingScope := config.HandlerInfo.RefreshingScope
if refreshingScope != nil {
srv.SetRefreshingScopeHandler(refreshingScope)
}
return srv, nil
}