Skip to content

Commit

Permalink
fix(NET-1540): add cfg to autoclose connections on rac, when logged out
Browse files Browse the repository at this point in the history
only auto-disconnect non-admin users when JWT expires on RAC and RAC_AUTO_DISABLE is set
  • Loading branch information
Aceix committed Oct 7, 2024
1 parent 2e7d9ad commit 5fc9c04
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions logic/jwts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
5 changes: 3 additions & 2 deletions models/user_mgmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 5fc9c04

Please sign in to comment.