mirror of
https://github.com/juanfont/headscale.git
synced 2024-12-25 01:07:52 +00:00
Rename idKey to machineKey to keep consistency
This commit is contained in:
parent
fdd64d98c8
commit
dcbf289470
31
api.go
31
api.go
@ -288,7 +288,7 @@ func (h *Headscale) getMapKeepAliveResponse(
|
|||||||
|
|
||||||
func (h *Headscale) handleMachineLogOut(
|
func (h *Headscale) handleMachineLogOut(
|
||||||
ctx *gin.Context,
|
ctx *gin.Context,
|
||||||
idKey wgkey.Key,
|
machineKey wgkey.Key,
|
||||||
machine Machine,
|
machine Machine,
|
||||||
) {
|
) {
|
||||||
resp := tailcfg.RegisterResponse{}
|
resp := tailcfg.RegisterResponse{}
|
||||||
@ -303,7 +303,7 @@ func (h *Headscale) handleMachineLogOut(
|
|||||||
resp.AuthURL = ""
|
resp.AuthURL = ""
|
||||||
resp.MachineAuthorized = false
|
resp.MachineAuthorized = false
|
||||||
resp.User = *machine.Namespace.toUser()
|
resp.User = *machine.Namespace.toUser()
|
||||||
respBody, err := encode(resp, &idKey, h.privateKey)
|
respBody, err := encode(resp, &machineKey, h.privateKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().
|
log.Error().
|
||||||
Str("handler", "Registration").
|
Str("handler", "Registration").
|
||||||
@ -318,7 +318,7 @@ func (h *Headscale) handleMachineLogOut(
|
|||||||
|
|
||||||
func (h *Headscale) handleMachineValidRegistration(
|
func (h *Headscale) handleMachineValidRegistration(
|
||||||
ctx *gin.Context,
|
ctx *gin.Context,
|
||||||
idKey wgkey.Key,
|
machineKey wgkey.Key,
|
||||||
machine Machine,
|
machine Machine,
|
||||||
) {
|
) {
|
||||||
resp := tailcfg.RegisterResponse{}
|
resp := tailcfg.RegisterResponse{}
|
||||||
@ -334,7 +334,7 @@ func (h *Headscale) handleMachineValidRegistration(
|
|||||||
resp.User = *machine.Namespace.toUser()
|
resp.User = *machine.Namespace.toUser()
|
||||||
resp.Login = *machine.Namespace.toLogin()
|
resp.Login = *machine.Namespace.toLogin()
|
||||||
|
|
||||||
respBody, err := encode(resp, &idKey, h.privateKey)
|
respBody, err := encode(resp, &machineKey, h.privateKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().
|
log.Error().
|
||||||
Str("handler", "Registration").
|
Str("handler", "Registration").
|
||||||
@ -353,7 +353,8 @@ func (h *Headscale) handleMachineValidRegistration(
|
|||||||
|
|
||||||
func (h *Headscale) handleMachineExpired(
|
func (h *Headscale) handleMachineExpired(
|
||||||
ctx *gin.Context,
|
ctx *gin.Context,
|
||||||
idKey wgkey.Key,
|
machineKey wgkey.Key,
|
||||||
|
registerRequest tailcfg.RegisterRequest,
|
||||||
machine Machine,
|
machine Machine,
|
||||||
) {
|
) {
|
||||||
resp := tailcfg.RegisterResponse{}
|
resp := tailcfg.RegisterResponse{}
|
||||||
@ -397,7 +398,7 @@ func (h *Headscale) handleMachineExpired(
|
|||||||
|
|
||||||
func (h *Headscale) handleMachineRefreshKey(
|
func (h *Headscale) handleMachineRefreshKey(
|
||||||
ctx *gin.Context,
|
ctx *gin.Context,
|
||||||
idKey wgkey.Key,
|
machineKey wgkey.Key,
|
||||||
registerRequest tailcfg.RegisterRequest,
|
registerRequest tailcfg.RegisterRequest,
|
||||||
machine Machine,
|
machine Machine,
|
||||||
) {
|
) {
|
||||||
@ -412,7 +413,7 @@ func (h *Headscale) handleMachineRefreshKey(
|
|||||||
|
|
||||||
resp.AuthURL = ""
|
resp.AuthURL = ""
|
||||||
resp.User = *machine.Namespace.toUser()
|
resp.User = *machine.Namespace.toUser()
|
||||||
respBody, err := encode(resp, &idKey, h.privateKey)
|
respBody, err := encode(resp, &machineKey, h.privateKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().
|
log.Error().
|
||||||
Str("handler", "Registration").
|
Str("handler", "Registration").
|
||||||
@ -427,7 +428,7 @@ func (h *Headscale) handleMachineRefreshKey(
|
|||||||
|
|
||||||
func (h *Headscale) handleMachineRegistrationNew(
|
func (h *Headscale) handleMachineRegistrationNew(
|
||||||
ctx *gin.Context,
|
ctx *gin.Context,
|
||||||
idKey wgkey.Key,
|
machineKey wgkey.Key,
|
||||||
registerRequest tailcfg.RegisterRequest,
|
registerRequest tailcfg.RegisterRequest,
|
||||||
machine Machine,
|
machine Machine,
|
||||||
) {
|
) {
|
||||||
@ -442,11 +443,11 @@ func (h *Headscale) handleMachineRegistrationNew(
|
|||||||
resp.AuthURL = fmt.Sprintf(
|
resp.AuthURL = fmt.Sprintf(
|
||||||
"%s/oidc/register/%s",
|
"%s/oidc/register/%s",
|
||||||
strings.TrimSuffix(h.cfg.ServerURL, "/"),
|
strings.TrimSuffix(h.cfg.ServerURL, "/"),
|
||||||
idKey.HexString(),
|
machineKey.HexString(),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
resp.AuthURL = fmt.Sprintf("%s/register?key=%s",
|
resp.AuthURL = fmt.Sprintf("%s/register?key=%s",
|
||||||
strings.TrimSuffix(h.cfg.ServerURL, "/"), idKey.HexString())
|
strings.TrimSuffix(h.cfg.ServerURL, "/"), machineKey.HexString())
|
||||||
}
|
}
|
||||||
|
|
||||||
if !registerRequest.Expiry.IsZero() {
|
if !registerRequest.Expiry.IsZero() {
|
||||||
@ -456,7 +457,7 @@ func (h *Headscale) handleMachineRegistrationNew(
|
|||||||
Time("expiry", registerRequest.Expiry).
|
Time("expiry", registerRequest.Expiry).
|
||||||
Msg("Non-zero expiry time requested, adding to cache")
|
Msg("Non-zero expiry time requested, adding to cache")
|
||||||
h.requestedExpiryCache.Set(
|
h.requestedExpiryCache.Set(
|
||||||
idKey.HexString(),
|
machineKey.HexString(),
|
||||||
registerRequest.Expiry,
|
registerRequest.Expiry,
|
||||||
requestedExpiryCacheExpiration,
|
requestedExpiryCacheExpiration,
|
||||||
)
|
)
|
||||||
@ -465,7 +466,7 @@ func (h *Headscale) handleMachineRegistrationNew(
|
|||||||
machine.NodeKey = wgkey.Key(registerRequest.NodeKey).HexString() // save the NodeKey
|
machine.NodeKey = wgkey.Key(registerRequest.NodeKey).HexString() // save the NodeKey
|
||||||
h.db.Save(&machine)
|
h.db.Save(&machine)
|
||||||
|
|
||||||
respBody, err := encode(resp, &idKey, h.privateKey)
|
respBody, err := encode(resp, &machineKey, h.privateKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().
|
log.Error().
|
||||||
Str("handler", "Registration").
|
Str("handler", "Registration").
|
||||||
@ -480,7 +481,7 @@ func (h *Headscale) handleMachineRegistrationNew(
|
|||||||
|
|
||||||
func (h *Headscale) handleAuthKey(
|
func (h *Headscale) handleAuthKey(
|
||||||
ctx *gin.Context,
|
ctx *gin.Context,
|
||||||
idKey wgkey.Key,
|
machineKey wgkey.Key,
|
||||||
registerRequest tailcfg.RegisterRequest,
|
registerRequest tailcfg.RegisterRequest,
|
||||||
machine Machine,
|
machine Machine,
|
||||||
) {
|
) {
|
||||||
@ -497,7 +498,7 @@ func (h *Headscale) handleAuthKey(
|
|||||||
Err(err).
|
Err(err).
|
||||||
Msg("Failed authentication via AuthKey")
|
Msg("Failed authentication via AuthKey")
|
||||||
resp.MachineAuthorized = false
|
resp.MachineAuthorized = false
|
||||||
respBody, err := encode(resp, &idKey, h.privateKey)
|
respBody, err := encode(resp, &machineKey, h.privateKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().
|
log.Error().
|
||||||
Str("func", "handleAuthKey").
|
Str("func", "handleAuthKey").
|
||||||
@ -567,7 +568,7 @@ func (h *Headscale) handleAuthKey(
|
|||||||
|
|
||||||
resp.MachineAuthorized = true
|
resp.MachineAuthorized = true
|
||||||
resp.User = *pak.Namespace.toUser()
|
resp.User = *pak.Namespace.toUser()
|
||||||
respBody, err := encode(resp, &idKey, h.privateKey)
|
respBody, err := encode(resp, &machineKey, h.privateKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().
|
log.Error().
|
||||||
Str("func", "handleAuthKey").
|
Str("func", "handleAuthKey").
|
||||||
|
Loading…
x
Reference in New Issue
Block a user