This commit is contained in:
parent
173964a6fc
commit
21ef2f1372
5 changed files with 20 additions and 6 deletions
|
|
@ -143,7 +143,10 @@ func (l loginChecker) registerUser(username, remoteAddr string, ent ARPEntry) (n
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req.Header.Add("X-ADLIN-Authentication", base64.StdEncoding.EncodeToString(hmac.New(sha512.New, []byte(loginSalt)).Sum([]byte(fmt.Sprintf("%d", time.Now().Unix()/10)))))
|
||||
|
||||
h := hmac.New(sha512.New, []byte(loginSalt))
|
||||
h.Write([]byte(fmt.Sprintf("%d", time.Now().Unix()/10)))
|
||||
req.Header.Add("X-ADLIN-Authentication", base64.StdEncoding.EncodeToString(h.Sum(nil)))
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
|
||||
client := &http.Client{}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ func registerUser(tplPath string, filename string, username string, ip net.IP) e
|
|||
defer userfd.Close()
|
||||
|
||||
pkey := hmac.New(sha512.New512_224, []byte(loginSalt))
|
||||
pkey.Write([]byte(username))
|
||||
|
||||
if len(ip.To4()) != 4 {
|
||||
return fmt.Errorf("Unable to assign a protected IP.")
|
||||
|
|
@ -45,7 +46,7 @@ func registerUser(tplPath string, filename string, username string, ip net.IP) e
|
|||
return err
|
||||
} else if err := pxeTmpl.Execute(userfd, map[string]string{
|
||||
"username": username,
|
||||
"pkey": fmt.Sprintf("%x", pkey.Sum([]byte(username))),
|
||||
"pkey": fmt.Sprintf("%x", pkey.Sum(nil)),
|
||||
"ip": ip.String(),
|
||||
}); err != nil {
|
||||
return err
|
||||
|
|
|
|||
Reference in a new issue