Merge "services/device/internal: Allow re-run'ing of apps to work"
diff --git a/cmd/principal/main.go b/cmd/principal/main.go
index 05df6ee..cbed2dd 100644
--- a/cmd/principal/main.go
+++ b/cmd/principal/main.go
@@ -796,7 +796,7 @@
token: base64.URLEncoding.EncodeToString(token[:]),
notify: make(chan error),
}
- if err := server.Serve("", service, allowAnyone{}); err != nil {
+ if err := server.Serve("", service, security.AllowEveryone()); err != nil {
return fmt.Errorf("failed to setup service: %v", err)
}
// Proposed name:
@@ -1034,7 +1034,7 @@
}
var s []string
for _, cav := range cavs {
- if cav.Id == security.PublicKeyThirdPartyCaveatX.Id {
+ if cav.Id == security.PublicKeyThirdPartyCaveat.Id {
c := cav.ThirdPartyDetails()
s = append(s, fmt.Sprintf("ThirdPartyCaveat: Requires discharge from %v (ID=%q)", c.Location(), c.ID()))
continue
@@ -1050,9 +1050,9 @@
if !param.(bool) {
s = append(s, fmt.Sprintf("Never validates"))
}
- case security.ExpiryCaveatX.Id:
+ case security.ExpiryCaveat.Id:
s = append(s, fmt.Sprintf("Expires at %v", param))
- case security.MethodCaveatX.Id:
+ case security.MethodCaveat.Id:
s = append(s, fmt.Sprintf("Restricted to methods %v", param))
case security.PeerBlessingsCaveat.Id:
s = append(s, fmt.Sprintf("Restricted to peers with blessings %v", param))
@@ -1208,10 +1208,6 @@
return nil
}
-type allowAnyone struct{}
-
-func (allowAnyone) Authorize(*context.T, security.Call) error { return nil }
-
type granter struct {
with security.Blessings
extension string
@@ -1256,7 +1252,7 @@
return nil, fmt.Errorf("failed to parse caveats: %v", err)
}
if expiry > 0 {
- ecav, err := security.ExpiryCaveat(time.Now().Add(expiry))
+ ecav, err := security.NewExpiryCaveat(time.Now().Add(expiry))
if err != nil {
return nil, fmt.Errorf("failed to create expiration caveat: %v", err)
}
diff --git a/cmd/principal/principal_v23_test.go b/cmd/principal/principal_v23_test.go
index 07ea2a0..e6c59dd 100644
--- a/cmd/principal/principal_v23_test.go
+++ b/cmd/principal/principal_v23_test.go
@@ -422,7 +422,7 @@
bin = bin.WithEnv(credEnv(aliceDir))
args := []string{
"blessself",
- "--caveat=\"v.io/v23/security\".MethodCaveatX={\"method\"}",
+ "--caveat=\"v.io/v23/security\".MethodCaveat={\"method\"}",
"--caveat={{0x54,0xa6,0x76,0x39,0x81,0x37,0x18,0x7e,0xcd,0xb2,0x6d,0x2d,0x69,0xba,0x0,0x3},typeobject([]string)}={\"method\"}",
"alicereborn",
}
diff --git a/cmd/vrun/vrun.go b/cmd/vrun/vrun.go
index 92f707f..390d0f1 100644
--- a/cmd/vrun/vrun.go
+++ b/cmd/vrun/vrun.go
@@ -92,7 +92,7 @@
}
func bless(ctx *context.T, p security.Principal, name string) error {
- caveat, err := security.ExpiryCaveat(time.Now().Add(durationFlag))
+ caveat, err := security.NewExpiryCaveat(time.Now().Add(durationFlag))
if err != nil {
vlog.Errorf("Couldn't create caveat")
return err
diff --git a/lib/security/audit/principal_test.go b/lib/security/audit/principal_test.go
index cc5a81b..ac0eecd 100644
--- a/lib/security/audit/principal_test.go
+++ b/lib/security/audit/principal_test.go
@@ -283,7 +283,7 @@
func newThirdPartyCaveatAndDischarge(t *testing.T) (security.Caveat, security.Discharge) {
p := newPrincipal(t)
- c, err := security.NewPublicKeyCaveat(p.PublicKey(), "location", security.ThirdPartyRequirements{}, newCaveat(security.MethodCaveat("method")))
+ c, err := security.NewPublicKeyCaveat(p.PublicKey(), "location", security.ThirdPartyRequirements{}, newCaveat(security.NewMethodCaveat("method")))
if err != nil {
t.Fatal(err)
}
diff --git a/profiles/internal/naming/namespace/all_test.go b/profiles/internal/naming/namespace/all_test.go
index 87bad7e..59749d3 100644
--- a/profiles/internal/naming/namespace/all_test.go
+++ b/profiles/internal/naming/namespace/all_test.go
@@ -123,14 +123,10 @@
return ch, nil
}
-type allowEveryoneAuthorizer struct{}
-
-func (allowEveryoneAuthorizer) Authorize(*context.T, security.Call) error { return nil }
-
type dispatcher struct{}
func (d *dispatcher) Lookup(suffix string) (interface{}, security.Authorizer, error) {
- return &testServer{suffix}, allowEveryoneAuthorizer{}, nil
+ return &testServer{suffix}, security.AllowEveryone(), nil
}
func knockKnock(t *testing.T, ctx *context.T, name string) {
diff --git a/profiles/internal/rpc/cancel_test.go b/profiles/internal/rpc/cancel_test.go
index c14d120..0ab201e 100644
--- a/profiles/internal/rpc/cancel_test.go
+++ b/profiles/internal/rpc/cancel_test.go
@@ -19,12 +19,6 @@
tnaming "v.io/x/ref/profiles/internal/testing/mocks/naming"
)
-type fakeAuthorizer int
-
-func (fakeAuthorizer) Authorize(*context.T, security.Call) error {
- return nil
-}
-
type canceld struct {
sm stream.Manager
ns namespace.T
@@ -78,7 +72,7 @@
stop: s.Stop,
}
- if err := s.Serve(name, c, fakeAuthorizer(0)); err != nil {
+ if err := s.Serve(name, c, security.AllowEveryone()); err != nil {
return nil, err
}
diff --git a/profiles/internal/rpc/discharges_test.go b/profiles/internal/rpc/discharges_test.go
index 7072a69..7b67b1b 100644
--- a/profiles/internal/rpc/discharges_test.go
+++ b/profiles/internal/rpc/discharges_test.go
@@ -26,7 +26,7 @@
methodCav = mkCaveat(security.NewPublicKeyCaveat(discharger.PublicKey(), "moline", security.ThirdPartyRequirements{}, security.UnconstrainedUse()))
serverCav = mkCaveat(security.NewPublicKeyCaveat(discharger.PublicKey(), "moline", security.ThirdPartyRequirements{}, security.UnconstrainedUse()))
- dExpired = mkDischarge(discharger.MintDischarge(expiredCav, mkCaveat(security.ExpiryCaveat(time.Now().Add(-1*time.Minute)))))
+ dExpired = mkDischarge(discharger.MintDischarge(expiredCav, mkCaveat(security.NewExpiryCaveat(time.Now().Add(-1*time.Minute)))))
dArgs = mkDischarge(discharger.MintDischarge(argsCav, security.UnconstrainedUse()))
dMethod = mkDischarge(discharger.MintDischarge(methodCav, security.UnconstrainedUse()))
dServer = mkDischarge(discharger.MintDischarge(serverCav, security.UnconstrainedUse()))
diff --git a/profiles/internal/rpc/full_test.go b/profiles/internal/rpc/full_test.go
index e978fc0..ed52512 100644
--- a/profiles/internal/rpc/full_test.go
+++ b/profiles/internal/rpc/full_test.go
@@ -389,7 +389,7 @@
if _, err := server.Listen(listenSpec); err != nil {
t.Fatal(err)
}
- if err := server.Serve(name, obj, acceptAllAuthorizer{}); err != nil {
+ if err := server.Serve(name, obj, security.AllowEveryone()); err != nil {
t.Fatal(err)
}
return sm
@@ -476,12 +476,12 @@
noErrID verror.IDAction
// Third-party caveats on blessings presented by server.
- cavTPValid = mkThirdPartyCaveat(pdischarger.PublicKey(), "mountpoint/dischargeserver", mkCaveat(security.ExpiryCaveat(now.Add(24*time.Hour))))
- cavTPExpired = mkThirdPartyCaveat(pdischarger.PublicKey(), "mountpoint/dischargeserver", mkCaveat(security.ExpiryCaveat(now.Add(-1*time.Second))))
+ cavTPValid = mkThirdPartyCaveat(pdischarger.PublicKey(), "mountpoint/dischargeserver", mkCaveat(security.NewExpiryCaveat(now.Add(24*time.Hour))))
+ cavTPExpired = mkThirdPartyCaveat(pdischarger.PublicKey(), "mountpoint/dischargeserver", mkCaveat(security.NewExpiryCaveat(now.Add(-1*time.Second))))
// Server blessings.
bServer = bless(pprovider, pserver, "server")
- bServerExpired = bless(pprovider, pserver, "expiredserver", mkCaveat(security.ExpiryCaveat(time.Now().Add(-1*time.Second))))
+ bServerExpired = bless(pprovider, pserver, "expiredserver", mkCaveat(security.NewExpiryCaveat(time.Now().Add(-1*time.Second))))
bServerTPValid = bless(pprovider, pserver, "serverWithTPCaveats", cavTPValid)
bServerTPExpired = bless(pprovider, pserver, "serverWithExpiredTPCaveats", cavTPExpired)
bOther = bless(pprovider, pserver, "other")
@@ -523,7 +523,7 @@
}
)
// Start the discharge server.
- _, dischargeServer := startServer(t, ctx, pdischarger, mgr, ns, "mountpoint/dischargeserver", testutil.LeafDispatcher(&dischargeServer{}, &acceptAllAuthorizer{}))
+ _, dischargeServer := startServer(t, ctx, pdischarger, mgr, ns, "mountpoint/dischargeserver", testutil.LeafDispatcher(&dischargeServer{}, security.AllowEveryone()))
defer stopServer(t, ctx, dischargeServer, ns, "mountpoint/dischargeserver")
// Make the client and server principals trust root certificates from
@@ -1022,11 +1022,11 @@
dischargeServerName = "mountpoint/dischargeserver"
// Caveats on blessings to the client: First-party caveats
- cavOnlyEcho = mkCaveat(security.MethodCaveat("Echo"))
- cavExpired = mkCaveat(security.ExpiryCaveat(now.Add(-1 * time.Second)))
+ cavOnlyEcho = mkCaveat(security.NewMethodCaveat("Echo"))
+ cavExpired = mkCaveat(security.NewExpiryCaveat(now.Add(-1 * time.Second)))
// Caveats on blessings to the client: Third-party caveats
- cavTPValid = mkThirdPartyCaveat(pdischarger.PublicKey(), dischargeServerName, mkCaveat(security.ExpiryCaveat(now.Add(24*time.Hour))))
- cavTPExpired = mkThirdPartyCaveat(pdischarger.PublicKey(), dischargeServerName, mkCaveat(security.ExpiryCaveat(now.Add(-1*time.Second))))
+ cavTPValid = mkThirdPartyCaveat(pdischarger.PublicKey(), dischargeServerName, mkCaveat(security.NewExpiryCaveat(now.Add(24*time.Hour))))
+ cavTPExpired = mkThirdPartyCaveat(pdischarger.PublicKey(), dischargeServerName, mkCaveat(security.NewExpiryCaveat(now.Add(-1*time.Second))))
// Client blessings that will be tested.
bServerClientOnlyEcho = bless(pserver, pclient, "onlyecho", cavOnlyEcho)
@@ -1108,7 +1108,7 @@
defer stopServer(t, ctx, server, ns, serverName)
// Start the discharge server.
- _, dischargeServer := startServer(t, ctx, pdischarger, mgr, ns, dischargeServerName, testutil.LeafDispatcher(&dischargeServer{}, &acceptAllAuthorizer{}))
+ _, dischargeServer := startServer(t, ctx, pdischarger, mgr, ns, dischargeServerName, testutil.LeafDispatcher(&dischargeServer{}, security.AllowEveryone()))
defer stopServer(t, ctx, dischargeServer, ns, dischargeServerName)
// The server should recognize the client principal as an authority on "client" and "random" blessings.
@@ -1239,7 +1239,7 @@
mgr = imanager.InternalNew(naming.FixedRoutingID(0x1111111))
ns = tnaming.NewSimpleNamespace()
- tpCav = mkThirdPartyCaveat(pdischarger.PublicKey(), "mountpoint/dischargeserver", mkCaveat(security.ExpiryCaveat(time.Now().Add(time.Hour))))
+ tpCav = mkThirdPartyCaveat(pdischarger.PublicKey(), "mountpoint/dischargeserver", mkCaveat(security.NewExpiryCaveat(time.Now().Add(time.Hour))))
bserver = bless(pprovider, pserver, "server", tpCav)
bclient = bless(pprovider, pclient, "client")
@@ -1256,7 +1256,7 @@
_, server := startServer(t, ctx, pserver, mgr, ns, "mountpoint/server", testServerDisp{&testServer{}})
defer stopServer(t, ctx, server, ns, "mountpoint/server")
- _, dischargeServer := startServer(t, ctx, pdischarger, mgr, ns, "mountpoint/dischargeserver", testutil.LeafDispatcher(&dischargeServer{}, &acceptAllAuthorizer{}))
+ _, dischargeServer := startServer(t, ctx, pdischarger, mgr, ns, "mountpoint/dischargeserver", testutil.LeafDispatcher(&dischargeServer{}, security.AllowEveryone()))
defer stopServer(t, ctx, dischargeServer, ns, "mountpoint/dischargeserver")
// Make the client present bclient to all servers that are blessed
@@ -1742,7 +1742,7 @@
}
// Bless the client with a ThirdPartyCaveat.
- tpcav := mkThirdPartyCaveat(pdischarger.PublicKey(), "mountpoint/discharger", mkCaveat(security.ExpiryCaveat(time.Now().Add(time.Hour))))
+ tpcav := mkThirdPartyCaveat(pdischarger.PublicKey(), "mountpoint/discharger", mkCaveat(security.NewExpiryCaveat(time.Now().Add(time.Hour))))
blessings, err := pserver.Bless(pclient.PublicKey(), pserver.BlessingStore().Default(), "tpcav", tpcav)
if err != nil {
t.Fatalf("failed to create Blessings: %v", err)
@@ -1801,7 +1801,7 @@
ctx, shutdown := initForTest()
defer shutdown()
// Bless the client with a ThirdPartyCaveat from discharger1.
- tpcav1 := mkThirdPartyCaveat(pdischarger1.PublicKey(), "mountpoint/discharger1", mkCaveat(security.ExpiryCaveat(time.Now().Add(time.Hour))))
+ tpcav1 := mkThirdPartyCaveat(pdischarger1.PublicKey(), "mountpoint/discharger1", mkCaveat(security.NewExpiryCaveat(time.Now().Add(time.Hour))))
blessings, err := pdischarger1.Bless(pdischargeClient.PublicKey(), pdischarger1.BlessingStore().Default(), "tpcav1", tpcav1)
if err != nil {
t.Fatalf("failed to create Blessings: %v", err)
@@ -1832,7 +1832,7 @@
t.Fatalf("failed to create client: %v", err)
}
dc := c.(*client).dc
- tpcav2, err := security.NewPublicKeyCaveat(pdischarger2.PublicKey(), "mountpoint/discharger2", security.ThirdPartyRequirements{}, mkCaveat(security.ExpiryCaveat(time.Now().Add(time.Hour))))
+ tpcav2, err := security.NewPublicKeyCaveat(pdischarger2.PublicKey(), "mountpoint/discharger2", security.ThirdPartyRequirements{}, mkCaveat(security.NewExpiryCaveat(time.Now().Add(time.Hour))))
if err != nil {
t.Error(err)
}
@@ -1919,7 +1919,7 @@
t.Errorf("got cacheAttempts(%v), cacheHits(%v), expected cacheAttempts(3), cacheHits(1)", gotAttempts, gotHits)
}
// clientB changes its blessings, the cache should not be used.
- blessings, err := pserver.Bless(pclient.PublicKey(), pserver.BlessingStore().Default(), "cav", mkCaveat(security.ExpiryCaveat(time.Now().Add(time.Hour))))
+ blessings, err := pserver.Bless(pclient.PublicKey(), pserver.BlessingStore().Default(), "cav", mkCaveat(security.NewExpiryCaveat(time.Now().Add(time.Hour))))
if err != nil {
t.Fatalf("failed to create Blessings: %v", err)
}
@@ -1987,7 +1987,7 @@
if ed.called {
expDur = time.Second
}
- expiry, err := security.ExpiryCaveat(time.Now().Add(expDur))
+ expiry, err := security.NewExpiryCaveat(time.Now().Add(expDur))
if err != nil {
return security.Discharge{}, fmt.Errorf("failed to create an expiration on the discharge: %v", err)
}
@@ -2004,7 +2004,7 @@
defer shutdown()
var (
pclient, pdischarger = newClientServerPrincipals()
- tpcav = mkThirdPartyCaveat(pdischarger.PublicKey(), "mountpoint/discharger", mkCaveat(security.ExpiryCaveat(time.Now().Add(time.Hour))))
+ tpcav = mkThirdPartyCaveat(pdischarger.PublicKey(), "mountpoint/discharger", mkCaveat(security.NewExpiryCaveat(time.Now().Add(time.Hour))))
ns = tnaming.NewSimpleNamespace()
discharger = &expiryDischarger{}
)
diff --git a/profiles/internal/rpc/protocols/tcp/init.go b/profiles/internal/rpc/protocols/tcp/init.go
index 08f95e6..a6067b9 100644
--- a/profiles/internal/rpc/protocols/tcp/init.go
+++ b/profiles/internal/rpc/protocols/tcp/init.go
@@ -22,7 +22,6 @@
}
func tcpDial(network, address string, timeout time.Duration) (net.Conn, error) {
- vlog.Infof("tcp.Dial %v", address)
conn, err := net.DialTimeout(network, address, timeout)
if err != nil {
return nil, err
diff --git a/profiles/internal/rpc/server.go b/profiles/internal/rpc/server.go
index d41aa64..3516796 100644
--- a/profiles/internal/rpc/server.go
+++ b/profiles/internal/rpc/server.go
@@ -15,9 +15,9 @@
"time"
"v.io/x/lib/netstate"
+ "v.io/x/lib/pubsub"
"v.io/x/lib/vlog"
- "v.io/v23/config"
"v.io/v23/context"
"v.io/v23/namespace"
"v.io/v23/naming"
@@ -73,9 +73,9 @@
type dhcpState struct {
name string
- publisher *config.Publisher
- stream *config.Stream
- ch chan config.Setting // channel to receive dhcp settings over
+ publisher *pubsub.Publisher
+ stream *pubsub.Stream
+ ch chan pubsub.Setting // channel to receive dhcp settings over
err error // error status.
watchers map[chan<- rpc.NetworkChange]struct{}
}
@@ -420,7 +420,7 @@
watchers: make(map[chan<- rpc.NetworkChange]struct{}),
}
s.dhcpState = dhcp
- dhcp.ch = make(chan config.Setting, 10)
+ dhcp.ch = make(chan pubsub.Setting, 10)
dhcp.stream, dhcp.err = dhcp.publisher.ForkStream(dhcp.name, dhcp.ch)
if dhcp.err == nil {
// We have a goroutine to listen for dhcp changes.
@@ -610,7 +610,7 @@
}
}
-func (s *server) dhcpLoop(ch chan config.Setting) {
+func (s *server) dhcpLoop(ch chan pubsub.Setting) {
defer vlog.VI(1).Infof("rpc: Stopped listen for dhcp changes")
vlog.VI(2).Infof("rpc: dhcp loop")
for setting := range ch {
@@ -854,7 +854,7 @@
}(ln)
}
- drain := func(ch chan config.Setting) {
+ drain := func(ch chan pubsub.Setting) {
for {
select {
case v := <-ch:
@@ -957,26 +957,26 @@
discharges: make(map[string]security.Discharge),
}
var err error
- typedec := flow.VCDataCache().Get(vc.TypeDecoderKey{})
- if typedec == nil {
- if fs.dec, err = vom.NewDecoder(flow); err != nil {
- flow.Close()
- return nil, err
- }
+ typeenc := flow.VCDataCache().Get(vc.TypeEncoderKey{})
+ if typeenc == nil {
if fs.enc, err = vom.NewEncoder(flow); err != nil {
flow.Close()
return nil, err
}
- } else {
- if fs.dec, err = vom.NewDecoderWithTypeDecoder(flow, typedec.(*vom.TypeDecoder)); err != nil {
+ if fs.dec, err = vom.NewDecoder(flow); err != nil {
flow.Close()
return nil, err
}
- typeenc := flow.VCDataCache().Get(vc.TypeEncoderKey{})
+ } else {
if fs.enc, err = vom.NewEncoderWithTypeEncoder(flow, typeenc.(*vom.TypeEncoder)); err != nil {
flow.Close()
return nil, err
}
+ typedec := flow.VCDataCache().Get(vc.TypeDecoderKey{})
+ if fs.dec, err = vom.NewDecoderWithTypeDecoder(flow, typedec.(*vom.TypeDecoder)); err != nil {
+ flow.Close()
+ return nil, err
+ }
}
return fs, nil
}
@@ -1160,7 +1160,7 @@
// value may be modified to match the actual suffix and method to use.
func (fs *flowServer) lookup(suffix string, method string) (rpc.Invoker, security.Authorizer, error) {
if naming.IsReserved(method) {
- return reservedInvoker(fs.disp, fs.server.dispReserved), &acceptAllAuthorizer{}, nil
+ return reservedInvoker(fs.disp, fs.server.dispReserved), security.AllowEveryone(), nil
}
disp := fs.disp
if naming.IsReserved(suffix) {
@@ -1234,12 +1234,6 @@
return nil
}
-type acceptAllAuthorizer struct{}
-
-func (acceptAllAuthorizer) Authorize(*context.T, security.Call) error {
- return nil
-}
-
func authorize(ctx *context.T, call security.Call, auth security.Authorizer) error {
if call.LocalPrincipal() == nil {
// LocalPrincipal is nil means that the server wanted to avoid
diff --git a/profiles/internal/rpc/server_test.go b/profiles/internal/rpc/server_test.go
index 4e30884..c23b3bd 100644
--- a/profiles/internal/rpc/server_test.go
+++ b/profiles/internal/rpc/server_test.go
@@ -11,8 +11,9 @@
"testing"
"time"
+ "v.io/x/lib/pubsub"
+
"v.io/v23"
- "v.io/v23/config"
"v.io/v23/context"
"v.io/v23/naming"
"v.io/v23/rpc"
@@ -430,8 +431,8 @@
t.Fatal(err)
}
- publisher := config.NewPublisher()
- roaming := make(chan config.Setting)
+ publisher := pubsub.NewPublisher()
+ roaming := make(chan pubsub.Setting)
stop, err := publisher.CreateStream("TestRoaming", "TestRoaming", roaming)
if err != nil {
t.Fatal(err)
@@ -582,8 +583,8 @@
t.Fatal(err)
}
- publisher := config.NewPublisher()
- roaming := make(chan config.Setting)
+ publisher := pubsub.NewPublisher()
+ roaming := make(chan pubsub.Setting)
stop, err := publisher.CreateStream("TestWatcherDeadlock", "TestWatcherDeadlock", roaming)
if err != nil {
t.Fatal(err)
diff --git a/profiles/internal/rpc/stream/manager/listener.go b/profiles/internal/rpc/stream/manager/listener.go
index 298d20f..3824089 100644
--- a/profiles/internal/rpc/stream/manager/listener.go
+++ b/profiles/internal/rpc/stream/manager/listener.go
@@ -6,6 +6,7 @@
import (
"fmt"
+ "math/rand"
"net"
"strings"
"sync"
@@ -62,6 +63,9 @@
manager *manager
vifs *vif.Set
+ connsMu sync.Mutex
+ conns map[net.Conn]bool
+
netLoop sync.WaitGroup
vifLoops sync.WaitGroup
}
@@ -87,6 +91,7 @@
manager: m,
netLn: netLn,
vifs: vif.NewSet(),
+ conns: make(map[net.Conn]bool),
}
// Set the default idle timeout for VC. But for "unixfd", we do not set
@@ -114,6 +119,44 @@
return false
}
+func (ln *netListener) killConnections(n int) {
+ ln.connsMu.Lock()
+ if n > len(ln.conns) {
+ n = len(ln.conns)
+ }
+ remaining := make([]net.Conn, 0, len(ln.conns))
+ for c := range ln.conns {
+ remaining = append(remaining, c)
+ }
+ removed := remaining[:n]
+ ln.connsMu.Unlock()
+
+ vlog.Infof("Killing %d Conns", n)
+
+ var wg sync.WaitGroup
+ wg.Add(n)
+ for i := 0; i < n; i++ {
+ idx := rand.Intn(len(remaining))
+ conn := remaining[idx]
+ go func(conn net.Conn) {
+ vlog.Infof("Killing connection (%s, %s)", conn.LocalAddr(), conn.RemoteAddr())
+ conn.Close()
+ ln.manager.killedConns.Incr(1)
+ wg.Done()
+ }(conn)
+ remaining[idx], remaining[0] = remaining[0], remaining[idx]
+ remaining = remaining[1:]
+ }
+
+ ln.connsMu.Lock()
+ for _, conn := range removed {
+ delete(ln.conns, conn)
+ }
+ ln.connsMu.Unlock()
+
+ wg.Wait()
+}
+
func (ln *netListener) netAcceptLoop(principal security.Principal, blessings security.Blessings, opts []stream.ListenerOpt) {
defer ln.netLoop.Done()
opts = append([]stream.ListenerOpt{vc.StartTimeout{defaultStartTimeout}}, opts...)
@@ -126,7 +169,7 @@
vlog.Infof("net.Listener.Accept() failed on %v with %v", ln.netLn, err)
for tokill := 1; isTemporaryError(err); tokill *= 2 {
if isTooManyOpenFiles(err) {
- ln.manager.killConnections(tokill)
+ ln.killConnections(tokill)
} else {
tokill = 1
}
@@ -145,6 +188,10 @@
vlog.VI(1).Infof("Exiting netAcceptLoop: net.Listener.Accept() failed on %v with %v", ln.netLn, err)
return
}
+ ln.connsMu.Lock()
+ ln.conns[conn] = true
+ ln.connsMu.Unlock()
+
vlog.VI(1).Infof("New net.Conn accepted from %s (local address: %s)", conn.RemoteAddr(), conn.LocalAddr())
go func() {
vf, err := vif.InternalNewAcceptedVIF(conn, ln.manager.rid, principal, blessings, nil, ln.deleteVIF, opts...)
@@ -157,7 +204,12 @@
ln.manager.vifs.Insert(vf)
ln.vifLoops.Add(1)
- vifLoop(vf, ln.q, &ln.vifLoops)
+ vifLoop(vf, ln.q, func() {
+ ln.connsMu.Lock()
+ delete(ln.conns, conn)
+ ln.connsMu.Unlock()
+ ln.vifLoops.Done()
+ })
}()
}
}
@@ -226,7 +278,9 @@
}
ln.vif = vf
ln.vifLoop.Add(1)
- go vifLoop(ln.vif, ln.q, &ln.vifLoop)
+ go vifLoop(ln.vif, ln.q, func() {
+ ln.vifLoop.Done()
+ })
return ln, ep, nil
}
@@ -338,8 +392,8 @@
return fmt.Sprintf("stream.Listener: PROXY:%v RoutingID:%v", ln.proxyEP, ln.manager.rid)
}
-func vifLoop(vf *vif.VIF, q *upcqueue.T, wg *sync.WaitGroup) {
- defer wg.Done()
+func vifLoop(vf *vif.VIF, q *upcqueue.T, cleanup func()) {
+ defer cleanup()
for {
cAndf, err := vf.Accept()
switch {
diff --git a/profiles/internal/rpc/stream/manager/manager.go b/profiles/internal/rpc/stream/manager/manager.go
index 371f86a..5fb6232 100644
--- a/profiles/internal/rpc/stream/manager/manager.go
+++ b/profiles/internal/rpc/stream/manager/manager.go
@@ -7,7 +7,6 @@
import (
"fmt"
- "math/rand"
"net"
"strings"
"sync"
@@ -330,29 +329,6 @@
return strings.Join(l, "\n")
}
-func (m *manager) killConnections(n int) {
- vifs := m.vifs.List()
- if n > len(vifs) {
- n = len(vifs)
- }
- vlog.Infof("Killing %d VIFs", n)
- var wg sync.WaitGroup
- wg.Add(n)
- for i := 0; i < n; i++ {
- idx := rand.Intn(len(vifs))
- vf := vifs[idx]
- go func(vf *vif.VIF) {
- vlog.Infof("Killing VIF %v", vf)
- vf.Shutdown()
- m.killedConns.Incr(1)
- wg.Done()
- }(vf)
- vifs[idx], vifs[0] = vifs[0], vifs[idx]
- vifs = vifs[1:]
- }
- wg.Wait()
-}
-
func extractBlessingNames(p security.Principal, b security.Blessings) ([]string, error) {
if !b.IsZero() && p == nil {
return nil, verror.New(stream.ErrBadArg, nil, verror.New(errProvidedServerBlessingsWithoutPrincipal, nil))
diff --git a/profiles/internal/rpc/stream/manager/manager_test.go b/profiles/internal/rpc/stream/manager/manager_test.go
index e28f505..5ae22f3 100644
--- a/profiles/internal/rpc/stream/manager/manager_test.go
+++ b/profiles/internal/rpc/stream/manager/manager_test.go
@@ -918,8 +918,8 @@
if err := h.Shutdown(nil, &stderr); err != nil {
t.Fatal(err)
}
- if log := expect.NewSession(t, bytes.NewReader(stderr.Bytes()), time.Minute).ExpectSetEventuallyRE("manager.go.*Killing [1-9][0-9]* VIFs"); len(log) == 0 {
- t.Errorf("Failed to find log message talking about killing VIFs in:\n%v", stderr.String())
+ if log := expect.NewSession(t, bytes.NewReader(stderr.Bytes()), time.Minute).ExpectSetEventuallyRE("listener.go.*Killing [1-9][0-9]* Conns"); len(log) == 0 {
+ t.Errorf("Failed to find log message talking about killing Conns in:\n%v", stderr.String())
}
t.Logf("Server FD limit:%d", nfiles)
t.Logf("Client connection attempts: %d", nattempts)
diff --git a/profiles/internal/rpc/stream/proxy/proxy.go b/profiles/internal/rpc/stream/proxy/proxy.go
index 3944e13..ae984c5 100644
--- a/profiles/internal/rpc/stream/proxy/proxy.go
+++ b/profiles/internal/rpc/stream/proxy/proxy.go
@@ -286,7 +286,7 @@
blessings = p.principal.BlessingStore().Default()
}
- c, err := vif.AuthenticateAsServer(conn, reader, nil, p.principal, blessings, nil)
+ c, _, err := vif.AuthenticateAsServer(conn, reader, nil, p.principal, blessings, nil)
if err != nil {
processLog().Infof("Process %v failed to authenticate: %s", p, err)
return
diff --git a/profiles/internal/rpc/stream/vc/vc.go b/profiles/internal/rpc/stream/vc/vc.go
index 5889cc6..91f249e 100644
--- a/profiles/internal/rpc/stream/vc/vc.go
+++ b/profiles/internal/rpc/stream/vc/vc.go
@@ -816,18 +816,18 @@
if err != nil {
return verror.New(errFlowForWireTypeNotAccepted, nil, err)
}
- typeDec, err := vom.NewTypeDecoder(conn)
- if err != nil {
- conn.Close()
- return verror.New(errVomTypeDecoder, nil, err)
- }
- vc.dataCache.Insert(TypeDecoderKey{}, typeDec)
typeEnc, err := vom.NewTypeEncoder(conn)
if err != nil {
conn.Close()
return verror.New(errVomTypeEncoder, nil, err)
}
vc.dataCache.Insert(TypeEncoderKey{}, typeEnc)
+ typeDec, err := vom.NewTypeDecoder(conn)
+ if err != nil {
+ conn.Close()
+ return verror.New(errVomTypeDecoder, nil, err)
+ }
+ vc.dataCache.Insert(TypeDecoderKey{}, typeDec)
return nil
}
diff --git a/profiles/internal/rpc/stream/vif/auth.go b/profiles/internal/rpc/stream/vif/auth.go
index 65bec0b..55a938d 100644
--- a/profiles/internal/rpc/stream/vif/auth.go
+++ b/profiles/internal/rpc/stream/vif/auth.go
@@ -67,6 +67,12 @@
// including a hash of the Setup message in the encrypted stream. It is
// likely that this will be addressed in subsequent protocol versions.
func AuthenticateAsClient(writer io.Writer, reader *iobuf.Reader, versions *version.Range, params security.CallParams, auth *vc.ServerAuthorizer) (crypto.ControlCipher, error) {
+ // TODO(mattr): Temporarily don't do version negotiation over insecure channels.
+ // This is because the current production agent is broken (see v.io/i/293).
+ if params.LocalPrincipal == nil {
+ return nullCipher, nil
+ }
+
if versions == nil {
versions = version.SupportedRange
}
@@ -103,10 +109,6 @@
}
v := vrange.Max
- if params.LocalPrincipal == nil {
- return nullCipher, nil
- }
-
// Perform the authentication.
return authenticateAsClient(writer, reader, params, auth, pvt, pub, ppub, v)
}
@@ -131,8 +133,13 @@
// based on the max common version.
//
// See AuthenticateAsClient for a description of the negotiation.
+// TODO(mattr): I have temporarily added a new output parmeter message.T.
+// If this message is non-nil then it is the first message that should be handled
+// by the VIF. This is needed because the first message we read here may
+// or may not be a Setup message, if it's not we need to handle it in the
+// message loop. This parameter will be removed shortly.
func AuthenticateAsServer(writer io.Writer, reader *iobuf.Reader, versions *version.Range, principal security.Principal, lBlessings security.Blessings,
- dc vc.DischargeClient) (crypto.ControlCipher, error) {
+ dc vc.DischargeClient) (crypto.ControlCipher, message.T, error) {
var err error
if versions == nil {
versions = version.SupportedRange
@@ -141,11 +148,11 @@
// Send server's public data.
pvt, pub, err := makeSetup(versions, principal != nil)
if err != nil {
- return nil, err
+ return nil, nil, err
}
errch := make(chan error, 1)
- readch := make(chan struct{})
+ readch := make(chan bool, 1)
go func() {
// TODO(mattr,ribrdb): In the case of the agent, which is
// currently the only user of insecure connections, we need to
@@ -155,42 +162,66 @@
// the magic byte has been sent the client will use the first
// byte of this message instead rendering the remainder of the
// stream uninterpretable.
- if principal == nil {
- <-readch
+ // TODO(mattr): As an even worse hack, we want to temporarily be
+ // compatible with really old agents. We can't send them our setup
+ // message because they have a bug. However we want new servers
+ // to be compatible with clients that DO send the setup message.
+ // To accomplish this we'll see if the client sends us a setup message
+ // first. If it does, we'll send ours. If not, we wont.
+ if principal != nil || <-readch {
+ err := message.WriteTo(writer, pub, nullCipher)
+ errch <- err
}
- err := message.WriteTo(writer, pub, nullCipher)
- errch <- err
+ close(errch)
}()
// Read client's public data.
pmsg, err := message.ReadFrom(reader, nullCipher)
- close(readch) // Note: we need to close this whether we get an error or not.
if err != nil {
- return nil, verror.New(stream.ErrNetwork, nil, err)
+ readch <- false
+ return nil, nil, verror.New(stream.ErrNetwork, nil, err)
}
ppub, ok := pmsg.(*message.Setup)
if !ok {
- return nil, verror.New(stream.ErrSecurity, nil, verror.New(errVersionNegotiationFailed, nil))
+ // TODO(mattr): We got a message from the client, but it's not a Setup, so
+ // assume this is a client that doesn't negotiate. This should
+ // be removed once we no longer have to be compatible with old agents.
+ readch <- false
+ return nullCipher, pmsg, nil
+ } else {
+ // TODO(mattr): We got a Setup message from the client, so
+ // assume this is a client that does negotiate. This should
+ // be removed once we no longer have to be compatible with old agents.
+ readch <- true
}
// Wait for the write to succeed.
- if err := <-errch; err != nil {
- return nil, err
+ if err, ok := <-errch; !ok {
+ // We didn't write because we didn't get a Setup message from the client.
+ // Just return a nil cipher. This basically just assumes the agent is
+ // RPC version compatible.
+ // TODO(mattr): This is part of the same hack described above, it should be
+ // removed later.
+ return nullCipher, nil, nil
+ } else if err != nil {
+ // The write failed, the VIF cannot be set up.
+ return nil, nil, err
}
// Choose the max version in the intersection.
vrange, err := versions.Intersect(&ppub.Versions)
if err != nil {
- return nil, verror.New(stream.ErrNetwork, nil, err)
+ return nil, nil, verror.New(stream.ErrNetwork, nil, err)
}
v := vrange.Max
if principal == nil {
- return nullCipher, nil
+ return nullCipher, nil, nil
}
// Perform authentication.
- return authenticateAsServerRPC6(writer, reader, principal, lBlessings, dc, pvt, pub, ppub, v)
+ cipher, err := authenticateAsServerRPC6(writer, reader, principal, lBlessings, dc, pvt, pub, ppub, v)
+ return cipher, nil, err
}
func authenticateAsServerRPC6(writer io.Writer, reader *iobuf.Reader, principal security.Principal, lBlessings security.Blessings, dc vc.DischargeClient,
diff --git a/profiles/internal/rpc/stream/vif/vif.go b/profiles/internal/rpc/stream/vif/vif.go
index d20b63e..6689d5d 100644
--- a/profiles/internal/rpc/stream/vif/vif.go
+++ b/profiles/internal/rpc/stream/vif/vif.go
@@ -195,7 +195,7 @@
startTimeout = v.Duration
}
}
- return internalNew(conn, pool, reader, rid, id.VC(vc.NumReservedVCs), versions, principal, blessings, startTimeout, onClose, nil, nil, c)
+ return internalNew(conn, pool, reader, rid, id.VC(vc.NumReservedVCs), versions, principal, blessings, startTimeout, onClose, nil, nil, c, nil)
}
// InternalNewAcceptedVIF creates a new virtual interface over the provided
@@ -215,7 +215,7 @@
dischargeClient := getDischargeClient(lopts)
- c, err := AuthenticateAsServer(conn, reader, versions, principal, blessings, dischargeClient)
+ c, initialMessage, err := AuthenticateAsServer(conn, reader, versions, principal, blessings, dischargeClient)
if err != nil {
return nil, err
}
@@ -227,10 +227,10 @@
startTimeout = v.Duration
}
}
- return internalNew(conn, pool, reader, rid, id.VC(vc.NumReservedVCs)+1, versions, principal, blessings, startTimeout, onClose, upcqueue.New(), lopts, c)
+ return internalNew(conn, pool, reader, rid, id.VC(vc.NumReservedVCs)+1, versions, principal, blessings, startTimeout, onClose, upcqueue.New(), lopts, c, initialMessage)
}
-func internalNew(conn net.Conn, pool *iobuf.Pool, reader *iobuf.Reader, rid naming.RoutingID, initialVCI id.VC, versions *iversion.Range, principal security.Principal, blessings security.Blessings, startTimeout time.Duration, onClose func(*VIF), acceptor *upcqueue.T, listenerOpts []stream.ListenerOpt, c crypto.ControlCipher) (*VIF, error) {
+func internalNew(conn net.Conn, pool *iobuf.Pool, reader *iobuf.Reader, rid naming.RoutingID, initialVCI id.VC, versions *iversion.Range, principal security.Principal, blessings security.Blessings, startTimeout time.Duration, onClose func(*VIF), acceptor *upcqueue.T, listenerOpts []stream.ListenerOpt, c crypto.ControlCipher, initialMessage message.T) (*VIF, error) {
var (
// Choose IDs that will not conflict with any other (VC, Flow)
// pairs. VCI 0 is never used by the application (it is
@@ -294,7 +294,7 @@
vif.closeVCAndSendMsg(vc, false, verror.New(errIdleTimeout, nil))
}
})
- go vif.readLoop()
+ go vif.readLoop(initialMessage)
go vif.writeLoop()
return vif, nil
}
@@ -412,12 +412,6 @@
}
}
-// Shutdown terminates the underlying network connection (any pending reads and
-// writes of flows/VCs over it will be discarded).
-func (vif *VIF) Shutdown() {
- vif.conn.Close()
-}
-
// StartAccepting begins accepting Flows (and VCs) initiated by the remote end
// of a VIF. opts is used to setup the listener on newly established VCs.
func (vif *VIF) StartAccepting(opts ...stream.ListenerOpt) error {
@@ -481,17 +475,24 @@
return fmt.Sprintf("(%s, %s) <-> (%s, %s)", l.Network(), l, r.Network(), r)
}
-func (vif *VIF) readLoop() {
+func (vif *VIF) readLoop(initialMessage message.T) {
defer vif.Close()
defer vif.stopVCDispatchLoops()
for {
// vif.ctrlCipher is guarded by vif.writeMu. However, the only mutation
// to it is in handleMessage, which runs in the same goroutine, so a
// lock is not required here.
- msg, err := message.ReadFrom(vif.reader, vif.ctrlCipher)
- if err != nil {
- vlog.VI(1).Infof("Exiting readLoop of VIF %s because of read error: %v", vif, err)
- return
+ var msg message.T
+ if initialMessage != nil {
+ msg = initialMessage
+ initialMessage = nil
+ } else {
+ var err error
+ msg, err = message.ReadFrom(vif.reader, vif.ctrlCipher)
+ if err != nil {
+ vlog.VI(1).Infof("Exiting readLoop of VIF %s because of read error: %v", vif, err)
+ return
+ }
}
vlog.VI(3).Infof("Received %T = [%v] on VIF %s", msg, msg, vif)
if err := vif.handleMessage(msg); err != nil {
diff --git a/profiles/internal/rpc/stress/internal/server.go b/profiles/internal/rpc/stress/internal/server.go
index 66b49d7..c4a62a1 100644
--- a/profiles/internal/rpc/stress/internal/server.go
+++ b/profiles/internal/rpc/stress/internal/server.go
@@ -81,10 +81,6 @@
return nil
}
-type allowEveryoneAuthorizer struct{}
-
-func (allowEveryoneAuthorizer) Authorize(*context.T, security.Call) error { return nil }
-
// StartServer starts a server that implements the Stress service, and returns
// the server and its vanadium address. It also returns a channel carrying stop
// requests. After reading from the stop channel, the application should exit.
@@ -102,7 +98,7 @@
}
s := impl{stop: make(chan struct{})}
- if err := server.Serve("", stress.StressServer(&s), allowEveryoneAuthorizer{}); err != nil {
+ if err := server.Serve("", stress.StressServer(&s), security.AllowEveryone()); err != nil {
vlog.Fatalf("Serve failed: %v", err)
}
return server, eps[0], s.stop
diff --git a/profiles/internal/rpc/test/client_test.go b/profiles/internal/rpc/test/client_test.go
index cb2f6f4..99bf7c2 100644
--- a/profiles/internal/rpc/test/client_test.go
+++ b/profiles/internal/rpc/test/client_test.go
@@ -874,7 +874,7 @@
}
verr := call.Finish()
if verror.ErrorID(verr) != verror.ErrUnknownMethod.ID {
- t.Fatalf("wrong error: %s", verr)
+ t.Errorf("wrong error: %s", verr)
}
logErr("unknown method", verr)
@@ -885,39 +885,49 @@
}
verr = call.Finish()
if verror.ErrorID(verr) != verror.ErrUnknownSuffix.ID {
- t.Fatalf("wrong error: %s", verr)
+ t.Errorf("wrong error: %s", verr)
}
logErr("unknown suffix", verr)
// Too many args.
call, err = clt.StartCall(ctx, name, "Ping", []interface{}{1, 2})
if err != nil {
- t.Fatal(err)
+ // We check for "failed to encode arg" here because sometimes the server detects the
+ // mismatched number of arguments, sends an error response, and closes the connection,
+ // before the client gets through encoding the args. In this case the flow is closed and
+ // encoding of args fails, preventing the client from calling call.Finish, and seeing
+ // the error in the response. In the normal case network time dominates, so this case
+ // will very rarely get hit, but since the client and server in this test are in the
+ // same process we see this race quite a bit.
+ if got, want := err.Error(), "failed to encode arg"; !strings.Contains(got, want) {
+ t.Errorf("want %q to contain %q", got, want)
+ }
+ logErr("too many args", err)
+ } else {
+ r1 := ""
+ verr = call.Finish(&r1)
+ if verror.ErrorID(verr) != verror.ErrBadProtocol.ID {
+ t.Errorf("wrong error: %s", verr)
+ }
+ if got, want := verr.Error(), "wrong number of input arguments"; !strings.Contains(got, want) {
+ t.Errorf("want %q to contain %q", got, want)
+ }
+ logErr("too many args", verr)
}
- r1 := ""
- verr = call.Finish(&r1)
- if verror.ErrorID(verr) != verror.ErrBadProtocol.ID {
- t.Fatalf("wrong error: %s", verr)
- }
- if got, want := verr.Error(), "wrong number of input arguments"; !strings.Contains(got, want) {
- t.Fatalf("want %q to contain %q", got, want)
- }
- logErr("wrong # args", verr)
-
// Too many results.
call, err = clt.StartCall(ctx, name, "Ping", nil)
if err != nil {
t.Fatal(err)
}
- r2 := ""
+ r1, r2 := "", ""
verr = call.Finish(&r1, &r2)
if verror.ErrorID(verr) != verror.ErrBadProtocol.ID {
- t.Fatalf("wrong error: %s", verr)
+ t.Errorf("wrong error: %s", verr)
}
if got, want := verr.Error(), "results, but want"; !strings.Contains(got, want) {
- t.Fatalf("want %q to contain %q", got, want)
+ t.Errorf("want %q to contain %q", got, want)
}
logErr("wrong # results", verr)
@@ -929,10 +939,10 @@
verr = call.Finish(&r2)
if verror.ErrorID(verr) != verror.ErrBadProtocol.ID {
- t.Fatalf("wrong error: %s", verr)
+ t.Errorf("wrong error: %s", verr)
}
if got, want := verr.Error(), "aren't compatible"; !strings.Contains(got, want) {
- t.Fatalf("want %q to contain %q", got, want)
+ t.Errorf("want %q to contain %q", got, want)
}
logErr("wrong arg types", verr)
@@ -945,10 +955,10 @@
r3 := 2
verr = call.Finish(&r3)
if verror.ErrorID(verr) != verror.ErrBadProtocol.ID {
- t.Fatalf("wrong error: %s", verr)
+ t.Errorf("wrong error: %s", verr)
}
if got, want := verr.Error(), "aren't compatible"; !strings.Contains(got, want) {
- t.Fatalf("want %q to contain %q", got, want)
+ t.Errorf("want %q to contain %q", got, want)
}
logErr("wrong result types", verr)
}
diff --git a/profiles/internal/rpc/test/retry_test.go b/profiles/internal/rpc/test/retry_test.go
index 9f69ee0..0b28efb 100644
--- a/profiles/internal/rpc/test/retry_test.go
+++ b/profiles/internal/rpc/test/retry_test.go
@@ -32,12 +32,6 @@
return verror.New(errRetryThis, ctx)
}
-type allowEveryoneAuth struct{}
-
-func (allowEveryoneAuth) Authorize(*context.T, security.Call) error {
- return nil
-}
-
func TestRetryCall(t *testing.T) {
ctx, shutdown := v23.Init()
defer shutdown()
@@ -52,7 +46,7 @@
t.Fatal(err)
}
rs := retryServer{}
- if err = server.Serve("", &rs, allowEveryoneAuth{}); err != nil {
+ if err = server.Serve("", &rs, security.AllowEveryone()); err != nil {
t.Fatal(err)
}
name := eps[0].Name()
diff --git a/profiles/internal/rt/ipc_test.go b/profiles/internal/rt/ipc_test.go
index 6c76eb4..138826f 100644
--- a/profiles/internal/rt/ipc_test.go
+++ b/profiles/internal/rt/ipc_test.go
@@ -92,7 +92,7 @@
return nil, "", err
}
serverObjectName := naming.JoinAddressName(endpoints[0].String(), "")
- if err := server.Serve("", s, allowEveryone{}); err != nil {
+ if err := server.Serve("", s, security.AllowEveryone()); err != nil {
return nil, "", err
}
return server, serverObjectName, nil
@@ -265,7 +265,7 @@
ds.mu.Unlock()
caveat := security.UnconstrainedUse()
if called == 0 {
- caveat = mkCaveat(security.ExpiryCaveat(time.Now().Add(-1 * time.Second)))
+ caveat = mkCaveat(security.NewExpiryCaveat(time.Now().Add(-1 * time.Second)))
}
return call.Security().LocalPrincipal().MintDischarge(cav, caveat)
@@ -363,7 +363,7 @@
t.Fatal(err)
}
- rootServerInvalidTPCaveat := mkBlessings(root.NewBlessings(pserver, "server", mkThirdPartyCaveat(pdischarger.PublicKey(), dischargeServerName, mkCaveat(security.ExpiryCaveat(time.Now().Add(-1*time.Second))))))
+ rootServerInvalidTPCaveat := mkBlessings(root.NewBlessings(pserver, "server", mkThirdPartyCaveat(pdischarger.PublicKey(), dischargeServerName, mkCaveat(security.NewExpiryCaveat(time.Now().Add(-1*time.Second))))))
if err := pserver.BlessingStore().SetDefault(rootServerInvalidTPCaveat); err != nil {
t.Fatal(err)
}
@@ -372,7 +372,3 @@
t.Errorf("client.StartCall passed unexpectedly with remote end authenticated as: %v", remoteBlessings)
}
}
-
-type allowEveryone struct{}
-
-func (allowEveryone) Authorize(*context.T, security.Call) error { return nil }
diff --git a/profiles/internal/vtrace/vtrace_test.go b/profiles/internal/vtrace/vtrace_test.go
index 74b7cab..87a1bf8 100644
--- a/profiles/internal/vtrace/vtrace_test.go
+++ b/profiles/internal/vtrace/vtrace_test.go
@@ -154,10 +154,6 @@
}, nil
}
-type anyone struct{}
-
-func (anyone) Authorize(*context.T, security.Call) error { return nil }
-
func makeTestServer(ctx *context.T, principal security.Principal, name string) (*testServer, error) {
// Set a new vtrace store to simulate a separate process.
ctx, err := ivtrace.Init(ctx, flags.VtraceFlags{CacheSize: 100})
@@ -180,7 +176,7 @@
name: name,
stop: s.Stop,
}
- if err := s.Serve(name, c, anyone{}); err != nil {
+ if err := s.Serve(name, c, security.AllowEveryone()); err != nil {
return nil, err
}
return c, nil
diff --git a/profiles/roaming/roaminginit.go b/profiles/roaming/roaminginit.go
index 4996320..8ec4482 100644
--- a/profiles/roaming/roaminginit.go
+++ b/profiles/roaming/roaminginit.go
@@ -8,7 +8,7 @@
// configurations, including 1-1 NATs, dhcp auto-configuration, and Google
// Compute Engine.
//
-// The config.Publisher mechanism is used for communicating networking
+// The pubsub.Publisher mechanism is used for communicating networking
// settings to the rpc.Server implementation of the runtime and publishes
// the Settings it expects.
package roaming
@@ -19,10 +19,10 @@
"v.io/x/lib/netconfig"
"v.io/x/lib/netstate"
+ "v.io/x/lib/pubsub"
"v.io/x/lib/vlog"
"v.io/v23"
- "v.io/v23/config"
"v.io/v23/context"
"v.io/v23/rpc"
@@ -86,11 +86,11 @@
}
}
- publisher := config.NewPublisher()
+ publisher := pubsub.NewPublisher()
// Create stream in Init function to avoid a race between any
// goroutines started here and consumers started after Init returns.
- ch := make(chan config.Setting)
+ ch := make(chan pubsub.Setting)
stop, err := publisher.CreateStream(SettingsStreamName, SettingsStreamName, ch)
if err != nil {
ac.Shutdown()
@@ -141,7 +141,7 @@
prev netstate.AddrList,
pubStop, cleanup <-chan struct{},
watcherLoop chan<- struct{},
- ch chan<- config.Setting) {
+ ch chan<- pubsub.Setting) {
defer close(ch)
listenSpec := runtime.GetListenSpec(ctx)
diff --git a/services/agent/internal/test_principal/main.go b/services/agent/internal/test_principal/main.go
index 5d7a29a..1f27580 100644
--- a/services/agent/internal/test_principal/main.go
+++ b/services/agent/internal/test_principal/main.go
@@ -83,7 +83,7 @@
errorf("signature.Verify: %v", err)
}
// MintDischarge
- cav, err := security.MethodCaveat("method")
+ cav, err := security.NewMethodCaveat("method")
if err != nil {
errorf("security.MethodCaveat: %v", err)
}
diff --git a/services/device/device/local_install.go b/services/device/device/local_install.go
index f2a3243..c124974 100644
--- a/services/device/device/local_install.go
+++ b/services/device/device/local_install.go
@@ -52,10 +52,6 @@
cmdInstallLocal.Flags.Var(&packagesOverride, "packages", "JSON-encoded application.Packages object, of the form: '{\"pkg1\":{\"File\":\"local file path1\"},\"pkg2\":{\"File\":\"local file path 2\"}}'")
}
-type openAuthorizer struct{}
-
-func (openAuthorizer) Authorize(*context.T, security.Call) error { return nil }
-
type mapDispatcher map[string]interface{}
func (d mapDispatcher) Lookup(suffix string) (interface{}, security.Authorizer, error) {
@@ -63,8 +59,8 @@
if !ok {
return nil, nil, fmt.Errorf("suffix %s not found", suffix)
}
- // TODO(caprita): Do not open authorizer even for a short-lived server.
- return o, &openAuthorizer{}, nil
+ // TODO(caprita): Do not allow everyone, even for a short-lived server.
+ return o, security.AllowEveryone(), nil
}
type mapServer struct {
diff --git a/services/device/internal/impl/impl_test.go b/services/device/internal/impl/impl_test.go
index 91718af..4b2cdf4 100644
--- a/services/device/internal/impl/impl_test.go
+++ b/services/device/internal/impl/impl_test.go
@@ -563,7 +563,7 @@
func setupPingServer(t *testing.T, ctx *context.T) (<-chan pingArgs, func()) {
server, _ := servicetest.NewServer(ctx)
pingCh := make(chan pingArgs, 1)
- if err := server.Serve("pingserver", pingServer(pingCh), &openAuthorizer{}); err != nil {
+ if err := server.Serve("pingserver", pingServer(pingCh), security.AllowEveryone()); err != nil {
t.Fatalf("Serve(%q, <dispatcher>) failed: %v", "pingserver", err)
}
return pingCh, func() {
diff --git a/services/device/internal/impl/mock_repo_test.go b/services/device/internal/impl/mock_repo_test.go
index 7f6a03d..632342b 100644
--- a/services/device/internal/impl/mock_repo_test.go
+++ b/services/device/internal/impl/mock_repo_test.go
@@ -47,7 +47,7 @@
server, _ := servicetest.NewServer(ctx)
invoker := new(arInvoker)
name := mockApplicationRepoName
- if err := server.Serve(name, repository.ApplicationServer(invoker), &openAuthorizer{}); err != nil {
+ if err := server.Serve(name, repository.ApplicationServer(invoker), security.AllowEveryone()); err != nil {
vlog.Fatalf("Serve(%v) failed: %v", name, err)
}
return &invoker.envelope, func() {
@@ -57,10 +57,6 @@
}
}
-type openAuthorizer struct{}
-
-func (openAuthorizer) Authorize(*context.T, security.Call) error { return nil }
-
// arInvoker holds the state of an application repository invocation mock. The
// mock returns the value of the wrapped envelope, which can be subsequently be
// changed at any time. Client is responsible for synchronization if desired.
@@ -94,7 +90,7 @@
func startBinaryRepository(ctx *context.T) func() {
server, _ := servicetest.NewServer(ctx)
name := mockBinaryRepoName
- if err := server.Serve(name, repository.BinaryServer(new(brInvoker)), &openAuthorizer{}); err != nil {
+ if err := server.Serve(name, repository.BinaryServer(new(brInvoker)), security.AllowEveryone()); err != nil {
vlog.Fatalf("Serve(%q) failed: %v", name, err)
}
return func() {
diff --git a/services/identity/internal/auditor/blessing_auditor_test.go b/services/identity/internal/auditor/blessing_auditor_test.go
index 5813382..eb7a4a6 100644
--- a/services/identity/internal/auditor/blessing_auditor_test.go
+++ b/services/identity/internal/auditor/blessing_auditor_test.go
@@ -21,7 +21,7 @@
if err != nil {
t.Fatalf("failed to create principal: %v", err)
}
- expiryCaveat := newCaveat(security.ExpiryCaveat(time.Now().Add(time.Hour)))
+ expiryCaveat := newCaveat(security.NewExpiryCaveat(time.Now().Add(time.Hour)))
revocationCaveat := newThirdPartyCaveat(t, p)
tests := []struct {
@@ -91,7 +91,7 @@
}
func newThirdPartyCaveat(t *testing.T, p security.Principal) security.Caveat {
- tp, err := security.NewPublicKeyCaveat(p.PublicKey(), "location", security.ThirdPartyRequirements{}, newCaveat(security.MethodCaveat("method")))
+ tp, err := security.NewPublicKeyCaveat(p.PublicKey(), "location", security.ThirdPartyRequirements{}, newCaveat(security.NewMethodCaveat("method")))
if err != nil {
t.Fatal(err)
}
diff --git a/services/identity/internal/blesser/macaroon_test.go b/services/identity/internal/blesser/macaroon_test.go
index f2dcca0..95ebbd1 100644
--- a/services/identity/internal/blesser/macaroon_test.go
+++ b/services/identity/internal/blesser/macaroon_test.go
@@ -22,7 +22,7 @@
var (
key = make([]byte, 16)
provider, user = testutil.NewPrincipal(), testutil.NewPrincipal()
- cOnlyMethodFoo = newCaveat(security.MethodCaveat("Foo"))
+ cOnlyMethodFoo = newCaveat(security.NewMethodCaveat("Foo"))
ctx, call = fakeContextAndCall(provider, user)
)
if _, err := rand.Read(key); err != nil {
diff --git a/services/identity/internal/blesser/oauth.go b/services/identity/internal/blesser/oauth.go
index 44a13d9..127658d 100644
--- a/services/identity/internal/blesser/oauth.go
+++ b/services/identity/internal/blesser/oauth.go
@@ -83,7 +83,7 @@
if b.revocationManager != nil {
caveat, err = b.revocationManager.NewCaveat(self.PublicKey(), b.dischargerLocation)
} else {
- caveat, err = security.ExpiryCaveat(time.Now().Add(b.duration))
+ caveat, err = security.NewExpiryCaveat(time.Now().Add(b.duration))
}
if err != nil {
return noblessings, "", err
diff --git a/services/identity/internal/caveats/caveat_factory.go b/services/identity/internal/caveats/caveat_factory.go
index d057a86..d11382e 100644
--- a/services/identity/internal/caveats/caveat_factory.go
+++ b/services/identity/internal/caveats/caveat_factory.go
@@ -50,7 +50,7 @@
if !ok {
return empty, fmt.Errorf("expiry caveat: received arg of type %T, expected time.Time", args[0])
}
- return security.ExpiryCaveat(t)
+ return security.NewExpiryCaveat(t)
}
func methodCaveat(args ...interface{}) (security.Caveat, error) {
@@ -61,7 +61,7 @@
if err != nil {
return security.Caveat{}, fmt.Errorf("method caveat: %v", err)
}
- return security.MethodCaveat(methods[0], methods[1:]...)
+ return security.NewMethodCaveat(methods[0], methods[1:]...)
}
func peerBlessingsCaveat(args ...interface{}) (security.Caveat, error) {
diff --git a/services/identity/internal/dischargerlib/discharger.go b/services/identity/internal/dischargerlib/discharger.go
index cf75370..4fb6d48 100644
--- a/services/identity/internal/dischargerlib/discharger.go
+++ b/services/identity/internal/dischargerlib/discharger.go
@@ -26,7 +26,7 @@
if err := tp.Dischargeable(ctx, call.Security()); err != nil {
return security.Discharge{}, fmt.Errorf("third-party caveat %v cannot be discharged for this context: %v", tp, err)
}
- expiry, err := security.ExpiryCaveat(time.Now().Add(15 * time.Minute))
+ expiry, err := security.NewExpiryCaveat(time.Now().Add(15 * time.Minute))
if err != nil {
return security.Discharge{}, fmt.Errorf("unable to create expiration caveat on the discharge: %v", err)
}
diff --git a/services/identity/internal/oauth/handler.go b/services/identity/internal/oauth/handler.go
index bea1fae..815431f 100644
--- a/services/identity/internal/oauth/handler.go
+++ b/services/identity/internal/oauth/handler.go
@@ -227,7 +227,7 @@
func prettyPrintCaveats(cavs []security.Caveat) ([]string, error) {
s := make([]string, len(cavs))
for i, cav := range cavs {
- if cav.Id == security.PublicKeyThirdPartyCaveatX.Id {
+ if cav.Id == security.PublicKeyThirdPartyCaveat.Id {
c := cav.ThirdPartyDetails()
s[i] = fmt.Sprintf("ThirdPartyCaveat: Requires discharge from %v (ID=%q)", c.Location(), c.ID())
continue
@@ -238,9 +238,9 @@
return nil, err
}
switch cav.Id {
- case security.ExpiryCaveatX.Id:
+ case security.ExpiryCaveat.Id:
s[i] = fmt.Sprintf("Expires at %v", param)
- case security.MethodCaveatX.Id:
+ case security.MethodCaveat.Id:
s[i] = fmt.Sprintf("Restricted to methods %v", param)
case security.PeerBlessingsCaveat.Id:
s[i] = fmt.Sprintf("Restricted to peers with blessings %v", param)
diff --git a/services/identity/internal/server/identityd.go b/services/identity/internal/server/identityd.go
index f1f0cda..01eaeb4 100644
--- a/services/identity/internal/server/identityd.go
+++ b/services/identity/internal/server/identityd.go
@@ -253,15 +253,11 @@
return d
}
-type allowEveryoneAuthorizer struct{}
-
-func (allowEveryoneAuthorizer) Authorize(*context.T, security.Call) error { return nil }
-
type dispatcher map[string]interface{}
func (d dispatcher) Lookup(suffix string) (interface{}, security.Authorizer, error) {
if invoker := d[suffix]; invoker != nil {
- return invoker, allowEveryoneAuthorizer{}, nil
+ return invoker, security.AllowEveryone(), nil
}
return nil, nil, verror.New(verror.ErrNoExist, nil, suffix)
}
diff --git a/services/proxy/proxyd/proxyd_v23_test.go b/services/proxy/proxyd/proxyd_v23_test.go
index 5a44507..2e4d4e0 100644
--- a/services/proxy/proxyd/proxyd_v23_test.go
+++ b/services/proxy/proxyd/proxyd_v23_test.go
@@ -75,7 +75,7 @@
if _, err := server.Listen(rpc.ListenSpec{Proxy: proxyName}); err != nil {
return err
}
- if err := server.Serve(serverName, service{}, allowEveryone{}); err != nil {
+ if err := server.Serve(serverName, service{}, security.AllowEveryone()); err != nil {
return err
}
@@ -106,7 +106,3 @@
server := security.LocalBlessingNames(ctx, call.Security())
return fmt.Sprintf("server %v saw client %v", server, client), nil
}
-
-type allowEveryone struct{}
-
-func (allowEveryone) Authorize(*context.T, security.Call) error { return nil }
diff --git a/services/role/roled/internal/discharger.go b/services/role/roled/internal/discharger.go
index 5e8f4a0..2a624cc 100644
--- a/services/role/roled/internal/discharger.go
+++ b/services/role/roled/internal/discharger.go
@@ -41,12 +41,12 @@
// TODO(rthellend,ashankar): Do proper logging when the API allows it.
vlog.Infof("Discharge() impetus: %#v", impetus)
- expiry, err := security.ExpiryCaveat(time.Now().Add(5 * time.Minute))
+ expiry, err := security.NewExpiryCaveat(time.Now().Add(5 * time.Minute))
if err != nil {
return security.Discharge{}, verror.Convert(verror.ErrInternal, ctx, err)
}
// Bind the discharge to precisely the purpose the requestor claims it will be used.
- method, err := security.MethodCaveat(impetus.Method)
+ method, err := security.NewMethodCaveat(impetus.Method)
if err != nil {
return security.Discharge{}, verror.Convert(verror.ErrInternal, ctx, err)
}
diff --git a/services/role/roled/internal/dispatcher.go b/services/role/roled/internal/dispatcher.go
index 4567c2b..475beb5 100644
--- a/services/role/roled/internal/dispatcher.go
+++ b/services/role/roled/internal/dispatcher.go
@@ -46,7 +46,7 @@
func (d *dispatcher) Lookup(suffix string) (interface{}, security.Authorizer, error) {
if len(suffix) == 0 {
- return discharger.DischargerServer(&dischargerImpl{d.config}), &openAuthorizer{}, nil
+ return discharger.DischargerServer(&dischargerImpl{d.config}), security.AllowEveryone(), nil
}
fileName := filepath.Join(d.config.root, filepath.FromSlash(suffix+".conf"))
if !strings.HasPrefix(fileName, d.config.root) {
@@ -65,12 +65,6 @@
return role.RoleServer(obj), &authorizer{roleConfig}, nil
}
-type openAuthorizer struct{}
-
-func (openAuthorizer) Authorize(*context.T, security.Call) error {
- return nil
-}
-
type authorizer struct {
config *Config
}
diff --git a/services/role/roled/internal/role.go b/services/role/roled/internal/role.go
index 2e39f7c..9d0e332 100644
--- a/services/role/roled/internal/role.go
+++ b/services/role/roled/internal/role.go
@@ -90,7 +90,7 @@
if err != nil {
return nil, verror.Convert(verror.ErrInternal, ctx, err)
}
- expiry, err := security.ExpiryCaveat(time.Now().Add(d))
+ expiry, err := security.NewExpiryCaveat(time.Now().Add(d))
if err != nil {
return nil, verror.Convert(verror.ErrInternal, ctx, err)
}
diff --git a/services/wspr/internal/account/account.go b/services/wspr/internal/account/account.go
index f577b59..0289534 100644
--- a/services/wspr/internal/account/account.go
+++ b/services/wspr/internal/account/account.go
@@ -146,9 +146,9 @@
return security.Caveat{}, zeroTime, fmt.Errorf("time.parseDuration(%v) failed: %v", arg, err)
}
expirationTime := time.Now().Add(dur)
- cav, err := security.ExpiryCaveat(expirationTime)
+ cav, err := security.NewExpiryCaveat(expirationTime)
if err != nil {
- return security.Caveat{}, zeroTime, fmt.Errorf("security.ExpiryCaveat(%v) failed: %v", expirationTime, err)
+ return security.Caveat{}, zeroTime, fmt.Errorf("security.NewExpiryCaveat(%v) failed: %v", expirationTime, err)
}
return cav, expirationTime, nil
}
@@ -158,5 +158,5 @@
if len(args) == 0 {
return security.Caveat{}, fmt.Errorf("must pass at least one method")
}
- return security.MethodCaveat(args[0], args[1:]...)
+ return security.NewMethodCaveat(args[0], args[1:]...)
}
diff --git a/services/wspr/internal/app/app.go b/services/wspr/internal/app/app.go
index d9d87cf..baa5bda 100644
--- a/services/wspr/internal/app/app.go
+++ b/services/wspr/internal/app/app.go
@@ -818,6 +818,15 @@
granterStr.Send(data)
}
+func (c *Controller) BlessingsDebugString(_ *context.T, _ rpc.ServerCall, handle principal.BlessingsHandle) (string, error) {
+ var inputBlessings security.Blessings
+ if inputBlessings = c.GetBlessings(handle); inputBlessings.IsZero() {
+ return "", verror.New(invalidBlessingsHandle, nil, handle)
+ }
+
+ return inputBlessings.String(), nil
+}
+
func (c *Controller) RemoteBlessings(ctx *context.T, _ rpc.ServerCall, name, method string) ([]string, error) {
vlog.VI(2).Infof("requesting remote blessings for %q", name)
diff --git a/services/wspr/internal/app/controller.vdl b/services/wspr/internal/app/controller.vdl
index 85c911a..0f6be7c 100644
--- a/services/wspr/internal/app/controller.vdl
+++ b/services/wspr/internal/app/controller.vdl
@@ -25,6 +25,8 @@
// UnlinkBlessings removes the given blessings from the blessings store.
UnlinkBlessings(handle principal.BlessingsHandle) error
+ // BlessingsDebugString gets a string useful for debugging blessings.
+ BlessingsDebugString(handle principal.BlessingsHandle) (string | error)
// Bless binds extensions of blessings held by this principal to
// another principal (represented by its public key).
Bless(publicKey string, blessingHandle principal.BlessingsHandle, extension string, caveat []security.Caveat) (string, principal.BlessingsHandle | error)
diff --git a/services/wspr/internal/app/controller.vdl.go b/services/wspr/internal/app/controller.vdl.go
index 5d5d920..fe63c72 100644
--- a/services/wspr/internal/app/controller.vdl.go
+++ b/services/wspr/internal/app/controller.vdl.go
@@ -34,6 +34,8 @@
RemoveName(ctx *context.T, serverId uint32, name string, opts ...rpc.CallOpt) error
// UnlinkBlessings removes the given blessings from the blessings store.
UnlinkBlessings(ctx *context.T, handle principal.BlessingsHandle, opts ...rpc.CallOpt) error
+ // BlessingsDebugString gets a string useful for debugging blessings.
+ BlessingsDebugString(ctx *context.T, handle principal.BlessingsHandle, opts ...rpc.CallOpt) (string, error)
// Bless binds extensions of blessings held by this principal to
// another principal (represented by its public key).
Bless(ctx *context.T, publicKey string, blessingHandle principal.BlessingsHandle, extension string, caveat []security.Caveat, opts ...rpc.CallOpt) (string, principal.BlessingsHandle, error)
@@ -91,6 +93,11 @@
return
}
+func (c implControllerClientStub) BlessingsDebugString(ctx *context.T, i0 principal.BlessingsHandle, opts ...rpc.CallOpt) (o0 string, err error) {
+ err = v23.GetClient(ctx).Call(ctx, c.name, "BlessingsDebugString", []interface{}{i0}, []interface{}{&o0}, opts...)
+ return
+}
+
func (c implControllerClientStub) Bless(ctx *context.T, i0 string, i1 principal.BlessingsHandle, i2 string, i3 []security.Caveat, opts ...rpc.CallOpt) (o0 string, o1 principal.BlessingsHandle, err error) {
err = v23.GetClient(ctx).Call(ctx, c.name, "Bless", []interface{}{i0, i1, i2, i3}, []interface{}{&o0, &o1}, opts...)
return
@@ -141,6 +148,8 @@
RemoveName(ctx *context.T, call rpc.ServerCall, serverId uint32, name string) error
// UnlinkBlessings removes the given blessings from the blessings store.
UnlinkBlessings(ctx *context.T, call rpc.ServerCall, handle principal.BlessingsHandle) error
+ // BlessingsDebugString gets a string useful for debugging blessings.
+ BlessingsDebugString(ctx *context.T, call rpc.ServerCall, handle principal.BlessingsHandle) (string, error)
// Bless binds extensions of blessings held by this principal to
// another principal (represented by its public key).
Bless(ctx *context.T, call rpc.ServerCall, publicKey string, blessingHandle principal.BlessingsHandle, extension string, caveat []security.Caveat) (string, principal.BlessingsHandle, error)
@@ -213,6 +222,10 @@
return s.impl.UnlinkBlessings(ctx, call, i0)
}
+func (s implControllerServerStub) BlessingsDebugString(ctx *context.T, call rpc.ServerCall, i0 principal.BlessingsHandle) (string, error) {
+ return s.impl.BlessingsDebugString(ctx, call, i0)
+}
+
func (s implControllerServerStub) Bless(ctx *context.T, call rpc.ServerCall, i0 string, i1 principal.BlessingsHandle, i2 string, i3 []security.Caveat) (string, principal.BlessingsHandle, error) {
return s.impl.Bless(ctx, call, i0, i1, i2, i3)
}
@@ -296,6 +309,16 @@
},
},
{
+ Name: "BlessingsDebugString",
+ Doc: "// BlessingsDebugString gets a string useful for debugging blessings.",
+ InArgs: []rpc.ArgDesc{
+ {"handle", ``}, // principal.BlessingsHandle
+ },
+ OutArgs: []rpc.ArgDesc{
+ {"", ``}, // string
+ },
+ },
+ {
Name: "Bless",
Doc: "// Bless binds extensions of blessings held by this principal to\n// another principal (represented by its public key).",
InArgs: []rpc.ArgDesc{
diff --git a/services/wspr/internal/principal/principal_test.go b/services/wspr/internal/principal/principal_test.go
index 492688b..2f86ef4 100644
--- a/services/wspr/internal/principal/principal_test.go
+++ b/services/wspr/internal/principal/principal_test.go
@@ -42,7 +42,7 @@
}
// Test AddOrigin.
- cav, err := security.MethodCaveat("Foo")
+ cav, err := security.NewMethodCaveat("Foo")
if err != nil {
return fmt.Errorf("security.MethodCaveat failed: %v", err)
}
@@ -197,7 +197,7 @@
// Test with no expiration caveat.
origin1 := "http://origin-1.com"
- methodCav, err := security.MethodCaveat("Foo")
+ methodCav, err := security.NewMethodCaveat("Foo")
if err != nil {
fmt.Errorf("security.MethodCaveat failed: %v", err)
}
@@ -214,9 +214,9 @@
origin2 := "http://origin-2.com"
futureTime := time.Now().Add(5 * time.Minute)
- futureExpCav, err := security.ExpiryCaveat(futureTime)
+ futureExpCav, err := security.NewExpiryCaveat(futureTime)
if err != nil {
- fmt.Errorf("security.ExpiryCaveat(%v) failed: %v", futureTime, err)
+ fmt.Errorf("security.NewExpiryCaveat(%v) failed: %v", futureTime, err)
}
if err := m.AddOrigin(origin2, googleAccount, []security.Caveat{futureExpCav}, []time.Time{futureTime}); err != nil {
@@ -231,9 +231,9 @@
origin3 := "http://origin-3.com"
pastTime := time.Now().Add(-5 * time.Minute)
- pastExpCav, err := security.ExpiryCaveat(pastTime)
+ pastExpCav, err := security.NewExpiryCaveat(pastTime)
if err != nil {
- fmt.Errorf("security.ExpiryCaveat(%v) failed: %v", pastTime, err)
+ fmt.Errorf("security.NewExpiryCaveat(%v) failed: %v", pastTime, err)
}
if err := m.AddOrigin(origin3, googleAccount, []security.Caveat{futureExpCav, pastExpCav}, []time.Time{futureTime, pastTime}); err != nil {
diff --git a/services/wspr/internal/rpc/server/server.go b/services/wspr/internal/rpc/server/server.go
index 9ab5309..2069d8c 100644
--- a/services/wspr/internal/rpc/server/server.go
+++ b/services/wspr/internal/rpc/server/server.go
@@ -410,7 +410,7 @@
// CaveatValidation implements a function suitable for passing to
// security.OverrideCaveatValidation.
//
-// Certain caveats (PublicKeyThirdPartyCaveatX) are intercepted and handled in
+// Certain caveats (PublicKeyThirdPartyCaveat) are intercepted and handled in
// go, while all other caveats are evaluated in javascript.
func CaveatValidation(ctx *context.T, call security.Call, cavs [][]security.Caveat) []error {
// If the server isn't set in the context, we just perform validation in Go.
@@ -446,7 +446,7 @@
default:
}
switch cav.Id {
- case security.PublicKeyThirdPartyCaveatX.Id:
+ case security.PublicKeyThirdPartyCaveat.Id:
res := cav.Validate(ctx, call)
if res != nil {
valStatus[i] = validationStatus{