controller/auth: Implement JWT based authorization for controller. (#2544)

Fixes #2474
This commit is contained in:
Harshavardhana
2016-08-24 10:14:14 -07:00
parent 200d327737
commit 9605fde04d
15 changed files with 240 additions and 162 deletions

View File

@@ -19,6 +19,7 @@ package dsync
import (
"math"
"math/rand"
"net"
"sync"
"time"
)
@@ -336,11 +337,21 @@ func sendRelease(c RPC, name, uid string, isReadLock bool) {
if err = c.Call("Dsync.RUnlock", &LockArgs{Name: name}, &status); err == nil {
// RUnlock delivered, exit out
return
} else if err != nil {
if nErr, ok := err.(net.Error); ok && nErr.Timeout() {
// RUnlock possibly failed with server timestamp mismatch, server may have restarted.
return
}
}
} else {
if err = c.Call("Dsync.Unlock", &LockArgs{Name: name}, &status); err == nil {
// Unlock delivered, exit out
return
} else if err != nil {
if nErr, ok := err.(net.Error); ok && nErr.Timeout() {
// Unlock possibly failed with server timestamp mismatch, server may have restarted.
return
}
}
}

View File

@@ -18,12 +18,11 @@ package dsync
import "time"
type TokenSetter interface {
SetToken(token string)
SetTimestamp(tstamp time.Time)
}
// RPC - is dsync compatible client interface.
type RPC interface {
Call(serviceMethod string, args TokenSetter, reply interface{}) error
Call(serviceMethod string, args interface {
SetToken(token string)
SetTimestamp(tstamp time.Time)
}, reply interface{}) error
Close() error
}