-
Notifications
You must be signed in to change notification settings - Fork 206
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
impl Challenge for &'static str
#248
base: master
Are you sure you want to change the base?
Conversation
…l Challenge for &str
I don't know how useful the test really is, but it allowed me to check the box ;) |
actix-web-httpauth/CHANGES.md
Outdated
@@ -1,6 +1,7 @@ | |||
# Changes | |||
|
|||
## Unreleased - 2021-xx-xx | |||
- impl Challenge for &str |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- impl Challenge for &str | |
- impl `Challenge` for `&str` |
use super::*; | ||
|
||
#[proptest] | ||
fn roundtrip_static_str(input: Box<str>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if that conversion really needs to use such expensive testing, isn't it enough to add a basic test? We should be cautious to add an additional test framework just for one test.
#[proptest] | ||
fn roundtrip_static_str(input: Box<str>) { | ||
// This will leak, but it's probably fine in the context of a test. Fixable by adding: | ||
// unsafe { Box::from_raw(s as *const str as *mut str); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unleaking is UB, especially through a shared reference. This should use Box::into_raw
and Box::from_raw
if memory is to be cleaned up.
( |
impl Challenge for &'static str
PR Type
Feature
PR Checklist
cargo +nightly fmt
).Overview
As it stands, using
actix-web-httpauth::middleware::HttpAuthentication
requires creating a type that implsChallenge
in order to return anAuthenticationError
. This makes it possible to simply (e.g.)return Err(AuthenticationError::new("Authentication required").into())
from your auth check function.