{ "server": true, "datacenter": "dc1", "acl_datacenter": "dc1", "acl_default_policy": "deny", "acl_master_token": "superuser", "bootstrap": true, "log_level": "trace" }
Attempt to register a service using the /agent/service/register endpoint, without passing an ACL:curl 0.0.0.0:8500/v1/agent/service/register -X PUT -v -d '{"Name":"foo"}'
Consul returns 200 to this request. We would have expected a 403 because no ACL was provided.
Now look at the server logs. There are some warnings:2015/02/26 01:19:29 [DEBUG] http: Request /v1/agent/service/register (267.75µs) 2015/02/26 01:19:29 [WARN] consul.catalog: Register of service 'foo' on 'example.com' denied due to ACLs 2015/02/26 01:19:29 [WARN] agent: Service 'foo' registration blocked by ACLs 2015/02/26 01:20:35 [DEBUG] agent: Service 'foo' in sync
List the services on this node using the /agent/services endpoint, with no ACL token. Instead of returning 403, this also returns a 200. The foo service is listed.$ curl 0.0.0.0:8500/v1/agent/services | python -m json.tool { "consul": { "Address": "", "ID": "consul", "Port": 8300, "Service": "consul", "Tags": [] }, "foo": { "Address": "", "ID": "foo", "Port": 0, "Service": "foo", "Tags": null } }
Let's try the /catalog/services endpoint instead. With or without an ACL token, the result is the same: no foo service.$ curl 0.0.0.0:8500/v1/catalog/services | python -m json.tool { "consul": [] }Bug #1: the /agent endpoints should have returned 403 forbidden, since I was not passing an ACL token.$ curl 0.0.0.0:8500/v1/catalog/services?token=superuser | python -m json.tool { "consul": [] }
Now let's try registering the service again using the agent endpoint, but passing an ACL token this time.curl 0.0.0.0:8500/v1/agent/service/register?token=superuser -X PUT -v -d '{"Name":"bar"}'
This gives an HTTP 200, which is what we expected (because this time the ACL token was passed). But the server logs show the same warnings as before:2015/02/26 01:27:40 [DEBUG] http: Request /v1/agent/service/register?token=superuser (203.665µs) 2015/02/26 01:27:40 [WARN] consul.catalog: Register of service 'bar' on 'example.com' denied due to ACLs 2015/02/26 01:27:40 [WARN] agent: Service 'bar' registration blocked by ACLs 2015/02/26 01:28:11 [DEBUG] agent: Service 'bar' in sync
And once again, the service is not listed in the catalog:$ curl 0.0.0.0:8500/v1/catalog/services | python -m json.tool { "consul": [] }$ curl 0.0.0.0:8500/v1/catalog/services?token=superuser | python -m json.tool { "consul": [] }
Bug #2: even if the /agent endpoint is passed an ACL token, the token is not getting passed along to the catalog RPC endpoint, so the service is still not getting registered properly.
We also have a followup question - what is the functional difference between the catalog and agent endpoints? The docs say to prefer the agent endpoint, but they aren't really clear on what the catalog is or why we should use the agent endpoint instead. Thanks.
--
You received this message because you are subscribed to the Google Groups "Consul" group.
To unsubscribe from this group and stop receiving emails from it, send an email to consul-tool...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
WRT the /v1/agent vs /v1/catalog endpoints, the catalog endpoints are mainly for internal use, and represent service state and metadata moreso than configuration. The catalog can be thought of as a cluster-wide view of services, while the agent endpoints are scoped to the local node. One other thing to note is that the agents are authoritative over the catalog, meaning that whenever an agent successfully runs anti-entropy or syncs services and checks to the catalog, the agent state will always win. By registering a check directly with the catalog endpoint, you are not only greatly limited in the configuration options you can pass in, but your registration will likely be corrected by the agent during its next anti-entropy sync.
As for bug #1, shouldn't the agent be rejecting the service registration because no ACL token was passed? The 200 makes sense in that the local registration succeeded, but it seems to me that it shouldn't have succeeded at all due to a lack of authorization.