Skip to content

Add /containers, /networks and /volumes POST & DELETE endpoints - #20

Closed
folex wants to merge 9 commits into
Tecnativa:masterfrom
fluencelabs:master
Closed

folex wants to merge 9 commits into
Tecnativa:masterfrom
fluencelabs:master

Conversation

@folex

@folex folex commented Sep 19, 2019 •

Copy link
Copy Markdown

This PR adds variables to control /containers, /networks and /volumes POST & DELETE endpoints granularly.

If formatting variables in a table is a bad idea, or I need to update README further – please let me know!

Also, maybe I should mark security sensitive endpoints in a more explicit fashion? Not sure if current POST is security-critical is enough.

@folex folex changed the title Add /containers, /networks and /volumes POST endpoints Add /containers, /networks and /volumes POST & DELETE endpoints Sep 20, 2019
@dphildebrandt

Copy link
Copy Markdown

This would be great. I'd definitely like to enable more granularity in Portainer, and unfortunately right now you must grant blanket POST, even if you want some minor functionality like stop/kill/restart!

Comment thread haproxy.cfg Outdated
Comment on lines +31 to +37
# errorfile 400 /usr/local/etc/haproxy/errors/400.http
# errorfile 403 /usr/local/etc/haproxy/errors/403.http
# errorfile 408 /usr/local/etc/haproxy/errors/408.http
# errorfile 500 /usr/local/etc/haproxy/errors/500.http
# errorfile 502 /usr/local/etc/haproxy/errors/502.http
# errorfile 503 /usr/local/etc/haproxy/errors/503.http
# errorfile 504 /usr/local/etc/haproxy/errors/504.http

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change? 🤔

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, maybe by accident. I'll revert this :)

Comment thread haproxy.cfg
bind :2375
http-request deny unless METH_GET || { env(POST) -m bool }
http-request allow if { path,url_dec -m reg -i ^(/v[\d\.]+)?/containers/[a-zA-Z0-9_.-]+/((stop)|(restart)|(kill)) } { env(ALLOW_RESTARTS) -m bool }
http-request deny unless METH_GET || METH_POST { env(POST) -m bool } || METH_DELETE { env(DELETE) -m bool }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the DELETE env variable in the README or the Dockerfile.

Also if POST=0 DELETE=0, this will be denied now and won't continue evaluating any more rules, right? Then all new rules should exist before this one.

Comment thread haproxy.cfg
http-request allow if { path,url_dec -m reg -i ^(/v[\d\.]+)?/version } { env(VERSION) -m bool }
http-request allow if { path,url_dec -m reg -i ^(/v[\d\.]+)?/volumes } { env(VOLUMES) -m bool }
# POST requests
http-request allow if { path,url_dec -m reg -i ^(/v[\d\.]+)?/containers/create } { env(CONTAINERS_CREATE) -m bool }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably need this in all these rules:

Suggested change
http-request allow if { path,url_dec -m reg -i ^(/v[\d\.]+)?/containers/create } { env(CONTAINERS_CREATE) -m bool }
http-request allow if METH_POST { path,url_dec -m reg -i ^(/v[\d\.]+)?/containers/create } { env(CONTAINERS_CREATE) -m bool }

Also, you should modify the README explaining that the POST variable is global, while the other ones in the table are specific and can still allow POST requests when POST=0

@folex

folex commented Aug 14, 2020

Copy link
Copy Markdown
Author

Hi!

Sorry for my silence. This is a pretty old PR, so I'm out of the context now, let me check if I can address your comments :)

@folex

folex commented Aug 14, 2020 •

Copy link
Copy Markdown
Author

So I have pushed some trivial fixes, but it's not enough to address your comments. Right now I don't recall how to config haproxy, so while all your feedback is right to the point, it seems that I couldn't address it.

Is it possible to convert this PR to a feature request, maybe?

@yajo

yajo commented Aug 14, 2020

Copy link
Copy Markdown
Contributor

Yes, of course. Closing, then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants