Skip to content

Commit eca82a6

Browse files
authored
Allow set basicauth realm value (#1173)
* Allow set basicauth realm value * fix ci
1 parent 752f7d8 commit eca82a6

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

crates/extra/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ sse = ["dep:futures-util", "dep:pin-project", "tokio", "dep:serde", "dep:serde_j
3131
trailing-slash = ["dep:tracing"]
3232
timeout = ["tokio/macros"]
3333
websocket = ["dep:futures-util", "dep:hyper", "tokio", "tokio-tungstenite", "dep:tracing"]
34-
request-id = ["dep:ulid"]
34+
request-id = ["dep:ulid", "dep:tracing"]
3535
tower-compat = ["dep:futures-util", "dep:http-body-util", "dep:tower", "dep:tracing"]
3636

3737
[dependencies]

crates/extra/src/basic_auth.rs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,32 +96,47 @@ where
9696
}
9797
}
9898

99-
#[doc(hidden)]
99+
/// Set the realm for the Basic Authentication.
100+
#[inline]
101+
#[must_use]
102+
pub fn set_realm(mut self, realm: impl Into<String>) -> Self {
103+
self.realm = realm.into();
104+
self
105+
}
106+
107+
/// Get the realm of the Basic Authentication.
108+
#[inline]
109+
pub fn realm(&self) -> &str {
110+
&self.realm
111+
}
112+
113+
/// Set the header names for the Basic Authentication.
100114
#[inline]
101115
#[must_use]
102116
pub fn set_header_names(mut self, header_names: impl Into<Vec<HeaderName>>) -> Self {
103117
self.header_names = header_names.into();
104118
self
105119
}
106-
#[doc(hidden)]
120+
121+
/// Get the header names of the Basic Authentication.
107122
#[inline]
108123
pub fn header_names(&self) -> &Vec<HeaderName> {
109124
&self.header_names
110125
}
111126

112-
#[doc(hidden)]
127+
/// Get mutable reference to the header names.
113128
#[inline]
114129
pub fn header_names_mut(&mut self) -> &mut Vec<HeaderName> {
115130
&mut self.header_names
116131
}
117132

118-
#[doc(hidden)]
133+
/// Ask for credentials by setting the `WWW-Authenticate` header.
119134
#[inline]
120135
pub fn ask_credentials(&self, res: &mut Response) {
121136
ask_credentials(res, &self.realm)
122137
}
123138

124-
#[doc(hidden)]
139+
/// Parse credentials from the request.
125140
#[inline]
126141
pub fn parse_credentials(&self, req: &Request) -> Result<(String, String), Error> {
127142
parse_credentials(req, &self.header_names)

0 commit comments

Comments
 (0)