Add AlreadyUsed field to Auth Keys (fixes #157 and #158)

This commit is contained in:
Juan Font Alonso 2021-10-13 18:13:26 +02:00
parent dd1e425d02
commit 30788e1a70
4 changed files with 20 additions and 3 deletions

3
api.go
View file

@ -395,6 +395,9 @@ func (h *Headscale) handleAuthKey(c *gin.Context, db *gorm.DB, idKey wgkey.Key,
m.RegisterMethod = "authKey"
db.Save(&m)
pak.AlreadyUsed = true
db.Save(&pak)
resp.MachineAuthorized = true
resp.User = *pak.Namespace.toUser()
respBody, err := encode(resp, &idKey, h.privateKey)