Closed welteki closed 2 years ago
The queue worker fails to post reports back to the gateway when gateway_invoke is false and basic_auth is set to "1".
gateway_invoke
basic_auth
Posting reports back to the gateway should return http status 202.
When gateway_invoke is false and the basic_auth env variable is set to "1" posting a report back to the gateway fails with http status 401.
queue-worker logs:
[#1] Invoking: figlet with 6 bytes, via: http://figlet.openfaas-fn.svc.cluster.local:8080/ [#1] Invoked: figlet [200] in 0.016794s [#1] figlet returned 138 bytes [#1] Posting report for figlet, status: 401
The postReport function gets the value of the bacic_auth env variable but only accepts the string "true" to be thruty while ReadConfig accepts "1" and "true" to be thruty. https://github.com/openfaas/nats-queue-worker/blob/b5f165b01f8501b19b651a8df88274aabf70a829/main.go#L318-L320
postReport
bacic_auth
ReadConfig
Two possible solutions:
config
BasicAuth
credentials
config.BasicAuth
- name: gateway_invoke value: "false" - name: basic_auth value: "1"
Docker version docker version (e.g. Docker 17.0.05 ): 20.10.9
docker version
Are you using Docker Swarm or Kubernetes (FaaS-netes)? Kubernetes
Operating System and version (e.g. Linux, Windows, MacOS): Linux
Link to your project or a code example to reproduce issue:
I think the suggestion makes sense.
Please send a PR to use config.BasicAuth instead of checking the env-var.
The queue worker fails to post reports back to the gateway when
gateway_invoke
is false andbasic_auth
is set to "1".Expected Behaviour
Posting reports back to the gateway should return http status 202.
Current Behaviour
When
gateway_invoke
is false and thebasic_auth
env variable is set to "1" posting a report back to the gateway fails with http status 401.queue-worker logs:
Possible Solution
The
postReport
function gets the value of thebacic_auth
env variable but only accepts the string "true" to be thruty whileReadConfig
accepts "1" and "true" to be thruty. https://github.com/openfaas/nats-queue-worker/blob/b5f165b01f8501b19b651a8df88274aabf70a829/main.go#L318-L320Two possible solutions:
config
as an argument to thepostReport
function and use the value of theBasicAuth
field in the above mentioned conditional.basic_auth
value sincecredentials
will always be nil ifconfig.BasicAuth
is false. https://github.com/openfaas/nats-queue-worker/blob/b5f165b01f8501b19b651a8df88274aabf70a829/main.go#L39-L48Steps to Reproduce (for bugs)
Context
Your Environment
Docker version
docker version
(e.g. Docker 17.0.05 ): 20.10.9Are you using Docker Swarm or Kubernetes (FaaS-netes)? Kubernetes
Operating System and version (e.g. Linux, Windows, MacOS): Linux
Link to your project or a code example to reproduce issue: