Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable ability to send username/password for Basic Auth in service check stanza #2924

Closed
leowmjw opened this issue Jul 28, 2017 · 4 comments
Closed

Comments

@leowmjw
Copy link

leowmjw commented Jul 28, 2017

Nomad v0.6

Request for ability to pass username/password for Basic Auth in the service check stanza. As example, I have below where it checks the cluster endpoints for ElasticSearch:

      service {
        name = "escluster"
        tags = [
          "search",
          "cluster"
        ]
        port = "eshttp"
        check {
          name = "available"
          type = "tcp"
          interval = "10s"
          timeout = "2s"
        }
        check {
          name = "ready"
          type = "http"
          port = "eshttp"
          path = "/_cluster/health?wait_for_status=yellow"
          interval = "30s"
          timeout = "10s"
        }
      }

As cannot authenticate; will hit error below:

HTTP GET http://10.0.42.4:47553/_cluster/health?wait_for_status=yellow: 401 Unauthorized Output: {"error":{"root_cause":[{"type":"security_exception","reason":"missing authentication token for REST request [/_cluster/health?wait_for_status=yellow]","header":{"WWW-Authenticate":"Basic realm=\"security\" charset=\"UTF-8\""}}],"type":"security_exception","reason":"missing authentication token for REST request [/_cluster/health?wait_for_status=yellow]","header":{"WWW-Authenticate":"Basic realm=\"security\" charset=\"UTF-8\""}},"status":401}

Thanks for any possible guidance. Thanks!

@dadgar
Copy link
Contributor

dadgar commented Jul 28, 2017

Looks like there is support in Consul as of late: hashicorp/consul#3107

Should allow headers in Nomad as well.

@leowmjw
Copy link
Author

leowmjw commented Jul 29, 2017

Thanks @dadgar. Unfortunately it seems header in check is not valid?

$ nomad run docker-cluster-elasticsearch.nomad 
Error getting job struct: Error parsing job file from docker-cluster-elasticsearch.nomad: error parsing 'job': 1 error(s) occurred:

* group: 'complex', task: 'elasticsearch', service: 'escluster', check -> invalid key: header

Config below:

        check {
          name = "ready"
          type = "http"
          port = "eshttp"
          path = "/_cluster/health?wait_for_status=yellow"
          header = "Authorization: Basic ZWxhc3RpYzpjaGFuZ2VtZQ=="
          interval = "30s"
          timeout = "10s"
        }

If you can provide some guidance on what needs to be done; I'll take a stab at doing a PR --> I'm a Golang noob :)

I see in the Consul docs, the example for header is like below:

...
"header": {"x-foo":["bar", "baz"]},
...

so does the resulting output will have to be as below; correct?

...
"header": {"Authorization":["Basic", "ZWxhc3RpYzpjaGFuZ2VtZQ=="]},
...

leowmjw added a commit to leowmjw/nomad-samples that referenced this issue Jul 29, 2017
Changesets:
- Simplify config with Docker; had to up the memory as JVM minimum memory is 2Gb!
- Adjust listening ip to all interface so that cluster discovery works
- Tried to handle authentication for ES endpoints but fail
TODO: Once hashicorp/nomad#2924 is fixed; need to send in the
@dadgar
Copy link
Contributor

dadgar commented Aug 1, 2017

@leowmjw Ah sorry to confuse you! I was agreeing that we should add support. It isn't there currently. Hopefully in 0.6.1 or 0.6.2

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants