There is some vague chance that there is one person in this community which is as paranoid as I am. With that poor single individual in mind I though I will post a small workaround I did, to help me sleep a little bit better at night ;)
The "problem"I wanted to expose the Automic REST API to a wider unrestricted network range ( part of company network, or maybe even the Internet :goosebumps: )
The problem underneath the problemAutomic does not let me filter in any way which user is allowed what. Not to even mention creating dedicated disposable tokens with a defined usage scope. So once I let the network traffic in from external sources (not directly the AWI ) it means everyone can join the party to the extent their Automic permissions let them.
I do not like it.
The workaroundAs we are talking about HTTP(s) requests I went with the path of least resistance and used nginx as a proxy exposing my REST API backend. This allows me at least some minimal degree of control who is allowed what.
Here a sample configuration giving me a few benefits:
- access only to users whose name starts with API,
- limit access on a client basis
- control which methods can be used
server {
listen 80;
# restrict methods to valid ones
if ($request_method !~ ^(GET|POST|PUT|DELETE)$) {
return '405';
}
# restrict users
if ($remote_user !~ ^API.*) {
return '403';
}
set $baseurl "https://your_ae_hostname:8088";
resolver 1.1.1.1;
# Proxy for ping
location /ae/api/v1/ping {
proxy_pass $baseurl/ae/api/v1/ping;
# Proxy timeouts
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
}
# Allow only selected clients
location ~ /ae/api/v1/(0|100|200)/ {
proxy_pass $baseurl;
# Proxy timeouts
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
}
}
}
Based on that approach some fine grain control is possible restricting certain users to certain methods, endpoints etc. The proxy is running plain http as this is just a container which gets https termination a little bit before, but it could of course serve HTTPS right away.
It may turn out a rhetorical question, but did any of you struggle with similar problem?
How do you control who can do what using REST? :)
------------------------------
Cheers,
Marcin
------------------------------