From ccf5bc83c81496ba0eb2d6a59bbbc0721a35a371 Mon Sep 17 00:00:00 2001 From: the_aceix Date: Tue, 17 Sep 2024 01:14:06 +0000 Subject: [PATCH] fix(NET-1540): add cfg to autoclose connections on rac, when logged out only auto-disconnect non-admin users when JWT expires on RAC --- logic/jwts.go | 1 + models/user_mgmt.go | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/logic/jwts.go b/logic/jwts.go index 41181fcd6..d02727206 100644 --- a/logic/jwts.go +++ b/logic/jwts.go @@ -58,6 +58,7 @@ func CreateUserJWT(username string, role models.UserRoleID) (response string, er claims := &models.UserClaims{ UserName: username, Role: role, + RacAutoDisable: (role != models.SuperAdminRole && role != models.AdminRole), RegisteredClaims: jwt.RegisteredClaims{ Issuer: "Netmaker", Subject: fmt.Sprintf("user|%s", username), diff --git a/models/user_mgmt.go b/models/user_mgmt.go index a87a0f4b8..6c8887e9d 100644 --- a/models/user_mgmt.go +++ b/models/user_mgmt.go @@ -177,8 +177,9 @@ type UserAuthParams struct { // UserClaims - user claims struct type UserClaims struct { - Role UserRoleID - UserName string + Role UserRoleID + UserName string + RacAutoDisable bool jwt.RegisteredClaims }