log web access

This commit is contained in:
Xavier Henner
2019-07-17 15:13:40 +02:00
parent e4c5718f6d
commit 0d918b7540
2 changed files with 6 additions and 4 deletions

View File

@@ -118,12 +118,13 @@ func (h *HttpServer) ajaxHandler(w http.ResponseWriter, r *http.Request) {
return
}
profile, _, _ := h.ovpn.AuthLoop(h.minProfile,
strings.Replace(r.TLS.PeerCertificates[0].Subject.CommonName, " ", "", -1), "", false)
webuser := strings.Replace(r.TLS.PeerCertificates[0].Subject.CommonName, " ", "", -1)
profile, _, _ := h.ovpn.AuthLoop(h.minProfile, webuser, "", false)
if profile != h.neededProfile {
http.Error(w, fmt.Sprintf("You need the %s profile", h.neededProfile), 403)
return
}
log.Printf("%s is connected via the web interfaces\n", webuser)
req, err := parseJsonQuery(r)
if err != nil {
@@ -141,7 +142,7 @@ func (h *HttpServer) ajaxHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "%s", jsonStr)
case "kill":
if err := h.ovpn.Kill(req.Params.Session, req.Params.Id); err != nil {
if err := h.ovpn.Kill(req.Params.Session, req.Params.Id, webuser); err != nil {
http.Error(w, fmt.Sprintf("%s", err), 500)
}
fmt.Fprintf(w, "{}")