-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
66 lines (62 loc) · 2.57 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
62
63
64
65
66
package kitwalk
import (
"net/url"
)
const (
// DefaultUnameKey is used to post auth information
DefaultUnameKey = "j_username"
// DefaultPasswdKey is used as well as DefaultUnameKey
DefaultPasswdKey = "j_password"
// DefaultRelayStateKey is the key to parse HTML and extract saml auth information.
DefaultRelayStateKey = "RelayState"
// DefaultSAMLResponseKey is used as well as DefaultRelayStateKey
DefaultSAMLResponseKey = "SAMLResponse"
// DefaultAuthDomain is the domain of auth server.
DefaultAuthDomain = "auth.cis.kit.ac.jp"
// ShibbolethLoginURL is the default login url.
ShibbolethLoginURL = "https://portal.student.kit.ac.jp/"
// This pair will send with username and password.
// The auth server will require this params.
eventIDProceedKey = "_eventId_proceed"
eventIDProceedVal = ""
// These values are required to skip confirmation page.
shibIdpLsExceptionKey = "shib_idp_ls_exception.shib_idp_session_ss"
shibIdpLsExceptionVal = ""
shibIdpLsSuccessKey = "shib_idp_ls_success.shib_idp_session_ss"
shibIdpLsSuccessVal = "true"
)
// Config struct will have settings for saml authentication.
type Config struct {
// Username key is used when this module POST auth information to auth server.
ShibbolethUsernameKey string
// Password key is used as well as Username key.
ShibbolethPasswordKey string
// Domain information of auth server.
ShibbolethAuthDomain string
// Url to login
ShibbolethLoginURL string
// This params has an additionally information to auth.
// POST with username and password.
ShibbolethHiddenParams url.Values
// When appear webstorage confirmation during authentication steps, this params send to the server.
ShibbolethPassConfirmationParams url.Values
}
// GetDefaultConfig will return the default configuration. It is enough to authenticate typically.
func GetDefaultConfig() *Config {
var (
defaultHiddenParams = url.Values{}
defaultPassConfirmationParams = url.Values{}
)
defaultHiddenParams.Add(eventIDProceedKey, eventIDProceedVal)
defaultPassConfirmationParams.Add(shibIdpLsExceptionKey, shibIdpLsExceptionVal)
defaultPassConfirmationParams.Add(shibIdpLsSuccessKey, shibIdpLsSuccessVal)
defaultPassConfirmationParams.Add(eventIDProceedKey, eventIDProceedVal)
return &Config{
ShibbolethUsernameKey: DefaultUnameKey,
ShibbolethPasswordKey: DefaultPasswdKey,
ShibbolethAuthDomain: DefaultAuthDomain,
ShibbolethLoginURL: ShibbolethLoginURL,
ShibbolethHiddenParams: defaultHiddenParams,
ShibbolethPassConfirmationParams: defaultPassConfirmationParams,
}
}