mirror of
https://github.com/minio/minio.git
synced 2024-12-23 21:55:53 -05:00
auth-rpc: Reset token on disconnect (#2542)
This commit is contained in:
parent
7922a54c9a
commit
c8dfc4cda4
@ -17,6 +17,7 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"net/rpc"
|
||||
"time"
|
||||
|
||||
"github.com/minio/dsync"
|
||||
@ -62,7 +63,7 @@ func (authClient *AuthRPCClient) Login() (string, time.Time, error) {
|
||||
// Call - If rpc connection isn't established yet since previous disconnect,
|
||||
// connection is established, a jwt authenticated login is performed and then
|
||||
// the call is performed.
|
||||
func (authClient *AuthRPCClient) Call(serviceMethod string, args dsync.TokenSetter, reply interface{}) (err error) {
|
||||
func (authClient *AuthRPCClient) Call(serviceMethod string, args dsync.TokenSetter, reply interface{}) error {
|
||||
if authClient.token == "" {
|
||||
token, tstamp, err := authClient.Login()
|
||||
if err != nil {
|
||||
@ -75,5 +76,10 @@ func (authClient *AuthRPCClient) Call(serviceMethod string, args dsync.TokenSett
|
||||
args.SetToken(token)
|
||||
args.SetTimestamp(tstamp)
|
||||
}
|
||||
return authClient.rpc.Call(serviceMethod, args, reply)
|
||||
err := authClient.rpc.Call(serviceMethod, args, reply)
|
||||
// Reset token on disconnect to mark for re-login on subsequent reconnect.
|
||||
if err != nil && err == rpc.ErrShutdown {
|
||||
authClient.token = ""
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user