Override the httpauth Unauthorized Error #427
Answered
by
robjtede
EvilWatermelon
asked this question in
Q&A
-
If I access my actix web API without a Bearer token then I want to override the I'm getting
But I want to create my own error message impl HttpError {
pub fn new(
cause: Option<String>,
message: Option<String>,
status_code: String,
error_type: ErrorResponse
) -> Self {
Self {
cause,
message,
status_code,
error_type
}
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
robjtede
Jun 11, 2024
Replies: 1 comment
-
I updated one of the examples to show how optional auth works: The main points are:
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
robjtede
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I updated one of the examples to show how optional auth works:
https://github.com/actix/actix-extras/blob/master/actix-web-httpauth/examples/middleware.rs
The main points are:
HttpAuthentication::with_fn(validator)
credentials: Option<BearerAuth>
instead ofcredentials: BearerAuth
.