Configuration file
This commit is contained in:
parent
079fe62bc9
commit
f0c61005dd
4
k8s.yaml
4
k8s.yaml
|
@ -13,9 +13,9 @@ data:
|
||||||
bindDN: uid=seviceaccount,cn=users,dc=example,dc=com
|
bindDN: uid=seviceaccount,cn=users,dc=example,dc=com
|
||||||
bindPW: password
|
bindPW: password
|
||||||
user:
|
user:
|
||||||
bindDN: cn=users,dc=example,dc=com
|
baseDN: cn=users,dc=example,dc=com
|
||||||
filter: "(objectClass=person)"
|
filter: "(objectClass=person)"
|
||||||
username: uid
|
userAttr: uid
|
||||||
requiredGroups:
|
requiredGroups:
|
||||||
- appAdmin
|
- appAdmin
|
||||||
group:
|
group:
|
||||||
|
|
|
@ -8,17 +8,17 @@ type AuthConfig struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserConfig struct {
|
type UserConfig struct {
|
||||||
BindDN string `yaml:"bindDN"`
|
BaseDN string `yaml:"baseDN"`
|
||||||
Filter string `yaml:"filter"`
|
Filter string `yaml:"filter"`
|
||||||
UserAttr string `yaml:"userAttr"`
|
UserAttr string `yaml:"userAttr"`
|
||||||
RequiredGroups []string `yaml:"requiredGroups"`
|
RequiredGroups []string `yaml:"requiredGroups"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GroupConfig struct {
|
type GroupConfig struct {
|
||||||
BindDN string `yaml:"bindDN"`
|
BaseDN string `yaml:"baseDN"`
|
||||||
Filter string `yaml:"filter"`
|
Filter string `yaml:"filter"`
|
||||||
UserAttr string `yaml:"userAttr"`
|
UserAttr string `yaml:"userAttr"`
|
||||||
GroupAttr string `yaml:"member"`
|
GroupAttr string `yaml:"groupAttr"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TimeoutConfig struct {
|
type TimeoutConfig struct {
|
||||||
|
|
20
src/main.go
20
src/main.go
|
@ -3,11 +3,27 @@ package main
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
|
|
||||||
|
yaml "gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
var config = flag.String("config", "/etc/nginx-ldap-auth/config.yaml", "Configuration file")
|
var configFile = flag.String("config", "/etc/nginx-ldap-auth/config.yaml", "Configuration file")
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
fmt.Printf("Value of config: %s\n", *config)
|
|
||||||
|
data, err := ioutil.ReadFile(*configFile)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Could not read file \"%s\": %v\n", *configFile, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var config Config
|
||||||
|
err = yaml.Unmarshal(data, &config)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Error on parse config: %v\n", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("Config: %+v\n", config)
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue