veyron2/security, veyron/security: Move ACL authorizer to veyron/security.

ACL authorizer is the default implementation of Authorizer, and is
intended to be used by both the Veyron runtime and applications.

Change-Id: Ib17097ccb94ccc2cd629a851b9a1c9fa29ef3d27
diff --git a/examples/bank/pbankd/main.go b/examples/bank/pbankd/main.go
index 76acc17..d673b86 100644
--- a/examples/bank/pbankd/main.go
+++ b/examples/bank/pbankd/main.go
@@ -21,6 +21,7 @@
 	"veyron/examples/bank"
 	"veyron/examples/bank/schema"
 	"veyron/lib/signals"
+	vsecurity "veyron/security"
 	"veyron/security/caveat"
 	idutil "veyron/services/identity/util"
 
@@ -432,7 +433,7 @@
 	bankAccountServer := bank.NewServerBankAccount(pbankd)
 
 	// Setup bank and account authorizers.
-	bankAuth := security.NewACLAuthorizer(security.ACL{security.AllPrincipals: security.LabelSet(security.ReadLabel | security.WriteLabel)})
+	bankAuth := vsecurity.NewACLAuthorizer(security.ACL{security.AllPrincipals: security.LabelSet(security.ReadLabel | security.WriteLabel)})
 	bankAccountAuth := AccountAuthorizer(runtime.Identity().PublicID().Names()[0] + SUFFIX_REGEXP)
 
 	dispatcher := newBankDispatcher(bankServer, bankAccountServer, bankAuth, bankAccountAuth)
diff --git a/examples/boxes/android/src/boxesp2p/main.go b/examples/boxes/android/src/boxesp2p/main.go
index 9e8680d..0cc51e6 100644
--- a/examples/boxes/android/src/boxesp2p/main.go
+++ b/examples/boxes/android/src/boxesp2p/main.go
@@ -69,6 +69,7 @@
 	"veyron/examples/boxes"
 	inaming "veyron/runtimes/google/naming"
 	vsync "veyron/runtimes/google/vsync"
+	vsecurity "veyron/security"
 	sstore "veyron/services/store/server"
 
 	"veyron2"
@@ -255,7 +256,7 @@
 }
 
 func (gs *goState) registerAsPeer() {
-	auth := security.NewACLAuthorizer(security.ACL{security.AllPrincipals: security.LabelSet(security.AdminLabel)})
+	auth := vsecurity.NewACLAuthorizer(security.ACL{security.AllPrincipals: security.LabelSet(security.AdminLabel)})
 	gs.disp.drawAuth = auth
 	gs.disp.drawServer = ipc.ReflectInvoker(boxes.NewServerDrawInterface(gs))
 	endPt, err := gs.ipc.Listen("tcp", gs.myIPAddr+drawServicePort)
@@ -358,7 +359,7 @@
 	if err != nil {
 		panic(fmt.Errorf("LoadACL failed:%v", err))
 	}
-	auth := security.NewACLAuthorizer(acl)
+	auth := vsecurity.NewACLAuthorizer(acl)
 	gs.disp.storeDispatcher = sstore.NewStoreDispatcher(store, auth)
 
 	// Create an endpoint and start listening
diff --git a/runtimes/google/ipc/full_test.go b/runtimes/google/ipc/full_test.go
index 718b9f8..0020de0 100644
--- a/runtimes/google/ipc/full_test.go
+++ b/runtimes/google/ipc/full_test.go
@@ -22,6 +22,7 @@
 	"veyron/runtimes/google/lib/publisher"
 	inaming "veyron/runtimes/google/naming"
 	isecurity "veyron/runtimes/google/security"
+	vsecurity "veyron/security"
 	"veyron/security/caveat"
 
 	"veyron2"
@@ -162,7 +163,7 @@
 		authorizer = nil
 	case "aclAuth":
 		// Only authorize clients matching patterns "client" or "server/*".
-		authorizer = security.NewACLAuthorizer(security.ACL{
+		authorizer = vsecurity.NewACLAuthorizer(security.ACL{
 			"server/*": security.LabelSet(security.AdminLabel),
 			"client":   security.LabelSet(security.AdminLabel),
 		})
diff --git a/runtimes/google/ipc/server.go b/runtimes/google/ipc/server.go
index f155996..6ed86f0 100644
--- a/runtimes/google/ipc/server.go
+++ b/runtimes/google/ipc/server.go
@@ -11,6 +11,7 @@
 	"veyron/runtimes/google/lib/publisher"
 	inaming "veyron/runtimes/google/naming"
 	isecurity "veyron/runtimes/google/security"
+	vsecurity "veyron/security"
 
 	"veyron2"
 	"veyron2/context"
@@ -538,8 +539,8 @@
 	// Since the provided authorizer is nil we create a default IDAuthorizer
 	// for the local identity of the flow. This authorizer only authorizes
 	// remote identities that have either been blessed by the local identity
-	// or have blessed the local identity. (See security.NewACLAuthorizer)
-	return security.NewACLAuthorizer(defaultACL(fs.flow.LocalID())).Authorize(fs)
+	// or have blessed the local identity. (See vsecurity.NewACLAuthorizer)
+	return vsecurity.NewACLAuthorizer(defaultACL(fs.flow.LocalID())).Authorize(fs)
 }
 
 // setDeadline sets a deadline on the flow. The flow will be cancelled if it
diff --git a/runtimes/google/rt/ipc_test.go b/runtimes/google/rt/ipc_test.go
index 85c49fd..e99e8c9 100644
--- a/runtimes/google/rt/ipc_test.go
+++ b/runtimes/google/rt/ipc_test.go
@@ -9,6 +9,7 @@
 
 	_ "veyron/lib/testutil"
 	isecurity "veyron/runtimes/google/security"
+	vsecurity "veyron/security"
 
 	"veyron2"
 	"veyron2/ipc"
@@ -157,7 +158,7 @@
 			continue
 		}
 		defer stopServer(server)
-		if err := server.Serve("", ipc.SoloDispatcher(&testService{}, security.NewACLAuthorizer(security.ACL{security.AllPrincipals: security.AllLabels}))); err != nil {
+		if err := server.Serve("", ipc.SoloDispatcher(&testService{}, vsecurity.NewACLAuthorizer(security.ACL{security.AllPrincipals: security.AllLabels}))); err != nil {
 			t.Errorf("error serving service: ", err)
 			continue
 		}
diff --git a/security/acl_authorizer.go b/security/acl_authorizer.go
new file mode 100644
index 0000000..82b35d9
--- /dev/null
+++ b/security/acl_authorizer.go
@@ -0,0 +1,103 @@
+package security
+
+// This file provides an implementation of security.Authorizer.
+//
+// Definitions
+// * Self-RPC: An RPC request is said to be a "self-RPC" if the identities
+// at the local and remote ends are identical.
+
+import (
+	"errors"
+	"os"
+	"reflect"
+
+	"veyron2/security"
+)
+
+var (
+	errACL          = errors.New("no matching ACL entry found")
+	errInvalidLabel = errors.New("label is invalid")
+	errNilID        = errors.New("identity being matched is nil")
+	errNilACL       = errors.New("ACL is nil")
+	nullACL         security.ACL
+)
+
+// aclAuthorizer implements Authorizer.
+type aclAuthorizer security.ACL
+
+// Authorize verifies a request iff the identity at the remote end has a name authorized by
+// the aclAuthorizer's ACL for the request's label, or the request corresponds to a self-RPC.
+func (a aclAuthorizer) Authorize(ctx security.Context) error {
+	// Test if the request corresponds to a self-RPC.
+	if ctx.LocalID() != nil && ctx.RemoteID() != nil && reflect.DeepEqual(ctx.LocalID(), ctx.RemoteID()) {
+		return nil
+	}
+	// Match the aclAuthorizer's ACL.
+	return matchesACL(ctx.RemoteID(), ctx.Label(), security.ACL(a))
+}
+
+// NewACLAuthorizer creates an authorizer from the provided ACL. The
+// authorizer authorizes a request iff the identity at the remote end has a name
+// authorized by the provided ACL for the request's label, or the request
+// corresponds to a self-RPC.
+func NewACLAuthorizer(acl security.ACL) security.Authorizer { return aclAuthorizer(acl) }
+
+// fileACLAuthorizer implements Authorizer.
+type fileACLAuthorizer string
+
+// Authorize reads and decodes the fileACLAuthorizer's ACL file into a ACL and
+// then verifies the request according to an aclAuthorizer based on the ACL. If
+// reading or decoding the file fails then no requests are authorized.
+func (a fileACLAuthorizer) Authorize(ctx security.Context) error {
+	acl, err := loadACLFromFile(string(a))
+	if err != nil {
+		return err
+	}
+	return aclAuthorizer(acl).Authorize(ctx)
+}
+
+// NewFileACLAuthorizer creates an authorizer from the provided path to a file
+// containing a JSON-encoded ACL. Each call to "Authorize" involves reading and
+// decoding a ACL from the file and then authorizing the request according to the
+// ACL. The authorizer monitors the file so out of band changes to the contents of
+// the file are reflected in the ACL. If reading or decoding the file fails then
+// no requests are authorized.
+//
+// The JSON-encoding of a ACL is essentially a JSON object describing a map from
+// PrincipalPatterns to encoded LabelSets (see LabelSet.MarshalJSON).
+// Examples:
+// * `{"*" : "RW"}` encodes an ACL that allows all principals to access all methods with
+//   ReadLabel or WriteLabel.
+// * `{"veyron/alice": "RW", "veyron/bob/*": "R"} encodes an ACL that allows all principals
+//   matching "veyron/alice" to access methods with ReadLabel or WriteLabel,
+//   and all principals matching "veyron/bob/*" to access methods with ReadLabel.
+//   (Also see PublicID.Match.)
+//
+// TODO(ataly, ashankar): Instead of reading the file on each call we should use the "inotify"
+// mechanism to watch the file. Eventually we should also support ACLs stored in the Veyron
+// store.
+func NewFileACLAuthorizer(filePath string) security.Authorizer { return fileACLAuthorizer(filePath) }
+
+func matchesACL(id security.PublicID, label security.Label, acl security.ACL) error {
+	if id == nil {
+		return errNilID
+	}
+	if acl == nil {
+		return errNilACL
+	}
+	for key, labels := range acl {
+		if labels.HasLabel(label) && id.Match(key) {
+			return nil
+		}
+	}
+	return errACL
+}
+
+func loadACLFromFile(filePath string) (security.ACL, error) {
+	f, err := os.Open(filePath)
+	if err != nil {
+		return nil, err
+	}
+	defer f.Close()
+	return security.LoadACL(f)
+}
diff --git a/security/acl_authorizer_test.go b/security/acl_authorizer_test.go
new file mode 100644
index 0000000..6c54ca4
--- /dev/null
+++ b/security/acl_authorizer_test.go
@@ -0,0 +1,249 @@
+package security
+
+import (
+	"io/ioutil"
+	"os"
+	"runtime"
+	"testing"
+	"time"
+
+	"veyron2/naming"
+	"veyron2/security"
+)
+
+type authMap map[security.PublicID]security.LabelSet
+
+// context implements Context.
+type context struct {
+	localID, remoteID    security.PublicID
+	discharges           security.CaveatDischargeMap
+	method, name, suffix string
+	label                security.Label
+}
+
+func (c *context) Method() string                                { return c.method }
+func (c *context) Name() string                                  { return c.name }
+func (c *context) Suffix() string                                { return c.suffix }
+func (c *context) Label() security.Label                         { return c.label }
+func (c *context) CaveatDischarges() security.CaveatDischargeMap { return c.discharges }
+func (c *context) LocalID() security.PublicID                    { return c.localID }
+func (c *context) RemoteID() security.PublicID                   { return c.remoteID }
+func (c *context) LocalEndpoint() naming.Endpoint                { return nil }
+func (c *context) RemoteEndpoint() naming.Endpoint               { return nil }
+
+func saveACLToTempFile(acl security.ACL) string {
+	f, err := ioutil.TempFile("", "saved_acl")
+	if err != nil {
+		panic(err)
+	}
+	defer f.Close()
+	if err := security.SaveACL(f, acl); err != nil {
+		defer os.Remove(f.Name())
+		panic(err)
+	}
+	return f.Name()
+}
+
+func updateACLInFile(fileName string, acl security.ACL) {
+	f, err := os.OpenFile(fileName, os.O_WRONLY, 0600)
+	if err != nil {
+		panic(err)
+	}
+	defer f.Close()
+	if err := security.SaveACL(f, acl); err != nil {
+		panic(err)
+	}
+}
+
+func bless(blessee security.PublicID, blesser security.PrivateID, name string) security.PublicID {
+	blessed, err := blesser.Bless(blessee, name, 5*time.Minute, nil)
+	if err != nil {
+		panic(err)
+	}
+	return blessed
+}
+
+func derive(pub security.PublicID, priv security.PrivateID) security.PrivateID {
+	d, err := priv.Derive(pub)
+	if err != nil {
+		panic(err)
+	}
+	return d
+}
+
+func testSelfRPCs(t *testing.T, authorizer security.Authorizer) {
+	_, file, line, _ := runtime.Caller(1)
+	var (
+		veyron      = security.FakePrivateID("veyron")
+		alice       = security.FakePrivateID("alice")
+		veyronAlice = bless(alice.PublicID(), veyron, "alice")
+	)
+	testData := []struct {
+		localID, remoteID security.PublicID
+		isAuthorized      bool
+	}{
+		{alice.PublicID(), alice.PublicID(), true},
+		{veyron.PublicID(), veyron.PublicID(), true},
+		{veyron.PublicID(), alice.PublicID(), false},
+		{veyronAlice, veyronAlice, true},
+		{veyronAlice, alice.PublicID(), false},
+		{veyronAlice, veyron.PublicID(), false},
+	}
+	for _, d := range testData {
+		ctx := &context{localID: d.localID, remoteID: d.remoteID}
+		if got, want := authorizer.Authorize(ctx), d.isAuthorized; (got == nil) != want {
+			t.Errorf("%s:%d: %+v.Authorize(&context{localID: %v, remoteID: %v}) returned error: %v, want error: %v", file, line, authorizer, d.localID, d.remoteID, got, !want)
+		}
+	}
+}
+
+func testAuthorizations(t *testing.T, authorizer security.Authorizer, authorizations authMap) {
+	_, file, line, _ := runtime.Caller(1)
+	for user, labels := range authorizations {
+		for _, l := range security.ValidLabels {
+			ctx := &context{remoteID: user, label: l}
+			if got, want := authorizer.Authorize(ctx), labels.HasLabel(l); (got == nil) != want {
+				t.Errorf("%s:%d: %+v.Authorize(&context{remoteID: %v, label: %v}) returned error: %v, want error: %v", file, line, authorizer, user, l, got, !want)
+			}
+		}
+	}
+}
+
+func testNothingPermitted(t *testing.T, authorizer security.Authorizer) {
+	_, file, line, _ := runtime.Caller(1)
+	var (
+		veyronPrivateID   = security.FakePrivateID("veyron")
+		alicePrivateID    = security.FakePrivateID("alice")
+		randomPrivateID   = security.FakePrivateID("random")
+		veyron            = veyronPrivateID.PublicID()
+		alice             = alicePrivateID.PublicID()
+		random            = randomPrivateID.PublicID()
+		veyronAlice       = bless(alice, veyronPrivateID, "alice")
+		veyronAliceFriend = bless(random, derive(veyronAlice, alicePrivateID), "friend")
+		veyronBob         = bless(random, veyronPrivateID, "bob")
+	)
+	users := []security.PublicID{
+		veyron,
+		random,
+		alice,
+
+		// Blessed principals
+		veyronAlice,
+		veyronAliceFriend,
+		veyronBob,
+	}
+	// No principal (whether the identity provider is trusted or not)
+	// should have access to any valid or invalid label.
+	for _, u := range users {
+		for _, l := range security.ValidLabels {
+			ctx := &context{remoteID: u, label: l}
+			if got := authorizer.Authorize(ctx); got == nil {
+				t.Errorf("%s:%d: %+v.Authorize(%v) returns nil, want error", file, line, authorizer, ctx)
+			}
+		}
+		invalidLabel := security.Label(3)
+		ctx := &context{remoteID: u, label: invalidLabel}
+		if got := authorizer.Authorize(ctx); got == nil {
+			t.Errorf("%s:%d: %+v.Authorize(%v) returns nil, want error", file, line, authorizer, ctx)
+		}
+	}
+}
+
+func TestACLAuthorizer(t *testing.T) {
+	const (
+		// Shorthands
+		R = security.ReadLabel
+		W = security.WriteLabel
+		A = security.AdminLabel
+		D = security.DebugLabel
+		M = security.MonitoringLabel
+	)
+	// Principals to test
+	var (
+		veyronPrivateID = security.FakePrivateID("veyron")
+		alicePrivateID  = security.FakePrivateID("alice")
+		veyron          = veyronPrivateID.PublicID()
+		alice           = alicePrivateID.PublicID()
+		bob             = security.FakePrivateID("bob").PublicID()
+
+		// Blessed principals
+		veyronAlice       = bless(alice, veyronPrivateID, "alice")
+		veyronBob         = bless(bob, veyronPrivateID, "bob")
+		veyronAliceFriend = bless(bob, derive(veyronAlice, alicePrivateID), "friend")
+	)
+	// Convenience function for combining Labels into a LabelSet.
+	LS := func(labels ...security.Label) security.LabelSet {
+		var ret security.LabelSet
+		for _, l := range labels {
+			ret = ret | security.LabelSet(l)
+		}
+		return ret
+	}
+
+	// ACL for testing
+	acl := security.ACL{
+		"*": LS(R),
+		"fake/veyron/alice/*": LS(W, R),
+		"fake/veyron/alice":   LS(A, D, M),
+		"fake/veyron/bob":     LS(D, M),
+	}
+
+	// Authorizations for the above ACL.
+	authorizations := authMap{
+		// alice and bob have only what "*" has.
+		alice: LS(R),
+		bob:   LS(R),
+		// veyron and veyronAlice have R, W, A, D, M from the "veyron/alice" and
+		// "veyron/alice/*" ACL entries.
+		veyron:      LS(R, W, A, D, M),
+		veyronAlice: LS(R, W, A, D, M),
+		// veyronBob has R, D, M from "*" and "veyron/bob" ACL entries.
+		veyronBob: LS(R, D, M),
+		// veyronAliceFriend has W, R from the "veyron/alice/*" ACL entry.
+		veyronAliceFriend: LS(W, R),
+		// nil PublicIDs are not authorized.
+		nil: LS(),
+	}
+	// Create an aclAuthorizer based on the ACL and verify the authorizations.
+	authorizer := NewACLAuthorizer(acl)
+	testAuthorizations(t, authorizer, authorizations)
+	testSelfRPCs(t, authorizer)
+
+	// Create a fileACLAuthorizer by saving the ACL in a file, and verify the
+	// authorizations.
+	fileName := saveACLToTempFile(acl)
+	defer os.Remove(fileName)
+	fileAuthorizer := NewFileACLAuthorizer(fileName)
+	testAuthorizations(t, fileAuthorizer, authorizations)
+	testSelfRPCs(t, fileAuthorizer)
+
+	// Modify the ACL stored in the file and verify that the authorizations appropriately
+	// change for the fileACLAuthorizer.
+	acl["fake/veyron/bob"] = LS(R, W, A, D, M)
+	updateACLInFile(fileName, acl)
+
+	authorizations[veyronBob] = LS(R, W, A, D, M)
+	testAuthorizations(t, fileAuthorizer, authorizations)
+	testSelfRPCs(t, fileAuthorizer)
+
+	// Update the ACL file with invalid contents and verify that no requests are
+	// authorized.
+	f, err := os.OpenFile(fileName, os.O_WRONLY, 0600)
+	if err != nil {
+		panic(err)
+	}
+	f.Write([]byte("invalid ACL"))
+	f.Close()
+	testNothingPermitted(t, fileAuthorizer)
+
+	// Verify that a fileACLAuthorizer based on a nonexistent file does not authorize any
+	// requests.
+	fileAuthorizer = NewFileACLAuthorizer("fileDoesNotExist")
+	testNothingPermitted(t, fileAuthorizer)
+}
+
+func TestNilACLAuthorizer(t *testing.T) {
+	authorizer := NewACLAuthorizer(nil)
+	testNothingPermitted(t, authorizer)
+	testSelfRPCs(t, authorizer)
+}
diff --git a/security/flag/flag.go b/security/flag/flag.go
index fa032b8..11dfcca 100644
--- a/security/flag/flag.go
+++ b/security/flag/flag.go
@@ -7,6 +7,8 @@
 	"errors"
 	"flag"
 
+	vsecurity "veyron/security"
+
 	"veyron2/security"
 )
 
@@ -27,11 +29,11 @@
 		panic(errors.New("only one of the flags \"--acl\" or \"--acl_file\" must be provided"))
 	}
 	if len(*aclFile) != 0 {
-		return security.NewFileACLAuthorizer(*aclFile)
+		return vsecurity.NewFileACLAuthorizer(*aclFile)
 	}
 	a, err := security.LoadACL(bytes.NewBufferString(*acl))
 	if err != nil {
 		return nil
 	}
-	return security.NewACLAuthorizer(a)
+	return vsecurity.NewACLAuthorizer(a)
 }
diff --git a/security/flag/flag_test.go b/security/flag/flag_test.go
index 5fa5616..03ae915 100644
--- a/security/flag/flag_test.go
+++ b/security/flag/flag_test.go
@@ -7,6 +7,7 @@
 	"testing"
 
 	tsecurity "veyron/lib/testutil/security"
+	vsecurity "veyron/security"
 
 	"veyron2/security"
 )
@@ -45,19 +46,19 @@
 		},
 		{
 			flags:    flagValue{"acl": "{}"},
-			wantAuth: security.NewACLAuthorizer(acl1),
+			wantAuth: vsecurity.NewACLAuthorizer(acl1),
 		},
 		{
 			flags:    flagValue{"acl": "{\"veyron/alice\":\"RW\", \"veyron/bob\": \"R\"}"},
-			wantAuth: security.NewACLAuthorizer(acl2),
+			wantAuth: vsecurity.NewACLAuthorizer(acl2),
 		},
 		{
 			flags:    flagValue{"acl": "{\"veyron/bob\":\"R\", \"veyron/alice\": \"WR\"}"},
-			wantAuth: security.NewACLAuthorizer(acl2),
+			wantAuth: vsecurity.NewACLAuthorizer(acl2),
 		},
 		{
 			flags:    flagValue{"acl_file": acl2File},
-			wantAuth: security.NewFileACLAuthorizer(acl2File),
+			wantAuth: vsecurity.NewFileACLAuthorizer(acl2File),
 		},
 		{
 			flags:     flagValue{"acl_file": acl2File, "acl": "{\"veyron/alice\":\"RW\", \"veyron/bob\": \"R\"}"},
diff --git a/services/identity/identityd/main.go b/services/identity/identityd/main.go
index 9c592b8..fd91182 100644
--- a/services/identity/identityd/main.go
+++ b/services/identity/identityd/main.go
@@ -12,9 +12,11 @@
 	"time"
 
 	"veyron/lib/signals"
+	vsecurity "veyron/security"
 	"veyron/services/identity/blesser"
 	"veyron/services/identity/googleoauth"
 	"veyron/services/identity/handlers"
+
 	"veyron2"
 	"veyron2/ipc"
 	"veyron2/rt"
@@ -121,7 +123,7 @@
 	}
 	allowEveryoneACL := security.ACL{security.AllPrincipals: security.AllLabels}
 	objectname := fmt.Sprintf("identity/%s/google", r.Identity().PublicID().Names()[0])
-	if err := server.Serve(objectname, ipc.SoloDispatcher(blesser.NewGoogleOAuthBlesserServer(params), security.NewACLAuthorizer(allowEveryoneACL))); err != nil {
+	if err := server.Serve(objectname, ipc.SoloDispatcher(blesser.NewGoogleOAuthBlesserServer(params), vsecurity.NewACLAuthorizer(allowEveryoneACL))); err != nil {
 		return nil, fmt.Errorf("failed to start Veyron service: %v", err)
 	}
 	vlog.Infof("Google blessing service enabled at endpoint %v and name %q", ep, objectname)
diff --git a/services/mounttable/lib/mounttable.go b/services/mounttable/lib/mounttable.go
index bfb4f56..866df60 100644
--- a/services/mounttable/lib/mounttable.go
+++ b/services/mounttable/lib/mounttable.go
@@ -10,6 +10,7 @@
 	"time"
 
 	"veyron/lib/glob"
+	vsecurity "veyron/security"
 
 	"veyron2/ipc"
 	"veyron2/naming"
@@ -81,7 +82,7 @@
 	}
 	result := make(map[string]security.Authorizer)
 	for name, acl := range acls {
-		result[name] = security.NewACLAuthorizer(acl)
+		result[name] = vsecurity.NewACLAuthorizer(acl)
 	}
 	if result["/"] == nil {
 		return nil, fmt.Errorf("No acl for / in %s", path)
diff --git a/services/security/dischargerd/main.go b/services/security/dischargerd/main.go
index cde9103..fb44bb7 100644
--- a/services/security/dischargerd/main.go
+++ b/services/security/dischargerd/main.go
@@ -4,7 +4,9 @@
 	"flag"
 
 	"veyron/lib/signals"
+	vsecurity "veyron/security"
 	"veyron/services/security/discharger"
+
 	"veyron2/ipc"
 	"veyron2/rt"
 	"veyron2/security"
@@ -25,9 +27,9 @@
 
 func authorizer(file string) security.Authorizer {
 	if file == "" {
-		return security.NewACLAuthorizer(security.ACL{security.AllPrincipals: security.AllLabels})
+		return vsecurity.NewACLAuthorizer(security.ACL{security.AllPrincipals: security.AllLabels})
 	}
-	return security.NewFileACLAuthorizer(file)
+	return vsecurity.NewFileACLAuthorizer(file)
 }
 
 func main() {
diff --git a/services/wsprd/ipc/server/server.go b/services/wsprd/ipc/server/server.go
index 8b79b15..b8e7cab 100644
--- a/services/wsprd/ipc/server/server.go
+++ b/services/wsprd/ipc/server/server.go
@@ -8,9 +8,11 @@
 	"fmt"
 	"sync"
 
+	vsecurity "veyron/security"
 	"veyron/services/wsprd/ipc/stream"
 	"veyron/services/wsprd/lib"
 	"veyron/services/wsprd/signature"
+
 	"veyron2"
 	"veyron2/ipc"
 	"veyron2/security"
@@ -166,7 +168,7 @@
 	}
 
 	if s.dispatcher == nil {
-		s.dispatcher = newDispatcher(invoker, security.NewACLAuthorizer(
+		s.dispatcher = newDispatcher(invoker, vsecurity.NewACLAuthorizer(
 			security.ACL{security.AllPrincipals: security.AllLabels},
 		))
 	}