Closed jshessen closed 2 years ago
@jshessen ,
# Authentication Portal
catacomb.local:18443 {
route {
authenticate with myportal
}
}
Please change the above to:
# Authentication Portal
catacomb.local:18443 {
authenticate with myportal
}
Please delete the following. You are not using these policies. It will make the config smaller.
authorization policy guests_policy {
# disable auth redirect
set auth url https://catacomb.local:18443/
allow roles authp/admin authp/user
crypto key verify {env.JWT_SHARED_KEY}
acl rule {
comment allow guests only
match role guest authp/guest
allow stop log info
}
acl rule {
comment default deny
match any
deny log warn
}
}
authorization policy users_policy {
set auth url https://catacomb.local:18443/
allow roles authp/admin authp/user
crypto key verify {env.JWT_SHARED_KEY}
acl rule {
comment allow users
match role authp/user
allow stop log info
}
acl rule {
comment default deny
match any
deny log warn
}
}
When you browse to catacomb.local:18443
, do you get a login screen?
Updated to remove the "guest" and "user" policies and removed the route in the authentication site as requested.
Yes, I get a redirect to the login, and can invoke both good (redirect loop) and bad (sandbox) login credentials.
I can also interact with the portal after login at this URL
https://catacomb.local:18443/portal
@jshessen , the token you get from auth portal is granted to you via HTTPS.
The links below suggest you are using using HTTP. If that the case the token issued via HTTPS will not be passed to HTTP.
"Prometheus" "http://catacomb.local:9090" icon "las la-fire"
"Alert Manager" "http://catacomb.local:9093" icon "las la-exclamation-circle"
"Grafana" "http://catacomb.local:3000" icon "las la-tachometer-alt"
Option 1: Add the following cookie
directives:
authentication portal myportal {
cookie insecure on
cookie strip domain
...
}
Option 2: (better) Proxy Prometheus, Alert Manager, and Grafana via 18443.
# Authentication Portal
catacomb.local:18443 {
route /auth* {
authenticate with myportal
}
route /prometheus* {
authorize with admins_policy
reverse_proxy prometheus:{$PROMETHEUS_PORT}
}
route /grafana* {
authorize with admins_policy
reverse_proxy prometheus:{$GRAFANA_PORT}
}
route /alertmanager* {
authorize with admins_policy
reverse_proxy alertmanager:{$ALERTMANAGER_PORT}
}
}
If that the case the token issued via HTTPS will not be passed to HTTP.
@jshessen , more on it here:
@greenpau this was a perfect answer! (been banging around for 2 days now)
I implemented Option 1 to get a quick response. I am looking to expand this across my environment (very subdomain heavy) however, I can look to modify the fully caddy sites (reverse proxies) to be HTTPS/TLS to maintain the cookie integrity to the non-TLS backends as I move forward
I had tried setting up TLS on the subsites, but had attempted to reduce the configuration as an act of troubleshooting, I should be able to go back to expanding the config.
Thank you for the prompt response.
@jshessen , more specifically on Prom and Alert Manager:
route /prometheus* {
authorize with admins_policy
uri strip_prefix /prometheus
reverse_proxy http://127.0.0.1:9080
}
route /alertmanager* {
authorize with admins_policy
uri strip_prefix /alertmanager
reverse_proxy http://127.0.0.1:9083
}
The config file for Prometheus should containweb.external-url
:
cat << EOF > ${MYAPP_CONF}
OPTIONS="--log.level=debug \
--config.file=/etc/prometheus/config/prometheus.yml \
--storage.tsdb.path=/opt/data/prometheus \
--web.console.templates=/var/lib/prometheus/consoles \
--web.console.libraries=/var/lib/prometheus/console_libraries \
--web.external-url https://${HOSTNAME}/prometheus"
EOF
Same for AlertManager:
cat << EOF > ${MYAPP_CONF}
OPTIONS="--log.level=debug \
--config.file=/etc/alertmanager/config/alertmanager.yml \
--storage.path=/opt/data/alertmanager \
--data.retention=1440h \
--web.external-url https://${HOSTNAME}/alertmanager \
--web.route-prefix=/"
EOF
@jshessen , if you want, please connect with me on LinkedIn and I will help you with your setup. We could do Google Meet or Zoom.
@greenpau, thank you again ... I will try to find a window here in the next few weeks to reach out.
this was a perfect answer! (been banging around for 2 days now)
@jshessen , next time open an issue after 15 minutes!
@greenpau gave me a chance to really dig through all the different combinations of templates and documents!
@jshessen , actually, prom/alertmanager/grafana was my first use case for this plugin 😄
@jshessen , you might also be interested in https://github.com/greenpau/caddy-security/issues/105#issuecomment-1129961604
Basically, when you proxy traffic to Grafana, you could set auth level via X-Auth-Level
.
Also, see X-WEBAUTH-USER
docs:
https://grafana.com/docs/grafana/next/setup-grafana/configure-security/configure-authentication/auth-proxy/#interacting-with-grafanas-authproxy-via-curl
@jshessen , I am looking to add testimonial sections to https://authcrunch.com. Could you please write one and send it to me at greenpau@outlook.com?
Describe the issue Appear to be in a redirect loop where the access_token is not being found
Configuration
Paste full
Caddyfile
below:Version Information
Provide output of
caddy list-modules -versions | grep git
below:Expected behavior
Describe expected behavior. Expect that after initial token failure, the authentication portal will prompt, and then redirect to original requested URL
Additional context
Add any other context about the problem here.