mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-05 16:57:51 +08:00
restructuring continued
This commit is contained in:
@@ -12,11 +12,12 @@ import (
|
||||
var jwtSecretKey = []byte("(BytesOverTheWire)")
|
||||
|
||||
// CreateJWT func will used to create the JWT while signing in and signing out
|
||||
func CreateJWT(macaddress string, network string) (response string, err error) {
|
||||
func CreateJWT(uuid string, macAddress string, network string) (response string, err error) {
|
||||
expirationTime := time.Now().Add(5 * time.Minute)
|
||||
claims := &models.Claims{
|
||||
MacAddress: macaddress,
|
||||
ID: uuid,
|
||||
Network: network,
|
||||
MacAddress: macAddress,
|
||||
StandardClaims: jwt.StandardClaims{
|
||||
ExpiresAt: expirationTime.Unix(),
|
||||
},
|
||||
@@ -73,13 +74,13 @@ func VerifyUserToken(tokenString string) (username string, networks []string, is
|
||||
}
|
||||
|
||||
// VerifyToken - gRPC [nodes] Only
|
||||
func VerifyToken(tokenString string) (macaddress string, network string, err error) {
|
||||
func VerifyToken(tokenString string) (nodeID string, mac string, network string, err error) {
|
||||
claims := &models.Claims{}
|
||||
|
||||
//this may be a stupid way of serving up a master key
|
||||
//TODO: look into a different method. Encryption?
|
||||
if tokenString == servercfg.GetMasterKey() {
|
||||
return "mastermac", "", nil
|
||||
return "mastermac", "", "", nil
|
||||
}
|
||||
|
||||
token, err := jwt.ParseWithClaims(tokenString, claims, func(token *jwt.Token) (interface{}, error) {
|
||||
@@ -87,7 +88,7 @@ func VerifyToken(tokenString string) (macaddress string, network string, err err
|
||||
})
|
||||
|
||||
if token != nil {
|
||||
return claims.MacAddress, claims.Network, nil
|
||||
return claims.ID, claims.MacAddress, claims.Network, nil
|
||||
}
|
||||
return "", "", err
|
||||
return "", "", "", err
|
||||
}
|
||||
|
Reference in New Issue
Block a user