Skip to content

What is the correct way to define additional protected routes? #154

Answered by maxcountryman
justmark asked this question in Q&A
Discussion options

You must be logged in to vote

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 login_required macro is going to be protected.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@justmark
Comment options

Answer selected by justmark
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants