New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using HttpAuthentication wrapper on the same named scope but different handler #37
Comments
Thanks, I appreciate it! In general, the question more about how routes & scopes works in App::new()
.service(
web::scope("/api/v1")
.service(
web::scope("/reservations")
.wrap(HttpAuthentication::bearer(validator))
.configure(reservations_controllers::secured_routes),
)
.service(web::scope("/auth").configure(auth_controller::routes))
)
.app_data(data.clone()) But I'm not sure if it suits you |
Thank you for the quick response. |
Hello @DDtKey , I run into the same issue. The trick with different scops works, but not in all situations. Is there a way to use Role based authentication and map all requests without a authorization header to role Guest and then using |
Just to clarify this, do you want I mean you can assign the Guest during checking header(in method that you pass to middleware), like: if auth_header.is_none() {
return Role::Guest
} |
Not exactly, it depends what is the most easiest way. It was only one idea I had, to give all non authenticated users the role guest. But I thought that maybe actix-web-grants has a way to handle this situations.
But that means I have to write my one middleware? I tried to implement something like that in the |
@jb-alvarado oh, I see your point. But it worth to create separate issue, I'm pretty sure that's not related one |
Ok, sorry, I will create one. |
Thank you for the amazing package!
This is more of a question than an issue.
I've been following the jwt-httpauth example:
The unguarded
create_token
handler is outside the/api
scope.The problem arises when you want to nest the unguarded route inside
/api
:Here, the first route works, but the second one returns 401.
Adding regexp
{regex:$|/.*?}
on the second scope doesn't work either.Is there a way to achieve this? (Other than wrapping the handlers individually)
The text was updated successfully, but these errors were encountered: