-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathconfig.go
46 lines (34 loc) · 1.92 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
package main
import (
log "github.com/sirupsen/logrus"
)
// Config - application config
type Config struct {
Listen string `default:"0.0.0.0:8888" split_words:"true" desc:"Host and port to listen on"`
LogFormat string `default:"txt" split_words:"true" desc:"Log format. Allowed values are 'txt' and 'json'"`
LogLevel string `default:"info" split_words:"true"`
URLPathSignIn string `default:"/sign_in" envconfig:"URL_PATH_SIGN_IN"`
URLPathAuth string `default:"/auth" envconfig:"URL_PATH_AUTH"`
MessageAuthRequired string `default:"Authorisation required" split_words:"true"`
Upstream string `default:"" split_words:"true"`
PassHostHeader bool `default:"true" split_words:"true"`
RedirectQueryAttribute string `default:"" split_words:"true" desc:"Query attribute that holds URL to redirect to after successful sign in (sign in only mode)"`
LdapServer string `default:"" split_words:"true" desc:"LDAP server name URL"`
LdapBase string `default:"" split_words:"true"`
LdapBindDN string `default:"" envconfig:"LDAP_BIND_DN"`
LdapBindPassword string `default:"" split_words:"true"`
LdapUserFilter string `default:"" split_words:"true"`
LdapGroupFilter string `default:"" split_words:"true"`
HeadersMap map[string]string `default:"" split_words:"true" desc:"Comma-separated \"HTTP header\":\"LDAP attribute\" values. \"X-\" prefix will be enforced for all headers."`
GroupHeader string `default:"" split_words:"true" desc:"HTTP header name that holds user group name to filter by, e.g. X-Ldap-Group. * in header value mean no group filter. Multiple groups should be comma-separated and search done using OR filter."`
}
func initLog(c *Config) error {
if "json" == c.LogFormat {
log.SetFormatter(&log.JSONFormatter{})
}
level, err := log.ParseLevel(c.LogLevel)
if err == nil {
log.SetLevel(level)
}
return err
}