Restricting routes to local Grafana public dashboard

Am trying to sort through the Applications/Policies/Tokens needed to set it up so I can share a Grafana dashboard in a Pi (via a Tunnel/route) without sharing all of Grafana. Feels like I'm missing something obvious; normally I'd think I could just block based on URL, but that doesn't seem to be an option. Anyone have experience with this?
43 Replies
Chaika
Chaika4d ago
The most specific application applies, which is the trick to use here. Make one self-hosted app on grafana.example.com/*, w/ an Allow rule just for you, and then another self-hosted app like this:
No description
Chaika
Chaika4d ago
then on the public self-hosted app, just need one Bypass action policy allowing Everyone. Just make sure not to select Protect with Access on the tunnel public hostname, won't work w/ bypass
gristleking
gristlekingOP4d ago
Hmm, will go back and try that. Thank you!
I ended up with a route to grafana.example.com/d/* and then set a service auth requirement for /login and that seems to have worked, but it’s inelegant. Was trying a route to /public-dashboards/* but Grafana kept throwing errors.
Chaika
Chaika4d ago
If you're using /d/ it sounds like you're trying to share the dashboard without using the public dashboards feature
Chaika
Chaika4d ago
in the grafana dashboard, top right, under Share -> Public Dashboard is how you can enable publicily viewable dashboards and get /public-dashboard/ links https://grafana.com/docs/grafana/latest/dashboards/dashboard-public/
Grafana Labs
Public dashboards | Grafana documentation
Make your Grafana dashboards public and share them with anyone
gristleking
gristlekingOP4d ago
I was having problems with using /public-dashboards. When I put that in and tried to set an allow policy for it I’d get a broken link. Definitely operator error. I’ll try your first suggestion when I get back to my desk. Thanks again!
Chaika
Chaika4d ago
The allow policy should be on the base wildcard
self-hosted app on grafana.example.com/*, w/ an Allow rule just for you,
then you have a more precise self-hosted app w/ a bypass action allowing everyone, matching public* public-dashboards* and api/public*
gristleking
gristlekingOP4d ago
Ah, because those dirs are what Grafana needs access to? (/public, /public-dashboards, and /api/public?
Chaika
Chaika3d ago
for public dashboards yea
gristleking
gristlekingOP3d ago
Hmm, I'm not getting something. Ok, 2 Applications. First:
grafana.domain.com/*
with Policy:
Allow - Email [email protected]
grafana.domain.com/*
with Policy:
Allow - Email [email protected]
Second
grafana.domain.com/public*
grafana.domain.com/public-dashboards*
grafana.domain.com/api/public*
with Policy:
Include Everyone
grafana.domain.com/public*
grafana.domain.com/public-dashboards*
grafana.domain.com/api/public*
with Policy:
Include Everyone
If I set that up, when I go to the public dashboard link I get "Get a login code emailed to you" If I enter that code, I get to see the dashboard, but I also see a "Failed to Fetch" message and there's the friction of mucking about with an email code. Whereas if I just set up a route to grafana.domain.com/d/* and then one Application for grafana.domain.com/login and use an Allow Policy tied to any Service Auth Token, I can share either the Public Dashboard link or the /d link, but people can't access anything else in Grafana. *** Sorry, I think I solved it inelegantly about 24 hours after asking the question. 🙂
Chaika
Chaika3d ago
The action on the second one should be Bypass, shouldn't get any login at all if it's setup right. Just protecting /login should prevent any login attempts since they just POST to /login but wouldn't protect Grafana's full api and such, eh, still exposing it to a degree anyway with public dashboards, just means you're trusting exposing their non-public api a bit more
gristleking
gristlekingOP3d ago
Ok, tried it again with Bypass (which I'd missed before) and that worked well, thanks! I think the other key aspect for me was setting the Route to go to grafana.domain.com/d*, so there's no way to get to grafana.domain.com Am I missing something important there?
Chaika
Chaika3d ago
hmm, what do you mean by setting the route to that? Essentially what you're doing is: Bypass: /public*, /public-dashboards*, /api/public* Redirect to auth, Allow: grafana.domain.com/* /d*, wouldn't match any of the bypass ones, so it'd match the less specific general wildcard which requires auth
gristleking
gristlekingOP3d ago
Let me double check, maybe I did something wrong. When I set the Route to grafana.domain.com/* before I'm pretty sure anyone could just go there and see the Grafana basic (pre-login) page.
Chaika
Chaika3d ago
hmmm, I'd make sure you're testing that from incognito mode/another browser too, you might be already logged in
gristleking
gristlekingOP3d ago
http://grafana.gristleking.dev/public-dashboards/de67142e871c4d2da807ee1086979b20 Word. Been testing in Incognito. I can't get the set up you've recommended to work the way I want it to. It's got to be operator error on my side, but I'm not sure what it is I'm doing wrong. So you should be able to see the dashboard but not access grafana.gristleking.dev or anything other than that public dash link OR you could paste in the de6... after gristleking.dev/d/ and you'll see an error page in Grafana but as far as I can tell you can't do anything with it. It's currently set up with the Route pointing to grafana.domain.com/d* and then just one rule set to allow access to grafana.domain.com/login to a Service Auth token. That appears to be working, but I think you'd said that exposes more than I should?
Chaika
Chaika3d ago
hmm, the way you word that is interesting, what do you mean "Route"? None of the access app's terminology is route
gristleking
gristlekingOP3d ago
I'm pretty new to this, so may be using the wrong term then. I mean the public hostname in the Tunnel; I thought that was a "Route".
Chaika
Chaika3d ago
hmm, those are public hostnames. You'd just have something a wildcard for the specific subdomain, like this for example
No description
gristleking
gristlekingOP3d ago
Ok, I was using the wrong term then.
gristleking
gristlekingOP3d ago
No description
gristleking
gristlekingOP3d ago
That's what I have set up.
Chaika
Chaika3d ago
hmm, you have another public hostname (what you call Routes) on that tunnel for this subdomain?
gristleking
gristlekingOP3d ago
Yes, for Node-RED.
Chaika
Chaika3d ago
that's different subdomain though, right?
gristleking
gristlekingOP3d ago
Yes.
Chaika
Chaika3d ago
Remove the path on that public hostname (route), it's not doing anything other then making some things fail, should just show as (optional) path once you remove it fully
gristleking
gristlekingOP3d ago
Kk.
No description
Chaika
Chaika3d ago
what are the access apps you have currently? just one for /login?
gristleking
gristlekingOP3d ago
Yep. 2 for the Node-RED part, but just the one for Grafana.
No description
gristleking
gristlekingOP3d ago
and that Grafana one just uses a Service Auth.
Chaika
Chaika3d ago
and so if you took the current one, and modified it to be * for path, and then made another self hosted app w/ https://discord.com/channels/595317990191398933/1330066393764331580/1330291419751125063 and a single Bypass Everyone policy, and give it a second to propagate
gristleking
gristlekingOP3d ago
Ah, I was testing immediately, which seemed to work for everything. Maybe I just need to wait an extra few seconds?
No description
Chaika
Chaika3d ago
yea it can take a bit, maybe ~60s or so? Plus I believe there's some browser caching on the access redirects
gristleking
gristlekingOP3d ago
Ha! Working now! I was just too impatient before. Thank you!
Chaika
Chaika3d ago
Access is powered by Workers KV, so some understandable propagation/cache delay
gristleking
gristlekingOP3d ago
Got it. Ok, this is awesome, thanks again! (part of a tutorial I'm writing, so this helps lots of other people get this right the first time). 🙂
Chaika
Chaika3d ago
The action types are the most confusing aspect to people I think Allow = Always go through Identity Provider. Even if you set it to include: Everyone, they still need to go through something providing them an identity to proceed Bypass = Bypass all Zero Trust stuff, go back to zone/website level security (waf, etc) Service Auth = Go through Zero Trust w/ no identity If you enable "Protect with Access" on the tunnel, only Allow and Service Auth provide the JWT/magic stuff for it to work. If you enable "Protect with Access" and have a bypass rule, they'll just be blocked by the tunnel
gristleking
gristlekingOP3d ago
Yeah, it definitely confused me!
gristleking
gristlekingOP3d ago
Ok to put ya in there?
No description
Chaika
Chaika3d ago
Sure
gristleking
gristlekingOP3d ago
https://www.meteoscientific.com/docs/tutorial-extras/metsci-demo-dash Thanks again! Not totally relevant to this, but doesn't Service Auth require that you have an identity in the form of a Service Auth token?
Chaika
Chaika3d ago
I more meant no identity provider login, but you can have Service Auth rule including Everyone

Did you find this page helpful?