-
Hi, I wanted to use live_admin behind authentication. I've configured it and run scope "/", WowWeb do
pipe_through [:browser, :require_authenticated_admin]
live_session :require_authenticated_admin,
on_mount: [{WowWeb.AdminAuth, :ensure_authenticated}] do
live "/admins/settings", AdminSettingsLive, :edit
live "/admins/settings/confirm_email/:token", AdminSettingsLive, :confirm_email
end
live_admin "/admin", title: "Wow Project" do
admin_resource "/users", Wow.Admin.User
end
end Two questions:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Question 1: LiveAdmin does not currently support any specific auth strategy but since it is just a group of routes it theoretically supports anything you can do in a router pipeline. The easiest way to quickly protect a route is to add basic auth plug, which would look something like this:
I am unfortunately not familiar with phx.gen.auth having never used it myself, but from your sample code it appears to rely on the Question 2: Yes, LiveAdmin uses its own layout currently which is a think wrapper around the components. By overriding the relevant component, you could theoretically add a "logout" link anywhere, most likely to the nav component, which implements the sidebar. Not sure how to implement that with basic auth off the top of my head, as I've never attempted that. |
Beta Was this translation helpful? Give feedback.
-
Copy the nav component source file (linked above) into your own project (and rename it), make any changes you want, and then pass it as an option like this (using Line 254 in bd82703 |
Beta Was this translation helpful? Give feedback.
Question 1:
LiveAdmin does not currently support any specific auth strategy but since it is just a group of routes it theoretically supports anything you can do in a router pipeline. The easiest way to quickly protect a route is to add basic auth plug, which would look something like this: