apocas / docker-modem

Docker Remote API network stack driver.
Apache License 2.0
234 stars 112 forks source link

Added Basic authentication to secure the Docker API #87

Closed lmorandini closed 5 years ago

lmorandini commented 6 years ago

The "auth" property of options is Base64-encoded and added as header "Authorization" to every request. This is necessary when the Docker API is secured by Basic HTTP authentication.

apocas commented 6 years ago

You can pass all the headers you need via options object. https://github.com/apocas/docker-modem/blob/master/lib/modem.js#L126

I think it's better to only map the official headers (like X-Registry-Auth) and leave "custom" headers to "user land" via options.

lmorandini commented 6 years ago

Yes, that;s a better alternative However, since the Authorization header (and possibly others) has to be sent with every request, wouldn't it be better to define them when the Modem object is created, and then merge them with the additional headers (if any) passed as argument to "dial"?

In other words: a) adding "this.headers= opts.headers;" to the "Modem" function in "modem.js" b) performing the merge in "dial"

apocas commented 5 years ago

Custom headers implemented in https://github.com/apocas/docker-modem/pull/104