gateway: dial swarm services by name over verified TLS
Consumers reached authelia at `127.0.0.1:<port>`, which encoded a
co-location nobody agreed to: the gateway and authelia are not required
to share a host, so the literal is a requirement stated only by being
unwriteable any other way. Moving them to the name is the point of the
issue.
But a name over https is only half of "https and auth". nginx's
`proxy_ssl_verify` is OFF by default and there was no `proxy_ssl_*`
anywhere in the tree, so the obvious repoint would have produced an
encrypted, unauthenticated hop -- which works, and keeps working,
against any certificate at all.
Adds `gateway.lib.verifiedProxyTo <name>` next to the rest of the vhost
kit, so the convention has one definition rather than a copy in each
consuming module, and repoints the four call sites through it.
Each directive was checked against a real nginx with the opposite arm
run as a control:
- the CA *bundle* (root + intermediate) is accepted -- worth checking,
since `hive-ca-trust.nix` warns off consumers that read only one
certificate, and nginx is not one of those
- verification checks the chain: an unrelated CA fails
- and the HOSTNAME: a wrong `proxy_ssl_name` fails even with a good
chain. Chain-only would accept any cert this CA ever signed, which
for an internal CA is every service on the hive
- with verify off, the wrong CA passes -- so the failures above come
from verification, not from the connection
Bind addresses are untouched. This changes what consumers dial, not what
anything listens on.
This commit is contained in:
parent
5a5a4ddd15
commit
43ae164d8b
6 changed files with 78 additions and 5 deletions
|
|
@ -272,8 +272,11 @@ in
|
|||
# `/__hive_authelia` below, just not `internal` since the
|
||||
# frontend calls this one directly.
|
||||
"= /api/whoami" = {
|
||||
proxyPass = "http://127.0.0.1:${toString autheliaCfg.port}/api/user/info";
|
||||
extraConfig = swarmAuthRequest;
|
||||
proxyPass = "https://${autheliaCfg.domain}/api/user/info";
|
||||
extraConfig = ''
|
||||
${swarmAuthRequest}
|
||||
${gatewayCfg.lib.verifiedProxyTo autheliaCfg.domain}
|
||||
'';
|
||||
};
|
||||
"/api/docs/" = {
|
||||
alias = "${gatewayCfg.swaggerUiTheme}/";
|
||||
|
|
@ -292,9 +295,10 @@ in
|
|||
# `X-Forwarded-Uri` does not appear in it at all, so sending it
|
||||
# would look like configuration and be dead weight.
|
||||
"= /__hive_authelia" = {
|
||||
proxyPass = "http://127.0.0.1:${toString autheliaCfg.port}/api/authz/auth-request";
|
||||
proxyPass = "https://${autheliaCfg.domain}/api/authz/auth-request";
|
||||
extraConfig = ''
|
||||
internal;
|
||||
${gatewayCfg.lib.verifiedProxyTo autheliaCfg.domain}
|
||||
# A subrequest carries no body, and forwarding one here makes
|
||||
# authelia read a payload it will never use.
|
||||
proxy_pass_request_body off;
|
||||
|
|
|
|||
Loading…
Reference in a new issue