Skip to content

Commit 2df02f7

Browse files
authored
Merge pull request #3504 from gravitl/depracate-rac-autodisable
chore: deprecate rac autodisable flag
1 parent 657a24e commit 2df02f7

File tree

11 files changed

+23
-44
lines changed

11 files changed

+23
-44
lines changed

config/config.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ type ServerConfig struct {
8989
DeployedByOperator bool `yaml:"deployed_by_operator"`
9090
Environment string `yaml:"environment"`
9191
JwtValidityDuration time.Duration `yaml:"jwt_validity_duration" swaggertype:"primitive,integer" format:"int64"`
92-
RacAutoDisable bool `yaml:"rac_auto_disable"`
9392
RacRestrictToSingleNetwork bool `yaml:"rac_restrict_to_single_network"`
9493
CacheEnabled string `yaml:"caching_enabled"`
9594
EndpointDetection bool `yaml:"endpoint_detection"`

controllers/user.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ func authenticateUser(response http.ResponseWriter, request *http.Request) {
377377
response.Write(successJSONResponse)
378378

379379
go func() {
380-
if servercfg.IsPro && logic.GetRacAutoDisable() {
380+
if servercfg.IsPro {
381381
// enable all associeated clients for the user
382382
clients, err := logic.GetAllExtClients()
383383
if err != nil {

logic/jwts.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,10 @@ func CreateJWT(uuid string, macAddress string, network string) (response string,
5858
// CreateUserJWT - creates a user jwt token
5959
func CreateUserAccessJwtToken(username string, role models.UserRoleID, d time.Time, tokenID string) (response string, err error) {
6060
claims := &models.UserClaims{
61-
UserName: username,
62-
Role: role,
63-
TokenType: models.AccessTokenType,
64-
Api: servercfg.GetAPIHost(),
65-
RacAutoDisable: GetRacAutoDisable() && (role != models.SuperAdminRole && role != models.AdminRole),
61+
UserName: username,
62+
Role: role,
63+
TokenType: models.AccessTokenType,
64+
Api: servercfg.GetAPIHost(),
6665
RegisteredClaims: jwt.RegisteredClaims{
6766
Issuer: "Netmaker",
6867
Subject: fmt.Sprintf("user|%s", username),
@@ -85,10 +84,9 @@ func CreateUserJWT(username string, role models.UserRoleID) (response string, er
8584
settings := GetServerSettings()
8685
expirationTime := time.Now().Add(time.Duration(settings.JwtValidityDuration) * time.Minute)
8786
claims := &models.UserClaims{
88-
UserName: username,
89-
Role: role,
90-
TokenType: models.UserIDTokenType,
91-
RacAutoDisable: settings.RacAutoDisable && (role != models.SuperAdminRole && role != models.AdminRole),
87+
UserName: username,
88+
Role: role,
89+
TokenType: models.UserIDTokenType,
9290
RegisteredClaims: jwt.RegisteredClaims{
9391
Issuer: "Netmaker",
9492
Subject: fmt.Sprintf("user|%s", username),

logic/settings.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ func GetServerSettingsFromEnv() (s models.ServerSettings) {
6262
Telemetry: servercfg.Telemetry(),
6363
BasicAuth: servercfg.IsBasicAuthEnabled(),
6464
JwtValidityDuration: servercfg.GetJwtValidityDurationFromEnv() / 60,
65-
RacAutoDisable: servercfg.GetRacAutoDisable(),
6665
RacRestrictToSingleNetwork: servercfg.GetRacRestrictToSingleNetwork(),
6766
EndpointDetection: servercfg.IsEndpointDetectionEnabled(),
6867
AllowedEmailDomains: servercfg.GetAllowedEmailDomains(),
@@ -140,7 +139,6 @@ func GetServerConfig() config.ServerConfig {
140139
cfg.IsPro = "yes"
141140
}
142141
cfg.JwtValidityDuration = time.Duration(settings.JwtValidityDuration) * time.Minute
143-
cfg.RacAutoDisable = settings.RacAutoDisable
144142
cfg.RacRestrictToSingleNetwork = settings.RacRestrictToSingleNetwork
145143
cfg.MetricInterval = settings.MetricInterval
146144
cfg.ManageDNS = settings.ManageDNS
@@ -206,11 +204,6 @@ func GetJwtValidityDuration() time.Duration {
206204
return GetServerConfig().JwtValidityDuration
207205
}
208206

209-
// GetRacAutoDisable - returns whether the feature to autodisable RAC is enabled
210-
func GetRacAutoDisable() bool {
211-
return GetServerSettings().RacAutoDisable
212-
}
213-
214207
// GetRacRestrictToSingleNetwork - returns whether the feature to allow simultaneous network connections via RAC is enabled
215208
func GetRacRestrictToSingleNetwork() bool {
216209
return GetServerSettings().RacRestrictToSingleNetwork

models/settings.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ type ServerSettings struct {
2525
Telemetry string `json:"telemetry"`
2626
BasicAuth bool `json:"basic_auth"`
2727
JwtValidityDuration int `json:"jwt_validity_duration"`
28-
RacAutoDisable bool `json:"rac_auto_disable"`
2928
RacRestrictToSingleNetwork bool `json:"rac_restrict_to_single_network"`
3029
EndpointDetection bool `json:"endpoint_detection"`
3130
AllowedEmailDomains string `json:"allowed_email_domains"`

pro/initialize.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,7 @@ func InitPro() {
8181
addTrialLicenseHook()
8282
}
8383

84-
if logic.GetRacAutoDisable() {
85-
AddRacHooks()
86-
}
84+
AddUnauthorisedUserNodeHooks()
8785

8886
var authProvider = auth.InitializeAuthProvider()
8987
if authProvider != "" {

pro/remote_access_client.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@ import (
1313
"golang.org/x/exp/slog"
1414
)
1515

16-
const racAutoDisableCheckInterval = 3 * time.Minute
16+
const unauthorisedUserNodeCheckInterval = 3 * time.Minute
1717

18-
// AddRacHooks - adds hooks for Remote Access Client
19-
func AddRacHooks() {
20-
slog.Debug("adding RAC autodisable hook")
18+
// AddUnauthorisedUserNodeHooks - adds hook to prevent access from unauthorised (expired) user nodes
19+
func AddUnauthorisedUserNodeHooks() {
20+
slog.Debug("adding unauthorisedUserNode hook")
2121
logic.HookManagerCh <- models.HookDetails{
22-
Hook: racAutoDisableHook,
23-
Interval: racAutoDisableCheckInterval,
22+
Hook: unauthorisedUserNodeHook,
23+
Interval: unauthorisedUserNodeCheckInterval,
2424
}
2525
}
2626

27-
// racAutoDisableHook - checks if RAC is enabled and if it is, checks if it should be disabled
28-
func racAutoDisableHook() error {
29-
slog.Debug("running RAC autodisable hook")
27+
// unauthorisedUserNodeHook - checks if a user node should be disabled, using the user's last login time
28+
func unauthorisedUserNodeHook() error {
29+
slog.Debug("running unauthorisedUserNode hook")
3030

3131
users, err := logic.GetUsers()
3232
if err != nil {
@@ -55,16 +55,16 @@ func racAutoDisableHook() error {
5555
}
5656
if (client.OwnerID == user.UserName) &&
5757
client.Enabled {
58-
slog.Info(fmt.Sprintf("disabling ext client %s for user %s due to RAC autodisabling", client.ClientID, client.OwnerID))
58+
slog.Info(fmt.Sprintf("disabling user node %s for user %s: auth token expired", client.ClientID, client.OwnerID))
5959
if err := disableExtClient(&client); err != nil {
60-
slog.Error("error disabling ext client in RAC autodisable hook", "error", err)
60+
slog.Error("error disabling user node", "error", err)
6161
continue // dont return but try for other clients
6262
}
6363
}
6464
}
6565
}
6666

67-
slog.Debug("finished running RAC autodisable hook")
67+
slog.Debug("finished running unauthorisedUserNode hook")
6868
return nil
6969
}
7070

scripts/netmaker.default.env

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ AZURE_TENANT=
7171
OIDC_ISSUER=
7272
# Duration of JWT token validity in seconds
7373
JWT_VALIDITY_DURATION=43200
74-
# Auto disable a user's connecteds clients bassed on JWT token expiration
75-
RAC_AUTO_DISABLE=false
7674
# Allow a user to connect to multiple networks simultaneously
7775
RAC_RESTRICT_TO_SINGLE_NETWORK=false
7876
# if turned on data will be cached on to improve performance significantly (IMPORTANT: If HA set to `false` )

scripts/nm-quick.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ save_config() { (
257257
"INSTALL_TYPE" "NODE_ID" "DNS_MODE" "NETCLIENT_AUTO_UPDATE" "API_PORT" "MANAGE_DNS" "DEFAULT_DOMAIN"
258258
"CORS_ALLOWED_ORIGIN" "DISPLAY_KEYS" "DATABASE" "SERVER_BROKER_ENDPOINT" "VERBOSITY"
259259
"DEBUG_MODE" "REST_BACKEND" "DISABLE_REMOTE_IP_CHECK" "TELEMETRY" "ALLOWED_EMAIL_DOMAINS" "AUTH_PROVIDER" "CLIENT_ID" "CLIENT_SECRET"
260-
"FRONTEND_URL" "AZURE_TENANT" "OIDC_ISSUER" "EXPORTER_API_PORT" "JWT_VALIDITY_DURATION" "RAC_AUTO_DISABLE" "RAC_RESTRICT_TO_SINGLE_NETWORK" "CACHING_ENABLED" "ENDPOINT_DETECTION"
260+
"FRONTEND_URL" "AZURE_TENANT" "OIDC_ISSUER" "EXPORTER_API_PORT" "JWT_VALIDITY_DURATION" "RAC_RESTRICT_TO_SINGLE_NETWORK" "CACHING_ENABLED" "ENDPOINT_DETECTION"
261261
"SMTP_HOST" "SMTP_PORT" "EMAIL_SENDER_ADDR" "EMAIL_SENDER_USER" "EMAIL_SENDER_PASSWORD")
262262
for name in "${toCopy[@]}"; do
263263
save_config_item $name "${!name}"

scripts/nm-upgrade.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ save_config() { (
179179
"CORS_ALLOWED_ORIGIN" "DISPLAY_KEYS" "DATABASE" "SERVER_BROKER_ENDPOINT" "STUN_PORT" "VERBOSITY"
180180
"TURN_PORT" "USE_TURN" "DEBUG_MODE" "TURN_API_PORT" "REST_BACKEND"
181181
"DISABLE_REMOTE_IP_CHECK" "TELEMETRY" "AUTH_PROVIDER" "CLIENT_ID" "CLIENT_SECRET"
182-
"FRONTEND_URL" "AZURE_TENANT" "OIDC_ISSUER" "EXPORTER_API_PORT" "JWT_VALIDITY_DURATION" "RAC_AUTO_DISABLE" "RAC_RESTRICT_TO_SINGLE_NETWORK")
182+
"FRONTEND_URL" "AZURE_TENANT" "OIDC_ISSUER" "EXPORTER_API_PORT" "JWT_VALIDITY_DURATION" "RAC_RESTRICT_TO_SINGLE_NETWORK")
183183
for name in "${toCopy[@]}"; do
184184
save_config_item $name "${!name}"
185185
done

0 commit comments

Comments
 (0)