Skip to content

Override the httpauth Unauthorized Error #427

Answered by robjtede
EvilWatermelon asked this question in Q&A
Discussion options

You must be logged in to vote

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:

  • use HttpAuthentication::with_fn(validator)
  • have a validator signature that uses credentials: Option<BearerAuth> instead of credentials: BearerAuth.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by robjtede
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