-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
37 lines (32 loc) · 1.01 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
package airlock
// Config type that expose all the requirements that AirLock needs
// in order to issue token and performs others operations
type Config struct {
tokenExpireIn int64
signKey []byte
storeInCookie bool
redirectTo string
redirectBackTo string
}
// NewConfig return a new instance of type config
// accept if the user wants store the token
// as cookie, the token expiration time
// and the encryption key and the
// redirection path
func NewConfig(storeInCookie bool, expireIn int64, encryptionKey string, redirectTo *string, redirectBackTo *string) Config {
var defaultPathToRedirect = "home"
if redirectTo != nil {
defaultPathToRedirect = *redirectTo
}
var defaultPathToRedirectBackTo = "/auth/login"
if redirectBackTo != nil {
defaultPathToRedirectBackTo = *redirectBackTo
}
return Config{
tokenExpireIn: expireIn,
signKey: []byte(encryptionKey),
storeInCookie: storeInCookie,
redirectTo: defaultPathToRedirect,
redirectBackTo: defaultPathToRedirectBackTo,
}
}