What is the correct way to define additional protected routes? #154
-
Hi, Firstly, thanks for this crate! I have used the Sqlite example to get going. I have been looking for details on how to add in additional pages beyond the example I was looking to add a
I also added a
I figure I'm on the right path, but everything I've tried hasn't worked. I changed the order of the dashboard::router() thinking that perhaps that might have an effect on the result, but it didn't. Any suggestions on how to add in multiple protected routes? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Generally speaking, you'll want to install the auth layer at the lowest point in your route graph (at least for routes you plan to protect). So for example, you might prefer something like this: let app = protected::router()
.merge(dashboard::router())
.route_layer(login_required!(Backend, login_url = "/login"))
.merge(auth::router())
.layer(auth_service); Everything above the |
Beta Was this translation helpful? Give feedback.
Generally speaking, you'll want to install the auth layer at the lowest point in your route graph (at least for routes you plan to protect).
So for example, you might prefer something like this:
Everything above the
login_required
macro is going to be protected.