mirror of
https://github.com/gravitl/netmaker.git
synced 2026-04-22 16:07:11 +08:00
NM-258: add host claim verfication to token validation
This commit is contained in:
@@ -262,6 +262,12 @@ func VerifyHostToken(tokenString string) (hostID string, mac string, network str
|
||||
})
|
||||
|
||||
if token != nil && token.Valid {
|
||||
if !strings.HasPrefix(claims.Subject, "node|") {
|
||||
return "", "", "", errors.New("not a host token")
|
||||
}
|
||||
if claims.ID == "" {
|
||||
return "", "", "", errors.New("invalid host token: missing host ID")
|
||||
}
|
||||
return claims.ID, claims.MacAddress, claims.Network, nil
|
||||
}
|
||||
return "", "", "", err
|
||||
|
||||
Reference in New Issue
Block a user