This repository was archived by the owner on Mar 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
61 lines (48 loc) · 1.5 KB
/
config.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package oauth2
var (
ServerDefaultConfig = ServerConfig{
Grants: map[GrantType]OauthGrant{},
ErrorMap: map[error]OauthError{
RefreshTokenNotFoundErr: {
Err: InvalidGrantErr,
Description: "Refresh has expired or been deleted",
},
},
ClientAuthorizedHandler: func(clientId, clientSecret string) (bool, error) {
return true, nil
},
ClientScopeHandler: func(clientId string, scopes []string) (bool, error) {
return true, nil
},
CallbackPreGrant: func(identifier, ipAddr string) error {
return nil
},
CallbackPostGrant: func(identifier, ipAddr, token string) {
},
CallbackPrePersistAccessToken: func(accessToken *AccessToken) error {
return nil
},
CallbackPrePersistRefreshToken: func(refreshToken *RefreshToken) error {
return nil
},
IsBehindProxy: false,
ProxyIpHeader: "X-Forwarded-For",
}
)
type ServerConfig struct {
// Grants
Grants map[GrantType]OauthGrant
// Authorize the client
ClientAuthorizedHandler func(clientId, clientSecret string) (bool, error)
// Can client access scope
ClientScopeHandler func(clientId string, scopes []string) (bool, error)
// Error map
ErrorMap map[error]OauthError
CallbackPostGrant CallbackPostGrant
CallbackPreGrant CallbackPreGrant
CallbackPrePersistAccessToken CallbackPrePersistAccessToken
CallbackPrePersistRefreshToken CallbackPrePersistRefreshToken
// If the server is hiding behind a reverse proxy thus check the headers first
IsBehindProxy bool
ProxyIpHeader string
}