correct bugs on web interface
This commit is contained in:
parent
657f92a3df
commit
53131a7a3b
13
httpd.go
13
httpd.go
|
@ -49,7 +49,8 @@ func parseJsonQuery(r *http.Request) (*jsonInput, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *HttpServer) handler(w http.ResponseWriter, r *http.Request) {
|
func (h *HttpServer) handler(w http.ResponseWriter, r *http.Request) {
|
||||||
fmt.Fprintf(w, "nothing here\n")
|
w.Header().Set("Content-type", "application/javascript")
|
||||||
|
fmt.Fprintf(w, "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *HttpServer) versionHandler(w http.ResponseWriter, r *http.Request) {
|
func (h *HttpServer) versionHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -80,6 +81,8 @@ func (h *HttpServer) helpHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
func (h *HttpServer) ajaxHandler(w http.ResponseWriter, r *http.Request) {
|
func (h *HttpServer) ajaxHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
var sslUsage = []x509.ExtKeyUsage{x509.ExtKeyUsageAny}
|
var sslUsage = []x509.ExtKeyUsage{x509.ExtKeyUsageAny}
|
||||||
|
|
||||||
|
w.Header().Set("Content-type", "application/json")
|
||||||
|
|
||||||
// deactivate if there is no https auth
|
// deactivate if there is no https auth
|
||||||
if h.key == "" || h.cert == "" || h.certPool == nil {
|
if h.key == "" || h.cert == "" || h.certPool == nil {
|
||||||
http.Error(w, "No security, deactivated", 403)
|
http.Error(w, "No security, deactivated", 403)
|
||||||
|
@ -133,7 +136,7 @@ func (h *HttpServer) ajaxHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
case "stats":
|
case "stats":
|
||||||
jsonStr, err := json.Marshal(h.ovpn.Stats())
|
jsonStr, err := json.Marshal(h.ovpn.Stats())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(w, "Error : %s", err)
|
http.Error(w, fmt.Sprintf("%s", err), 500)
|
||||||
}
|
}
|
||||||
fmt.Fprintf(w, "%s", jsonStr)
|
fmt.Fprintf(w, "%s", jsonStr)
|
||||||
|
|
||||||
|
@ -141,12 +144,10 @@ func (h *HttpServer) ajaxHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
if err := h.ovpn.Kill(req.Params.Session, req.Params.Id); err != nil {
|
if err := h.ovpn.Kill(req.Params.Session, req.Params.Id); err != nil {
|
||||||
http.Error(w, fmt.Sprintf("%s", err), 500)
|
http.Error(w, fmt.Sprintf("%s", err), 500)
|
||||||
}
|
}
|
||||||
|
fmt.Fprintf(w, "{}")
|
||||||
default:
|
default:
|
||||||
http.Error(w, "Invalid request", 500)
|
http.Error(w, "Invalid request", 500)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,7 +185,7 @@ func NewHTTPServer(port, key, cert, ca, minProfile, neededProfile string, s *Ope
|
||||||
server := &http.Server{
|
server := &http.Server{
|
||||||
Addr: port,
|
Addr: port,
|
||||||
TLSConfig: &tls.Config{
|
TLSConfig: &tls.Config{
|
||||||
ClientAuth: tls.RequestClientCert,
|
ClientAuth: tls.RequireAndVerifyClientCert,
|
||||||
ClientCAs: h.certPool,
|
ClientCAs: h.certPool,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
2
ldap.go
2
ldap.go
|
@ -214,8 +214,6 @@ func (conf *ldapConfig) Auth(logins []string, pass string) (e error, userOk, pas
|
||||||
if len(ret) > 2 {
|
if len(ret) > 2 {
|
||||||
attributes = append(attributes, ret[2:]...)
|
attributes = append(attributes, ret[2:]...)
|
||||||
}
|
}
|
||||||
log.Println(attributes)
|
|
||||||
|
|
||||||
log.Printf("User %s has a valid account on %s", logins[0], s)
|
log.Printf("User %s has a valid account on %s", logins[0], s)
|
||||||
|
|
||||||
userdn := sr.Entries[0].DN
|
userdn := sr.Entries[0].DN
|
||||||
|
|
2
otp.go
2
otp.go
|
@ -41,7 +41,7 @@ func (s *OpenVpnMgt) GenerateOTPGeneric(user string, period int, algo string, se
|
||||||
// the first code is the generic one
|
// the first code is the generic one
|
||||||
codes = append(codes, code)
|
codes = append(codes, code)
|
||||||
|
|
||||||
for i := 1; i < 3; i++ {
|
for i := 1; i < 4; i++ {
|
||||||
code, _ = GenericTotpCode(secret, now.Add(-1*time.Second*time.Duration(period*i)), algo, digits, period)
|
code, _ = GenericTotpCode(secret, now.Add(-1*time.Second*time.Duration(period*i)), algo, digits, period)
|
||||||
codes = append(codes, code)
|
codes = append(codes, code)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue