mirror of
https://github.com/minio/minio.git
synced 2024-12-24 06:05:55 -05:00
auth-rpc: Reset token on disconnect (#2542)
This commit is contained in:
parent
7922a54c9a
commit
c8dfc4cda4
@ -17,6 +17,7 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net/rpc"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/minio/dsync"
|
"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,
|
// Call - If rpc connection isn't established yet since previous disconnect,
|
||||||
// connection is established, a jwt authenticated login is performed and then
|
// connection is established, a jwt authenticated login is performed and then
|
||||||
// the call is performed.
|
// 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 == "" {
|
if authClient.token == "" {
|
||||||
token, tstamp, err := authClient.Login()
|
token, tstamp, err := authClient.Login()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -75,5 +76,10 @@ func (authClient *AuthRPCClient) Call(serviceMethod string, args dsync.TokenSett
|
|||||||
args.SetToken(token)
|
args.SetToken(token)
|
||||||
args.SetTimestamp(tstamp)
|
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