Custom auth message
This commit is contained in:
parent
05f005707c
commit
12f94aeb74
7
k8s.yaml
7
k8s.yaml
|
@ -6,20 +6,21 @@ data:
|
||||||
config.yaml: |
|
config.yaml: |
|
||||||
web: 0.0.0.0:5555
|
web: 0.0.0.0:5555
|
||||||
path: /
|
path: /
|
||||||
|
message: "LDAP Login"
|
||||||
servers:
|
servers:
|
||||||
- ldaps://ldap1.example.com:636
|
- ldaps://ldap1.example.com:636
|
||||||
- ldaps://ldap2.example.com:636
|
- ldaps://ldap2.example.com:636
|
||||||
- ldaps://ldap3.example.com:636
|
- ldaps://ldap3.example.com:636
|
||||||
auth:
|
auth:
|
||||||
bindDN: uid=seviceaccount,cn=users,dc=example,dc=com
|
bindDN: cn=seviceaccount,cn=users,o=company
|
||||||
bindPW: password
|
bindPW: password
|
||||||
user:
|
user:
|
||||||
baseDN: ou=users,dc=example,dc=com
|
baseDN: ou=users,o=company
|
||||||
filter: "(cn={0})"
|
filter: "(cn={0})"
|
||||||
requiredGroups:
|
requiredGroups:
|
||||||
- appAdmin
|
- appAdmin
|
||||||
group:
|
group:
|
||||||
baseDN: ou=groups,dc=example,dc=com
|
baseDN: ou=groups,o=company
|
||||||
groupAttr: cn
|
groupAttr: cn
|
||||||
filter: "(member={0})"
|
filter: "(member={0})"
|
||||||
timeout:
|
timeout:
|
||||||
|
|
|
@ -27,6 +27,7 @@ type TimeoutConfig struct {
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Web string `yaml:"web"`
|
Web string `yaml:"web"`
|
||||||
Path string `yaml:"path"`
|
Path string `yaml:"path"`
|
||||||
|
Message string `yaml:"message"`
|
||||||
Servers []string `yaml:"servers"`
|
Servers []string `yaml:"servers"`
|
||||||
Auth AuthConfig `yaml:"auth"`
|
Auth AuthConfig `yaml:"auth"`
|
||||||
User UserConfig `yaml:"user"`
|
User UserConfig `yaml:"user"`
|
||||||
|
|
|
@ -16,8 +16,9 @@ import (
|
||||||
var (
|
var (
|
||||||
configFile = flag.String("config", "/etc/nginx-ldap-auth/config.yaml", "Configuration file")
|
configFile = flag.String("config", "/etc/nginx-ldap-auth/config.yaml", "Configuration file")
|
||||||
config = Config{
|
config = Config{
|
||||||
Web: "0.0.0.0:5555",
|
Web: "0.0.0.0:5555",
|
||||||
Path: "/",
|
Path: "/",
|
||||||
|
Message: "LDAP Login",
|
||||||
User: UserConfig{
|
User: UserConfig{
|
||||||
Filter: "(cn={0})",
|
Filter: "(cn={0})",
|
||||||
},
|
},
|
||||||
|
@ -84,7 +85,7 @@ func handler(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("WWW-Authenticate", "Basic realm=\"LDAP Login\"")
|
w.Header().Set("WWW-Authenticate", fmt.Sprintf("Basic realm=\"%s\"", config.Message))
|
||||||
w.WriteHeader(http.StatusUnauthorized)
|
w.WriteHeader(http.StatusUnauthorized)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue