actix-extras icon indicating copy to clipboard operation
actix-extras copied to clipboard

`impl Challenge for &'static str`

Open mcronce opened this issue 3 years ago • 2 comments

PR Type

Feature

PR Checklist

  • [x] Tests for the changes have been added / updated.
  • [x] Documentation comments have been added / updated.
  • [x] A changelog entry has been made for the appropriate packages.
  • [x] Format code with the nightly rustfmt (cargo +nightly fmt).

Overview

As it stands, using actix-web-httpauth::middleware::HttpAuthentication requires creating a type that impls Challenge in order to return an AuthenticationError. This makes it possible to simply (e.g.) return Err(AuthenticationError::new("Authentication required").into()) from your auth check function.

mcronce avatar May 24 '22 04:05 mcronce

I don't know how useful the test really is, but it allowed me to check the box ;)

mcronce avatar May 24 '22 04:05 mcronce

(~~The CI failure seems unrelated to this PR~~ it's related but we don't have to run tests on MSRV, I'm going to take a look at the config later today™)

JohnTitor avatar May 24 '22 21:05 JohnTitor