Skip to content
Snippets Groups Projects
Commit a6cd38bc authored by Fabian Seidl's avatar Fabian Seidl Committed by Neil-Jocelyn Schark
Browse files

Apply 5 suggestion(s) to 3 file(s)

parent a7c20b98
No related branches found
No related tags found
1 merge request!977Resolve "Improve token usage for users"
Pipeline #218760 passed
...@@ -83,7 +83,7 @@ var CertFilePath string ...@@ -83,7 +83,7 @@ var CertFilePath string
// KeyFilePath si the path to the private key that the controller should use for TLS connections. // KeyFilePath si the path to the private key that the controller should use for TLS connections.
var KeyFilePath string var KeyFilePath string
// MaxTokensPerUser is the maximum number of tokens a user can have. This determiens the maximum of concurrent logged in sessions per user. // MaxTokensPerUser is the maximum number of tokens a user can have. This determines the maximum of concurrent logged in sessions per user.
var MaxTokensPerUser int var MaxTokensPerUser int
// Init gets called on module import. // Init gets called on module import.
......
...@@ -173,7 +173,7 @@ func initialize() error { ...@@ -173,7 +173,7 @@ func initialize() error {
return err return err
} }
if err := deletAllExpiredUserTokens(); err != nil { if err := deleteAllExpiredUserTokens(); err != nil {
return err return err
} }
...@@ -446,14 +446,14 @@ func ensureDefaultUserExists() error { ...@@ -446,14 +446,14 @@ func ensureDefaultUserExists() error {
return nil return nil
} }
func deletAllExpiredUserTokens() error { func deleteAllExpiredUserTokens() error {
var usersToUpdate []rbac.User var usersToUpdate []rbac.User
// Temporary create JWT manager just to evaluate tokens here // Temporary create JWT manager just to evaluate tokens here
jwtManager := rbacImpl.NewJWTManager(config.JWTSecret, config.JWTDuration) jwtManager := rbacImpl.NewJWTManager(config.JWTSecret, config.JWTDuration)
users, err := c.userService.GetAll() users, err := c.userService.GetAll()
if err != nil { if err != nil {
return fmt.Errorf("error getting all users while deleting expires user tokens: %w", err) return fmt.Errorf("error getting all users while deleting expired user tokens: %w", err)
} }
for _, user := range users { for _, user := range users {
......
...@@ -159,7 +159,7 @@ func (s AuthServer) isCorrectPassword(storedPassword, salt, loginPassword string ...@@ -159,7 +159,7 @@ func (s AuthServer) isCorrectPassword(storedPassword, salt, loginPassword string
} }
// handleLogout checks if the provided user name matches with the one associated with token and // handleLogout checks if the provided user name matches with the one associated with token and
// removed the token from all tokens of the user. // removes the token from all tokens of the user.
func (s AuthServer) handleLogout(ctx context.Context, userName string) error { func (s AuthServer) handleLogout(ctx context.Context, userName string) error {
md, ok := metadata.FromIncomingContext(ctx) md, ok := metadata.FromIncomingContext(ctx)
if !ok { if !ok {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment