mirror of
https://github.com/kemko/nomad.git
synced 2026-01-04 17:35:43 +03:00
acl: add replication to ACL Roles from authoritative region. (#14176)
ACL Roles along with policies and global token will be replicated from the authoritative region to all federated regions. This involves a new replication loop running on the federated leader. Policies and roles may be replicated at different times, meaning the policies and role references may not be present within the local state upon replication upsert. In order to bypass the RPC and state check, a new RPC request parameter has been added. This is used by the replication process; all other callers will trigger the ACL role policy validation check. There is a new ACL RPC endpoint to allow the reading of a set of ACL Roles which is required by the replication process and matches ACL Policies and Tokens. A bug within the ACL Role listing RPC has also been fixed which returned incorrect data during blocking queries where a deletion had occurred.
This commit is contained in:
@@ -636,7 +636,7 @@ func TestHTTPServer_ACLRoleListRequest(t *testing.T) {
|
||||
|
||||
// Create two ACL roles and put these directly into state.
|
||||
aclRoles := []*structs.ACLRole{mock.ACLRole(), mock.ACLRole()}
|
||||
require.NoError(t, srv.server.State().UpsertACLRoles(structs.MsgTypeTestSetup, 20, aclRoles))
|
||||
require.NoError(t, srv.server.State().UpsertACLRoles(structs.MsgTypeTestSetup, 20, aclRoles, false))
|
||||
|
||||
// Build the HTTP request.
|
||||
req, err := http.NewRequest(http.MethodGet, "/v1/acl/roles", nil)
|
||||
@@ -669,7 +669,7 @@ func TestHTTPServer_ACLRoleListRequest(t *testing.T) {
|
||||
// using a custom prefix.
|
||||
aclRoles := []*structs.ACLRole{mock.ACLRole(), mock.ACLRole()}
|
||||
aclRoles[1].ID = "badger-badger-badger-" + uuid.Generate()
|
||||
require.NoError(t, srv.server.State().UpsertACLRoles(structs.MsgTypeTestSetup, 20, aclRoles))
|
||||
require.NoError(t, srv.server.State().UpsertACLRoles(structs.MsgTypeTestSetup, 20, aclRoles, false))
|
||||
|
||||
// Build the HTTP request.
|
||||
req, err := http.NewRequest(http.MethodGet, "/v1/acl/roles?prefix=badger-badger-badger", nil)
|
||||
@@ -901,7 +901,7 @@ func TestHTTPServer_ACLRoleSpecificRequest(t *testing.T) {
|
||||
// Create a mock role and put directly into state.
|
||||
mockACLRole := mock.ACLRole()
|
||||
require.NoError(t, srv.server.State().UpsertACLRoles(
|
||||
structs.MsgTypeTestSetup, 20, []*structs.ACLRole{mockACLRole}))
|
||||
structs.MsgTypeTestSetup, 20, []*structs.ACLRole{mockACLRole}, false))
|
||||
|
||||
url := fmt.Sprintf("/v1/acl/role/name/%s", mockACLRole.Name)
|
||||
|
||||
@@ -935,7 +935,7 @@ func TestHTTPServer_ACLRoleSpecificRequest(t *testing.T) {
|
||||
// Create a mock role and put directly into state.
|
||||
mockACLRole := mock.ACLRole()
|
||||
require.NoError(t, srv.server.State().UpsertACLRoles(
|
||||
structs.MsgTypeTestSetup, 20, []*structs.ACLRole{mockACLRole}))
|
||||
structs.MsgTypeTestSetup, 20, []*structs.ACLRole{mockACLRole}, false))
|
||||
|
||||
url := fmt.Sprintf("/v1/acl/role/%s", mockACLRole.ID)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user