AAP and Phoenix.LiveDashboard

If I put live_dashboard inside my ash_authentication_live_session :admin_required router block, I get a compilation error about nested live sessions.
** (RuntimeError) attempting to define live_session :live_dashboard inside :admin_required.
live_session definitions cannot be nested.
** (RuntimeError) attempting to define live_session :live_dashboard inside :admin_required.
live_session definitions cannot be nested.
LiveDashboard does not appear to provide an interface to let you manage the live session yourself, so I am not sure how to do this.
9 Replies
ZachDaniel
ZachDaniel4mo ago
DOes live dashboard let you customize their live session in any way via options? There is a function in AAP to get the opts that should be passed to live_session we set it up for beacon, might work there too
ZachDaniel
ZachDaniel4mo ago
On_mount might be all you need
aidalgol
aidalgolOP4mo ago
That seems to work until Phoenix.LiveDashboard.PageLive mounts.
aidalgol
aidalgolOP4mo ago
At a glance, I don't see anything obviously clearing assigns in the code for PageLive. https://github.com/phoenixframework/phoenix_live_dashboard/blob/v0.8.7/lib/phoenix/live_dashboard/page_live.ex
ZachDaniel
ZachDaniel4mo ago
Hmm...actually I think you might need the session opt? I'm not sure. What are you trying to do specifically? May need to ask Phoenix folks how they authorize access to live dashboard in the way you're trying to do it
aidalgol
aidalgolOP4mo ago
I think what's happening is that AshAuthentication.Phoenix.LiveSession.on_mount is being called with a first argument other than :default, so it's not setting the current_user assign. I'm trying to make the phoenix dashboard accessible only to admin users, for use in production. It appears they expect auth to be done by plugs: https://hexdocs.pm/phoenix_live_dashboard/Phoenix.LiveDashboard.html#module-extra-add-dashboard-access-on-all-environments-including-production
ZachDaniel
ZachDaniel4mo ago
that makes sense, we have the plug to fetch the user from the session so you can just write a plug that kicks users out

Did you find this page helpful?