Commit Graph

46 Commits

Author SHA1 Message Date
2034662b7a When authz plugin is disabled, remove from authz middleware chain.
When the daemon is configured to run with an authorization-plugin and if
the plugin is disabled, the daemon continues to send API requests to the
plugin and expect it to respond. But the plugin has been disabled. As a
result, all API requests are blocked. Fix this behavior by removing the
disabled plugin from the authz middleware chain.

Tested using riyaz/authz-no-volume-plugin and observed that after
disabling the plugin, API request/response is functional.

Fixes #31836

Signed-off-by: Anusha Ragunathan <anusha.ragunathan@docker.com>
Upstream-commit: 38de272bd4dfea945985b7031cd353ac5f6507c5
Component: engine
2017-03-22 12:07:39 -07:00
b1d58a6a62 Fixed a typo within pkg/authorization/api.go
Signed-off-by: Diego Romero <idiegoromero@gmail.com>
Upstream-commit: 48b8f54876ff3269db46443eb91adeab2ea8b74b
Component: engine
2017-01-17 21:51:16 -05:00
8b3646ee75 plugingetter: Avoid all caps for constant declarations
Go style calls for mixed caps instead of all caps:
https://golang.org/doc/effective_go.html#mixed-caps

Change LOOKUP, ACQUIRE, and RELEASE to Lookup, Acquire, and Release.

This vendors a fork of libnetwork for now, to deal with a cyclic
dependency issue. The change will be upstream to libnetwork once this is
merged.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
Upstream-commit: 428600108cce0a11e65ec4ebd9e439e947b55da7
Component: engine
2017-01-04 10:19:04 -08:00
e5912f7d7e Rename Remote API to Engine API
Implementation of https://github.com/docker/docker/issues/28319

Signed-off-by: Ben Firshman <ben@firshman.co.uk>
Upstream-commit: f0d55cd081c6e8ad2a8222c787d54f9aae15723f
Component: engine
2016-11-22 12:49:38 +00:00
abdf1bbec3 Revert "Update authz plugin list on failure."
This reverts commit fae904af02a184833d2cd5ce9fdd61a4083707c7.

Signed-off-by: Riyaz Faizullabhoy <riyaz.faizullabhoy@docker.com>
Upstream-commit: a64fc8eea3266968c8e0082dbe6a2f5a8a5bbdc0
Component: engine
2016-11-03 15:49:21 -07:00
19be62abc4 pkg/authorization: send request's TLS peer certificates to plugins
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Upstream-commit: 1452c1cc718006c72c4b7876d4b3c0a08281074e
Component: engine
2016-10-31 17:37:19 +01:00
78119ce904 Update authz plugin list on failure.
When daemon fails to load an authz plugin, it should be removed from
the plugin list. Else the plugin is retried on every request and
response, resulting in undesired behavior (eg. daemon panic)

Signed-off-by: Anusha Ragunathan <anusha@docker.com>
Upstream-commit: fae904af02a184833d2cd5ce9fdd61a4083707c7
Component: engine
2016-10-28 11:16:06 -07:00
8fb804fc58 Fix the typo of URLs
Signed-off-by: YuPengZTE <yu.peng36@zte.com.cn>
Upstream-commit: fa378413f88054d0a336d675e7280930ddc86cb2
Component: engine
2016-10-19 17:46:27 +08:00
3643ef102a Merge pull request #27267 from ezrasilvera/plugin_fix
Call the AuthZRes function also when the daemon  returns error
Upstream-commit: 194f04bbbe5b4de06235bf56b8842cadac0294dc
Component: engine
2016-10-18 21:53:43 -07:00
1f94129ec0 Merge pull request #27293 from anusha-ragunathan/use-pluginv2-authz
Make authz use pluginv2
Upstream-commit: 8658748ef716e43a5f6d834825d818012ed6e2c4
Component: engine
2016-10-13 00:28:43 +02:00
2a20bc38c9 pkg/authorization: make it goroutine-safe
It was racy on config reload

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: a616cf3b88ee264b9a565dc0c25e583444ba64e2
Component: engine
2016-10-11 16:31:45 -07:00
d71f1080b9 Make authorization plugins use pluginv2.
Signed-off-by: Anusha Ragunathan <anusha@docker.com>
Upstream-commit: c5393ee147e981ded8fdf12c8da790abd1130175
Component: engine
2016-10-11 13:09:28 -07:00
8544599d78 Call the AuthZRes function also when the daemon returns error
Signed-off-by: Ezra Silvera <ezra@il.ibm.com>
Upstream-commit: 5a8ff4025408ed7a30a829008edf509c02f7a258
Component: engine
2016-10-11 09:53:30 +03:00
1a72f2bb5c Fix AuthZ plugins headers change issue
This fix tries to address the issue raised in 25927 where
the HTTP headers have been chaged when AUthZ plugin is in
place.

This issue is that in `FlushAll` (`pkg/authorization/response.go`),
the headers have been written (with `WriteHeader`) before all the
headers have bee copied.

This fix fixes the issue by placing `WriteHeader` after.

A test has been added to cover the changes.`

This fix fixes 25927

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Upstream-commit: 9cb8fb6ea03fcd78010ce7dd33585d96cd73e38c
Component: engine
2016-08-23 21:08:23 -07:00
565fab494f Enable to dynamically reload authorization plugins via daemon.config
Following #22729, enable to dynamically reload/remove the daemon
authorization plugins (via standard reloading mechanism).
https://docs.docker.com/engine/reference/commandline/daemon/#daemon-
configuration-file

Daemon must store a reference to the authorization middleware to refresh
the plugin on configuration changes.

Signed-off-by: Liron Levin <liron@twistlock.com>
Upstream-commit: 4192fe9c06d150fadfe18f228a6f9c3875227b8a
Component: engine
2016-07-30 14:59:07 +03:00
8e3d8789cb Merge pull request #24963 from allencloud/fix-typos
fix typos
Upstream-commit: 40044cb18fd4ff0ed13d8cdd41ec4dcecdac0703
Component: engine
2016-07-25 09:39:48 +02:00
7ce557c2bc Func name wrong in notes of response.go
Signed-off-by: lixiaobing10051267 <li.xiaobing1@zte.com.cn>
Upstream-commit: d6556a6ef716387122574e37cce4f009b1e21c25
Component: engine
2016-07-23 16:03:27 +08:00
1c3431e16a fix typos
Signed-off-by: allencloud <allen.sun@daocloud.io>
Upstream-commit: 4e959ef2f7f063803d04e06166f459257eb94b5c
Component: engine
2016-07-23 11:32:23 +08:00
7f898cc8b4 Use const http status code instead of just numbers see #24783
Signed-off-by: Doron Podoleanu <doronp@il.ibm.com>
Upstream-commit: 6bec735c91c378e1c9cde1744e7c8aca7397104a
Component: engine
2016-07-19 10:40:20 +03:00
848e510213 plugins: experimental support for new plugin management
This patch introduces a new experimental engine-level plugin management
with a new API and command line. Plugins can be distributed via a Docker
registry, and their lifecycle is managed by the engine.
This makes plugins a first-class construct.

For more background, have a look at issue #20363.

Documentation is in a separate commit. If you want to understand how the
new plugin system works, you can start by reading the documentation.

Note: backwards compatibility with existing plugins is maintained,
albeit they won't benefit from the advantages of the new system.

Signed-off-by: Tibor Vass <tibor@docker.com>
Signed-off-by: Anusha Ragunathan <anusha@docker.com>
Upstream-commit: f37117045c5398fd3dca8016ea8ca0cb47e7312b
Component: engine
2016-06-14 14:20:27 -07:00
abe6b8e4ec Merge pull request #23425 from runcom/authz-race
pkg: authorization: lock when lazy loading
Upstream-commit: 5338ae713347aa8c1139cbcfd8e07746eff52a51
Component: engine
2016-06-13 23:20:37 +02:00
87c4c2885f authz: cleanups
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Upstream-commit: d1b7e8373bde77819a25fce94bdfa9725608215e
Component: engine
2016-06-12 17:23:19 +02:00
a734e84285 pkg: authorization: lock when lazy loading
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Upstream-commit: ceb9c5a88b5fa7d0b6c0901fa6b44ec89e81c2dc
Component: engine
2016-06-12 17:19:43 +02:00
04ae4edf2f Fix logrus formatting
This fix tries to fix logrus formatting by removing `f` from
`logrus.[Error|Warn|Debug|Fatal|Panic|Info]f` when formatting string
is not present.

This fix fixes #23459.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Upstream-commit: a72b45dbec3caeb3237d1af5aedd04adeb083571
Component: engine
2016-06-11 13:16:55 -07:00
35c5774373 fix typos
Signed-off-by: allencloud <allen.sun@daocloud.io>
Upstream-commit: c1be45fa38e82054dcad606d71446a662524f2d5
Component: engine
2016-06-02 17:17:22 +08:00
ec0b8580b4 Fix racy tests in pkg/authorization
Fix #23012

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
Upstream-commit: f437e2d1485bfb64ac0ecc85ac3b14975e9f51f6
Component: engine
2016-06-01 03:25:56 +00:00
2e52fc323e pkg: authorization: cleanup tests
- do use use log pkg
- do not t.Fatal in goroutine
- cleanups

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Upstream-commit: 6a96684442a7e9d6e2d00e9b11d23ea6caa88a2a
Component: engine
2016-05-08 14:18:38 +02:00
fe5c78bee9 fix typos
Signed-off-by: allencloud <allen.sun@daocloud.io>
Upstream-commit: 3f77baf2ce3a607fd1eb8fbe6e9dd9da44a8db49
Component: engine
2016-05-06 18:23:11 +08:00
b33e8d5489 Fix authorization issue - when request is denied return forbbiden exist code (403).
- Return 403 (forbidden) when request is denied in authorization flows
(including integration test)
- Fix #22428
- Close #22431

Signed-off-by: Liron Levin <liron@twistlock.com>
Upstream-commit: 526abc00b138a168fb248c98efd1b90fdf679036
Component: engine
2016-05-02 19:14:48 +03:00
8194e834c4 Move middleware to interfaces.
This makes separating middlewares from the core api easier.
As an example, the authorization middleware is moved to
it's own package.

Initialize all static middlewares when the server is created, reducing
allocations every time a route is wrapper with the middlewares.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 8d3467626ee26cad48ad84f2181552dce7afccb6
Component: engine
2016-04-11 09:19:27 -07:00
7c3f3d665e pkg: cleanup some unused code
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: 07b568cb5342789839aabba0ee6d41e7275099e8
Component: engine
2016-03-31 11:39:59 -07:00
ae0977f1d1 fix variables that werent being called
Signed-off-by: Jessica Frazelle <acidburn@docker.com>
Upstream-commit: 0e025b4bb16c0d4cc6b3f0c040713d061b9b051a
Component: engine
2016-03-17 13:19:55 -07:00
4a285f2027 Call plugins with custom transports.
Small refactor to be able to use custom transports
to call remote plugins.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 1a630234508bdb12d55425ceebdb0b6523a38578
Component: engine
2016-03-02 12:54:53 -05:00
4b3ca35355 Merge pull request #20602 from twistlock/20508_authz_plugin_corrupt_body
Fix #20508 - Authz plugin enabled with large text/JSON POST payload corrupts body
Upstream-commit: abbb16d7abd7150a9226252f2544326930ea2baf
Component: engine
2016-02-29 10:43:02 -05:00
05479dd564 Fix #20508 - Authz plugin enabled with large text/JSON POST payload corrupts body
Based on the discussion, we have changed the following:

1. Send body only if content-type is application/json (based on the
Docker official daemon REST specification, this is the provided for all
APIs that requires authorization.

2. Correctly verify that the msg body is smaller than max cap (this was
the actual bug). Fix includes UT.

3. Minor: Check content length > 0 (it was -1 for load, altough an
attacker can still modify this)

Signed-off-by: Liron Levin <liron@twistlock.com>
Upstream-commit: ca5c2abecfd12ad22b75c69e0debde7b625c2735
Component: engine
2016-02-25 08:11:55 +02:00
f62b97e499 Fix some typos in comments and strings
Most of them were found and fixed by codespell.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Upstream-commit: 2eee613326fb59fd168849618d14a9054a40f9f5
Component: engine
2016-02-22 20:27:15 +01:00
928ef805a9 Windows CI: test-unit turn off pkg\authorisation
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: 57faef5c71b90874f66f1e6b5d2e23591b205e28
Component: engine
2016-02-11 17:42:12 -08:00
3e59ad891c Fix 19575: Docker events doesn't work with authorization plugin
To support the requirement of blocking the request after the daemon
responded the authorization plugin use a `response recorder` that replay
the response after the flow ends.

This commit adds support for commands that hijack the connection and
flushes data via the http.Flusher interface. This resolves the error
with the event endpoint.

Signed-off-by: Liron Levin <liron@twistlock.com>
Upstream-commit: 5ffc810df22c3779b4df8ce28d94e4bf89d34e2f
Component: engine
2016-02-05 22:30:01 +02:00
0411e42a0a Don't dump authz request when body is too large
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 93268d845e41be9cb67744c9bf7a82f8409dff04
Component: engine
2016-01-13 17:04:49 -05:00
51b37769f0 Remove usage of pkg sockets and tlsconfig.
- Use the ones provided by docker/go-connections, they are a drop in replacement.
- Remove pkg/sockets from docker.
- Keep pkg/tlsconfig because libnetwork still needs it and there is a
  circular dependency issue.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 8e034802b7ad92a29f08785e553415adcd1348a3
Component: engine
2015-12-29 19:27:12 -05:00
547bf07eca pkg: authorization: do not register the same plugin
This patches avoids registering (and calling) the same plugin more than
once. Using an helper map which indexes by name guarantees this and keeps
the order.
The behavior of overriding the same name in a flag is consistent with,
for instance, the `docker run -v /test -v /test` flag which register
the volume just once.
Adds integration tests.

Without this patch:
```
Dec 20 19:34:52 localhost.localdomain docker[9988]:
time="2015-12-20T19:34:52.080901676+01:00" level=debug msg="Calling
GET
/v1.22/info"
Dec 20 19:34:52 localhost.localdomain docker[9988]:
time="2015-12-20T19:34:52.081213202+01:00" level=debug msg="AuthZ
request using plugin docker-novolume-plugin"
Dec 20 19:34:52 localhost.localdomain docker[9988]:
time="2015-12-20T19:34:52.081268132+01:00" level=debug
msg="docker-novolume-plugin implements: authz"
Dec 20 19:34:52 localhost.localdomain docker[9988]:
time="2015-12-20T19:34:52.081699788+01:00" level=debug msg="AuthZ
request using plugin docker-novolume-plugin"
Dec 20 19:34:52 localhost.localdomain docker[9988]:
time="2015-12-20T19:34:52.081762507+01:00" level=debug
msg="docker-novolume-plugin implements: authz"
Dec 20 19:34:52 localhost.localdomain docker[9988]:
time="2015-12-20T19:34:52.082092480+01:00" level=debug msg="GET
/v1.22/info"
Dec 20 19:34:52 localhost.localdomain docker[9988]:
time="2015-12-20T19:34:52.628691038+01:00" level=debug msg="AuthZ
response using plugin docker-novolume-plugin"
Dec 20 19:34:52 localhost.localdomain docker[9988]:
time="2015-12-20T19:34:52.629880930+01:00" level=debug msg="AuthZ
response using plugin docker-novolume-plugin"
```

With this patch:
```
Dec 20 19:37:32 localhost.localdomain docker[16620]:
time="2015-12-20T19:37:32.376523958+01:00" level=debug msg="Calling
GET
/v1.22/info"
Dec 20 19:37:32 localhost.localdomain docker[16620]:
time="2015-12-20T19:37:32.376715483+01:00" level=debug msg="AuthZ
request using plugin docker-novolume-plugin"
Dec 20 19:37:32 localhost.localdomain docker[16620]:
time="2015-12-20T19:37:32.376771230+01:00" level=debug
msg="docker-novolume-plugin implements: authz"
Dec 20 19:37:32 localhost.localdomain docker[16620]:
time="2015-12-20T19:37:32.377698897+01:00" level=debug msg="GET
/v1.22/info"
Dec 20 19:37:32 localhost.localdomain docker[16620]:
time="2015-12-20T19:37:32.951016441+01:00" level=debug msg="AuthZ
response using plugin docker-novolume-plugin"
```

Also removes a somehow duplicate debug statement (leaving only the
second one as it's a loop of plugin's manifest):
```
Dec 20 19:52:30 localhost.localdomain docker[25767]:
time="2015-12-20T19:52:30.544090518+01:00" level=debug
msg="docker-novolume-plugin's manifest: &{[authz]}"
Dec 20 19:52:30 localhost.localdomain docker[25767]:
time="2015-12-20T19:52:30.544170677+01:00" level=debug
msg="docker-novolume-plugin implements: authz"
```

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Upstream-commit: c28fc06e002e06deed3437da76bc213b7bd752ba
Component: engine
2015-12-23 21:08:40 +01:00
d63981ab4d authZ: more fixes
- fix naming and formatting
- provide more context when erroring auth
- do not capitalize errors
- fix wrong documentation
- remove ugly remoteError{}

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Upstream-commit: 5a64c8027ecd2bebe773c9abd2e73c2fd7d23de1
Component: engine
2015-12-18 16:29:01 +01:00
98eeaeab93 pkg: authorization: add Err to tweak response status code
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Upstream-commit: 46e3a249a1971f8697ca338c9b02e27d36ddab12
Component: engine
2015-12-17 11:08:47 +01:00
b790e177cc pkg: authorization: cleanup
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Upstream-commit: 8435ea52893ef69c5a264bfbf0a1d3472f377ba2
Component: engine
2015-12-16 12:01:04 +01:00
1c96ff9a0b Fixing documentation according to comments by @moxiegirl and @thaJeztah
Signed-off-by: Dima Stopel <dima@twistlock.com>
Upstream-commit: 8cc0892269fb532f117aadc0e8acf7a173fe4e1b
Component: engine
2015-12-08 17:34:15 +02:00
2491643ccf Docker authorization plug-in infrastructure enables extending the functionality of the Docker daemon with respect to user authorization. The infrastructure enables registering a set of external authorization plug-in. Each plug-in receives information about the user and the request and decides whether to allow or deny the request. Only in case all plug-ins allow accessing the resource the access is granted.
Each plug-in operates as a separate service, and registers with Docker
through general (plug-ins API)
[https://blog.docker.com/2015/06/extending-docker-with-plugins/]. No
Docker daemon recompilation is required in order to add / remove an
authentication plug-in. Each plug-in is notified twice for each
operation: 1) before the operation is performed and, 2) before the
response is returned to the client. The plug-ins can modify the response
that is returned to the client.

The authorization depends on the authorization effort that takes place
in parallel [https://github.com/docker/docker/issues/13697].

This is the official issue of the authorization effort:
https://github.com/docker/docker/issues/14674

(Here)[https://github.com/rhatdan/docker-rbac] you can find an open
document that discusses a default RBAC plug-in for Docker.

Signed-off-by: Liron Levin <liron@twistlock.com>
Added container create flow test and extended the verification for ps
Upstream-commit: 75c353f0ad73bd83ed18e92857dd99a103bb47e3
Component: engine
2015-12-08 17:34:15 +02:00