fix(NET-1540): add cfg to autoclose connections on rac, when logged out (#3130)

only auto-disconnect non-admin users when JWT expires on RAC and RAC_AUTO_DISABLE is set
This commit is contained in:
Aceix 2024-10-24 09:54:00 +00:00 committed by GitHub
parent 470e9ddfe7
commit ce7c164e09
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 4 deletions

View file

@ -56,8 +56,9 @@ func CreateJWT(uuid string, macAddress string, network string) (response string,
func CreateUserJWT(username string, role models.UserRoleID) (response string, err error) {
expirationTime := time.Now().Add(servercfg.GetServerConfig().JwtValidityDuration)
claims := &models.UserClaims{
UserName: username,
Role: role,
UserName: username,
Role: role,
RacAutoDisable: servercfg.GetRacAutoDisable() && (role != models.SuperAdminRole && role != models.AdminRole),
RegisteredClaims: jwt.RegisteredClaims{
Issuer: "Netmaker",
Subject: fmt.Sprintf("user|%s", username),

View file

@ -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
}