mirror of
https://github.com/netbirdio/netbird.git
synced 2025-05-02 07:14:48 +02:00
Fix invalid token due to the cache race (#1763)
This commit is contained in:
parent
bd7a65d798
commit
22beac1b1b
@ -343,10 +343,18 @@ func (s *GRPCServer) Login(ctx context.Context, req *proto.EncryptedMessage) (*p
|
|||||||
userID := ""
|
userID := ""
|
||||||
// JWT token is not always provided, it is fine for userID to be empty cuz it might be that peer is already registered,
|
// JWT token is not always provided, it is fine for userID to be empty cuz it might be that peer is already registered,
|
||||||
// or it uses a setup key to register.
|
// or it uses a setup key to register.
|
||||||
|
|
||||||
if loginReq.GetJwtToken() != "" {
|
if loginReq.GetJwtToken() != "" {
|
||||||
userID, err = s.validateToken(loginReq.GetJwtToken())
|
for i := 0; i < 3; i++ {
|
||||||
|
userID, err = s.validateToken(loginReq.GetJwtToken())
|
||||||
|
if err == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
log.Warnf("failed validating JWT token sent from peer %s with error %v. "+
|
||||||
|
"Trying again as it may be due to the IdP cache issue", peerKey, err)
|
||||||
|
time.Sleep(200 * time.Millisecond)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warnf("failed validating JWT token sent from peer %s", peerKey)
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user