Closed aparedero closed 6 years ago
Update: Writing payload in HCL format scaping quotes and new lines it seems to work.
{
"ID": "12341234-1234-1234-1234-1234bf00c66e",
"Name": "aaa_server_no_management",
"Type": "client",
"Rules": "agent \"\" {\n policy = \"write\"\n }\n key \"\" {\n policy = \"write\"\n }\n key \"vault\" {\n policy = \"deny\"\n }\n event \"\" {\n policy = \"read\"\n }\n keyring = \"deny\"\n node \"\" {\n policy = \"read\"\n }\n operator = \"read\"\n query \"\" {\n policy = \"read\"\n }\n service \"\" {\n policy = \"write\"\n }"
}
I think your JSON format is not to the specification. The error message there is saying that it can't convert an array, but expected a string, and this matches what we recommend in the rule specification. The HCL specification you posted looks correct. I would revisit the ACL guide and modify the format of the JSON document and it should work as expected!
Overview of the Issue
API endpoint does not parse correctly complex JSON rules. I'm trying to create a new ACL via curl with management token sending payload in json format. Creating the token trough the UI interface loads JSON syntax successfully and works (eg: Using mgmt token switching key policy from
write
todeny
allows and disallows creating new K/V registersUsing the sample-payload works
Reproduction Steps
Steps to reproduce this issue, eg:
Create a cluster with 5 server nodes
Create a JSON file called payload an copy the following contents:
Execute curl command
View error
Consul info for both Client and Server
Server info
``` / # consul info agent: check_monitors = 0 check_ttls = 0 checks = 0 services = 0 build: prerelease = revision = e716d1b5 version = 1.2.2 consul: bootstrap = false known_datacenters = 1 leader = true leader_addr = 10.1.2.177:8300 server = true raft: applied_index = 209 commit_index = 209 fsm_pending = 0 last_contact = 0 last_log_index = 209 last_log_term = 2 last_snapshot_index = 0 last_snapshot_term = 0 latest_configuration = [{Suffrage:Voter ID:4a1ca5df-5941-5273-ee54-669c3ffbcf91 Address:10.1.2.70:8300} {Suffrage:Voter ID:d6b10a67-1c9f-e559-d717-cd77f6e8ca7f Address:10.1.1.191:8300} {Suffrage:Voter ID:06a18810-07e2-7212-595c-a97d0af11c9e Address:10.1.1.160:8300} {Suffrage:Voter ID:443f6232-bd1a-3b23-00f6-768b3b42dfdd Address:10.1.2.231:8300} {Suffrage:Voter ID:b6666b3e-779a-251c-a0d8-3613d8c11bef Address:10.1.2.177:8300}] latest_configuration_index = 1 num_peers = 4 protocol_version = 3 protocol_version_max = 3 protocol_version_min = 0 snapshot_version_max = 1 snapshot_version_min = 0 state = Leader term = 2 runtime: arch = amd64 cpu_count = 2 goroutines = 125 max_procs = 2 os = linux version = go1.10.1 serf_lan: coordinate_resets = 0 encrypted = true event_queue = 0 event_time = 2 failed = 0 health_score = 0 intent_queue = 0 left = 0 member_time = 5 members = 5 query_queue = 0 query_time = 1 serf_wan: coordinate_resets = 0 encrypted = true event_queue = 0 event_time = 1 failed = 0 health_score = 0 intent_queue = 0 left = 0 member_time = 8 members = 5 query_queue = 0 query_time = 1 ```Operating system and Environment details
Consul 1.2.2 in Docker using Amazon EKS platform. Using traefik as L7 balancer.
Log Fragments
There is no information relevant about this. It appears a normal startup
Log
``` 2018/08/08 11:44:10 [INFO] raft: Initial configuration (index=0): [] 2018/08/08 11:44:10 [INFO] raft: Node at 10.1.2.177:8300 [Follower] entering Follower state (Leader: "") 2018/08/08 11:44:10 [INFO] serf: EventMemberJoin: test-consul-0.test-consul 10.1.2.177 2018/08/08 11:44:10 [INFO] serf: EventMemberJoin: test-consul-0 10.1.2.177 2018/08/08 11:44:10 [INFO] agent: Started DNS server 0.0.0.0:8600 (udp) 2018/08/08 11:44:10 [INFO] consul: Adding LAN server test-consul-0 (Addr: tcp/10.1.2.177:8300) (DC: test-consul) 2018/08/08 11:44:10 [INFO] consul: Handled member-join event for server "test-consul-0.test-consul" in area "wan" 2018/08/08 11:44:10 [WARN] agent/proxy: running as root, will not start managed proxies 2018/08/08 11:44:10 [INFO] agent: Started DNS server 0.0.0.0:8600 (tcp) 2018/08/08 11:44:10 [INFO] agent: Started HTTP server on [::]:8500 (tcp) 2018/08/08 11:44:10 [INFO] agent: Retry join LAN is supported for: aliyun aws azure digitalocean gce os packet scaleway softlayer triton vsphere 2018/08/08 11:44:10 [INFO] agent: Joining LAN cluster... 2018/08/08 11:44:10 [INFO] agent: (LAN) joining: [test-consul-1.test-consul.default.svc test-consul-2.test-consul.default.svc test-consul-3.test-consul.default.svc test-consul-4.test-consul.default.svc] 2018/08/08 11:44:10 [INFO] serf: EventMemberJoin: test-consul-2 10.1.2.70 2018/08/08 11:44:10 [INFO] consul: Adding LAN server test-consul-2 (Addr: tcp/10.1.2.70:8300) (DC: test-consul) 2018/08/08 11:44:10 [INFO] agent: started state syncer 2018/08/08 11:44:10 [INFO] serf: EventMemberJoin: test-consul-2.test-consul 10.1.2.70 2018/08/08 11:44:10 [INFO] consul: Handled member-join event for server "test-consul-2.test-consul" in area "wan" 2018/08/08 11:44:10 [INFO] serf: EventMemberJoin: test-consul-3 10.1.1.191 2018/08/08 11:44:10 [INFO] serf: EventMemberJoin: test-consul-1 10.1.1.160 2018/08/08 11:44:10 [INFO] serf: EventMemberJoin: test-consul-4 10.1.2.231 2018/08/08 11:44:10 [INFO] consul: Adding LAN server test-consul-3 (Addr: tcp/10.1.1.191:8300) (DC: test-consul) 2018/08/08 11:44:10 [INFO] consul: Found expected number of peers, attempting bootstrap: 10.1.2.70:8300,10.1.1.191:8300,10.1.1.160:8300,10.1.2.231:8300,10.1.2.177:8300 2018/08/08 11:44:10 [INFO] consul: Adding LAN server test-consul-1 (Addr: tcp/10.1.1.160:8300) (DC: test-consul) 2018/08/08 11:44:10 [INFO] consul: Adding LAN server test-consul-4 (Addr: tcp/10.1.2.231:8300) (DC: test-consul) 2018/08/08 11:44:10 [INFO] serf: EventMemberJoin: test-consul-1.test-consul 10.1.1.160 2018/08/08 11:44:10 [INFO] serf: EventMemberJoin: test-consul-3.test-consul 10.1.1.191 2018/08/08 11:44:10 [INFO] serf: EventMemberJoin: test-consul-4.test-consul 10.1.2.231 2018/08/08 11:44:10 [INFO] consul: Handled member-join event for server "test-consul-1.test-consul" in area "wan" 2018/08/08 11:44:10 [INFO] consul: Handled member-join event for server "test-consul-3.test-consul" in area "wan" 2018/08/08 11:44:10 [INFO] consul: Handled member-join event for server "test-consul-4.test-consul" in area "wan" 2018/08/08 11:44:10 [INFO] agent: (LAN) joined: 4 Err: