Skip to content

Commit

Permalink
(security) fix user's JWT
Browse files Browse the repository at this point in the history
fixes #15
replaces #21
  • Loading branch information
reddec committed Jan 1, 2023
1 parent dd75f57 commit f65a28e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions api/services/user_srv.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ func (srv *userSrv) Login(ctx context.Context, login, password string) (*api.Tok
if err != nil {
return nil, err
}

now := time.Now()
tok := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{
"iat": time.Now().Add(srv.config.LifeTime),
"iat": now.Unix(),
"exp": now.Add(srv.config.LifeTime).Unix(),
"user": login,
})
v, err := tok.SignedString([]byte(srv.secret))
Expand Down

1 comment on commit f65a28e

@Ljkingoftires
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#9

Please sign in to comment.