mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-06 13:14:24 +08:00
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:
parent
470e9ddfe7
commit
ce7c164e09
2 changed files with 6 additions and 4 deletions
|
@ -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),
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue