added more parameters for authentication (host & domain)
This commit is contained in:
parent
6432c042f5
commit
561a800a1a
@ -48,10 +48,20 @@ type Error struct {
|
|||||||
// To gather admin rights the username password combination must match with the credentials given by the env var.
|
// To gather admin rights the username password combination must match with the credentials given by the env var.
|
||||||
func (h *Handler) AuthenticateUpdate(username, password string, c echo.Context) (bool, error) {
|
func (h *Handler) AuthenticateUpdate(username, password string, c echo.Context) (bool, error) {
|
||||||
h.CheckClearInterval()
|
h.CheckClearInterval()
|
||||||
|
reqParameter := c.QueryParam("hostname")
|
||||||
|
reqArr := strings.SplitN(reqParameter, ".", 2)
|
||||||
|
if len(reqArr) != 2 {
|
||||||
|
log.Error("Error: Something wrong with the hostname parameter")
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
host := &model.Host{}
|
host := &model.Host{}
|
||||||
if err := h.DB.Where(&model.Host{UserName: username, Password: password}).First(host).Error; err != nil {
|
if err := h.DB.Where(&model.Host{UserName: username, Password: password, Hostname: reqArr[0], Domain: reqArr[1]}).First(host).Error; err != nil {
|
||||||
log.Error("Error:", err)
|
log.Error("Error: ", err)
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
if host.ID == 0 {
|
||||||
|
log.Error("hostname or user user credentials unknown")
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
c.Set("updateHost", host)
|
c.Set("updateHost", host)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user