Skip to content

Commit ebff185

Browse files
authored
Revert "NM-38: User Config Fixes (#3559)" (#3562)
This reverts commit 9d65c62.
1 parent 9d65c62 commit ebff185

File tree

13 files changed

+66
-140
lines changed

13 files changed

+66
-140
lines changed

controllers/ext_client.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -726,17 +726,8 @@ func createExtClient(w http.ResponseWriter, r *http.Request) {
726726
return
727727
}
728728
for _, extclient := range extclients {
729-
// if device id is sent, then make sure extclient with the same device id
730-
// does not exist.
731-
if customExtClient.DeviceID != "" && extclient.DeviceID == customExtClient.DeviceID &&
732-
extclient.OwnerID == caller.UserName && nodeid == extclient.IngressGatewayID {
733-
err = errors.New("remote client config already exists on the gateway")
734-
slog.Error("failed to create extclient", "user", userName, "error", err)
735-
logic.ReturnErrorResponse(w, r, logic.FormatError(err, "badrequest"))
736-
return
737-
}
738-
739-
if extclient.OwnerID == caller.UserName && nodeid == extclient.IngressGatewayID {
729+
if extclient.RemoteAccessClientID != "" &&
730+
extclient.RemoteAccessClientID == customExtClient.RemoteAccessClientID && extclient.OwnerID == caller.UserName && nodeid == extclient.IngressGatewayID {
740731
// extclient on the gw already exists for the remote access client
741732
err = errors.New("remote client config already exists on the gateway")
742733
slog.Error("failed to create extclient", "user", userName, "error", err)
@@ -783,7 +774,6 @@ func createExtClient(w http.ResponseWriter, r *http.Request) {
783774
extclient.Enabled = parentNetwork.DefaultACL == "yes"
784775
}
785776
extclient.Os = customExtClient.Os
786-
extclient.DeviceID = customExtClient.DeviceID
787777
extclient.DeviceName = customExtClient.DeviceName
788778
if customExtClient.IsAlreadyConnectedToInetGw {
789779
slog.Warn("RAC/Client is already connected to internet gateway. this may mask their real IP address", "client IP", customExtClient.PublicEndpoint)

controllers/server.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
package controller
22

33
import (
4-
"context"
54
"encoding/json"
65
"errors"
7-
"github.com/gravitl/netmaker/db"
8-
"github.com/gravitl/netmaker/schema"
96
"github.com/google/go-cmp/cmp"
107
"net/http"
118
"os"
@@ -113,7 +110,10 @@ func getUsage(w http.ResponseWriter, _ *http.Request) {
113110
if err == nil {
114111
serverUsage.Ingresses = len(ingresses)
115112
}
116-
serverUsage.Egresses, _ = (&schema.Egress{}).Count(db.WithContext(context.TODO()))
113+
egresses, err := logic.GetAllEgresses()
114+
if err == nil {
115+
serverUsage.Egresses = len(egresses)
116+
}
117117
relays, err := logic.GetRelays()
118118
if err == nil {
119119
serverUsage.Relays = len(relays)

controllers/user.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,14 +1324,6 @@ func deleteUser(w http.ResponseWriter, r *http.Request) {
13241324
return
13251325
}
13261326
}
1327-
1328-
if user.AuthType == models.OAuth || user.ExternalIdentityProviderID != "" {
1329-
err = fmt.Errorf("cannot delete idp user %s", username)
1330-
logger.Log(0, username, "failed to delete user: ", err.Error())
1331-
logic.ReturnErrorResponse(w, r, logic.FormatError(err, "badrequest"))
1332-
return
1333-
}
1334-
13351327
err = logic.DeleteUser(username)
13361328
if err != nil {
13371329
logger.Log(0, username,

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ toolchain go1.23.7
77
require (
88
github.com/blang/semver v3.5.1+incompatible
99
github.com/eclipse/paho.mqtt.golang v1.5.0
10-
github.com/go-playground/validator/v10 v10.27.0
10+
github.com/go-playground/validator/v10 v10.26.0
1111
github.com/golang-jwt/jwt/v4 v4.5.2
1212
github.com/google/uuid v1.6.0
1313
github.com/gorilla/handlers v1.5.2
@@ -48,9 +48,9 @@ require (
4848
github.com/matryer/is v1.4.1
4949
github.com/pquerna/otp v1.5.0
5050
github.com/spf13/cobra v1.9.1
51-
google.golang.org/api v0.240.0
51+
google.golang.org/api v0.238.0
5252
gopkg.in/mail.v2 v2.3.1
53-
gorm.io/datatypes v1.2.6
53+
gorm.io/datatypes v1.2.5
5454
gorm.io/driver/postgres v1.6.0
5555
gorm.io/driver/sqlite v1.6.0
5656
gorm.io/gorm v1.30.0

go.sum

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o
3737
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
3838
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
3939
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
40-
github.com/go-playground/validator/v10 v10.27.0 h1:w8+XrWVMhGkxOaaowyKH35gFydVHOvC0/uWoy2Fzwn4=
41-
github.com/go-playground/validator/v10 v10.27.0/go.mod h1:I5QpIEbmr8On7W0TktmJAumgzX4CA1XNl4ZmDuVHKKo=
40+
github.com/go-playground/validator/v10 v10.26.0 h1:SP05Nqhjcvz81uJaRfEV0YBSSSGMc/iMaVtFbr3Sw2k=
41+
github.com/go-playground/validator/v10 v10.26.0/go.mod h1:I5QpIEbmr8On7W0TktmJAumgzX4CA1XNl4ZmDuVHKKo=
4242
github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
4343
github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y=
4444
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
@@ -174,8 +174,8 @@ golang.org/x/time v0.12.0 h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE=
174174
golang.org/x/time v0.12.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg=
175175
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20221104135756-97bc4ad4a1cb h1:9aqVcYEDHmSNb0uOWukxV5lHV09WqiSiCuhEgWNETLY=
176176
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20221104135756-97bc4ad4a1cb/go.mod h1:mQqgjkW8GQQcJQsbBvK890TKqUK1DfKWkuBGbOkuMHQ=
177-
google.golang.org/api v0.240.0 h1:PxG3AA2UIqT1ofIzWV2COM3j3JagKTKSwy7L6RHNXNU=
178-
google.golang.org/api v0.240.0/go.mod h1:cOVEm2TpdAGHL2z+UwyS+kmlGr3bVWQQ6sYEqkKje50=
177+
google.golang.org/api v0.238.0 h1:+EldkglWIg/pWjkq97sd+XxH7PxakNYoe/rkSTbnvOs=
178+
google.golang.org/api v0.238.0/go.mod h1:cOVEm2TpdAGHL2z+UwyS+kmlGr3bVWQQ6sYEqkKje50=
179179
google.golang.org/genproto v0.0.0-20250505200425-f936aa4a68b2 h1:1tXaIXCracvtsRxSBsYDiSBN0cuJvM7QYW+MrpIRY78=
180180
google.golang.org/genproto v0.0.0-20250505200425-f936aa4a68b2/go.mod h1:49MsLSx0oWMOZqcpB3uL8ZOkAh1+TndpJ8ONoCBWiZk=
181181
google.golang.org/genproto/googleapis/api v0.0.0-20250505200425-f936aa4a68b2 h1:vPV0tzlsK6EzEDHNNH5sa7Hs9bd7iXR7B1tSiPepkV0=
@@ -196,16 +196,16 @@ gopkg.in/mail.v2 v2.3.1/go.mod h1:htwXN1Qh09vZJ1NVKxQqHPBaCBbzKhp5GzuJEA4VJWw=
196196
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
197197
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
198198
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
199-
gorm.io/datatypes v1.2.6 h1:KafLdXvFUhzNeL2ncm03Gl3eTLONQfNKZ+wJ+9Y4Nck=
200-
gorm.io/datatypes v1.2.6/go.mod h1:M2iO+6S3hhi4nAyYe444Pcb0dcIiOMJ7QHaUXxyiNZY=
199+
gorm.io/datatypes v1.2.5 h1:9UogU3jkydFVW1bIVVeoYsTpLRgwDVW3rHfJG6/Ek9I=
200+
gorm.io/datatypes v1.2.5/go.mod h1:I5FUdlKpLb5PMqeMQhm30CQ6jXP8Rj89xkTeCSAaAD4=
201201
gorm.io/driver/mysql v1.5.6 h1:Ld4mkIickM+EliaQZQx3uOJDJHtrd70MxAUqWqlx3Y8=
202202
gorm.io/driver/mysql v1.5.6/go.mod h1:sEtPWMiqiN1N1cMXoXmBbd8C6/l+TESwriotuRRpkDM=
203203
gorm.io/driver/postgres v1.6.0 h1:2dxzU8xJ+ivvqTRph34QX+WrRaJlmfyPqXmoGVjMBa4=
204204
gorm.io/driver/postgres v1.6.0/go.mod h1:vUw0mrGgrTK+uPHEhAdV4sfFELrByKVGnaVRkXDhtWo=
205205
gorm.io/driver/sqlite v1.6.0 h1:WHRRrIiulaPiPFmDcod6prc4l2VGVWHz80KspNsxSfQ=
206206
gorm.io/driver/sqlite v1.6.0/go.mod h1:AO9V1qIQddBESngQUKWL9yoH93HIeA1X6V633rBwyT8=
207-
gorm.io/driver/sqlserver v1.6.0 h1:VZOBQVsVhkHU/NzNhRJKoANt5pZGQAS1Bwc6m6dgfnc=
208-
gorm.io/driver/sqlserver v1.6.0/go.mod h1:WQzt4IJo/WHKnckU9jXBLMJIVNMVeTu25dnOzehntWw=
207+
gorm.io/driver/sqlserver v1.5.4 h1:xA+Y1KDNspv79q43bPyjDMUgHoYHLhXYmdFcYPobg8g=
208+
gorm.io/driver/sqlserver v1.5.4/go.mod h1:+frZ/qYmuna11zHPlh5oc2O6ZA/lS88Keb0XSH1Zh/g=
209209
gorm.io/gorm v1.25.7/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
210210
gorm.io/gorm v1.30.0 h1:qbT5aPv1UH8gI99OsRlvDToLxW5zR7FzS9acZDOZcgs=
211211
gorm.io/gorm v1.30.0/go.mod h1:8Z33v652h4//uMA76KjeDH8mJXPm1QNCYrMeatR0DOE=

logic/extpeers.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -433,9 +433,6 @@ func UpdateExtClient(old *models.ExtClient, update *models.CustomExtClient) mode
433433
if update.Country != "" && update.Country != old.Country {
434434
new.Country = update.Country
435435
}
436-
if update.DeviceID != "" && old.DeviceID == "" {
437-
new.DeviceID = update.DeviceID
438-
}
439436
return new
440437
}
441438

@@ -487,7 +484,7 @@ func GetAllExtClientsWithStatus(status models.NodeStatus) ([]models.ExtClient, e
487484
var validExtClients []models.ExtClient
488485
for _, extClient := range extClients {
489486
node := extClient.ConvertToStaticNode()
490-
GetNodeStatus(&node, false)
487+
GetNodeCheckInStatus(&node, false)
491488

492489
if node.Status == status {
493490
validExtClients = append(validExtClients, extClient)

logic/hosts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func GetAllHostsWithStatus(status models.NodeStatus) ([]models.Host, error) {
125125

126126
nodes := GetHostNodes(&host)
127127
for _, node := range nodes {
128-
getNodeCheckInStatus(&node, false)
128+
GetNodeCheckInStatus(&node, false)
129129
if node.Status == status {
130130
validHosts = append(validHosts, host)
131131
break

logic/nodes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ func AddStatusToNodes(nodes []models.Node, statusCall bool) (nodesWithStatus []m
471471
if statusCall {
472472
GetNodeStatus(&node, aclDefaultPolicyStatusMap[node.Network])
473473
} else {
474-
getNodeCheckInStatus(&node, true)
474+
GetNodeCheckInStatus(&node, true)
475475
}
476476

477477
nodesWithStatus = append(nodesWithStatus, node)

logic/status.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import (
66
"github.com/gravitl/netmaker/models"
77
)
88

9-
var GetNodeStatus = getNodeCheckInStatus
9+
var GetNodeStatus = GetNodeCheckInStatus
1010

11-
func getNodeCheckInStatus(node *models.Node, t bool) {
11+
func GetNodeCheckInStatus(node *models.Node, t bool) {
1212
// On CE check only last check-in time
1313
if node.IsStatic {
1414
if !node.StaticNode.Enabled {

models/extclient.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ type ExtClient struct {
2424
PostDown string `json:"postdown" bson:"postdown"`
2525
Tags map[TagID]struct{} `json:"tags"`
2626
Os string `json:"os"`
27-
DeviceID string `json:"device_id"`
2827
DeviceName string `json:"device_name"`
2928
PublicEndpoint string `json:"public_endpoint"`
3029
Country string `json:"country"`
@@ -45,7 +44,6 @@ type CustomExtClient struct {
4544
PostDown string `json:"postdown" bson:"postdown" validate:"max=1024"`
4645
Tags map[TagID]struct{} `json:"tags"`
4746
Os string `json:"os"`
48-
DeviceID string `json:"device_id"`
4947
DeviceName string `json:"device_name"`
5048
IsAlreadyConnectedToInetGw bool `json:"is_already_connected_to_inet_gw"`
5149
PublicEndpoint string `json:"public_endpoint"`

0 commit comments

Comments
 (0)