pub struct Credential {
pub username: String,
pub password: String,
pub realm: Option<String>,
pub auth_username: Option<String>,
}Expand description
SIP Authentication Credentials
Credential contains the authentication information needed for SIP
digest authentication. This is used when a SIP server challenges
a request with a 401 Unauthorized or 407 Proxy Authentication Required
response.
§Fields
username- The username for authenticationpassword- The password for authenticationrealm- Optional authentication realm (extracted from challenge)
§Examples
§Basic Usage
let credential = Credential {
username: "alice".to_string(),
password: "secret123".to_string(),
realm: Some("example.com".to_string()),
auth_username: None,
};§Usage with Registration
let credential = Credential {
username: "alice".to_string(),
password: "secret123".to_string(),
realm: None, // Will be extracted from server challenge
auth_username: None,
};
// Use credential with registration
// let registration = Registration::new(endpoint.inner.clone(), Some(credential));§Usage with INVITE
let invite_option = InviteOption {
caller: rsipstack::sip::Uri::try_from("sip:alice@example.com")?,
callee: rsipstack::sip::Uri::try_from("sip:bob@example.com")?,
content_type: Some("application/sdp".to_string()),
offer: Some(sdp_bytes),
contact: rsipstack::sip::Uri::try_from("sip:alice@192.168.1.100:5060")?,
credential: Some(credential),
..Default::default()
};Fields§
§username: StringThe user part of the AOR (From/To/Contact of REGISTER, local contact
of dialogs). Also the digest username unless auth_username is set.
password: String§realm: Option<String>§auth_username: Option<String>Digest authentication username, when it differs from username.
Some PBXs (3CX, Asterisk auth objects, …) hand out an
“Authentication ID” that is distinct from the extension: the AOR is
sip:01@pbx but the username= in the Authorization /
Proxy-Authorization header (and the digest) must be that ID.
None (or an empty string) keeps the classic behavior of
authenticating as username.
Implementations§
Source§impl Credential
impl Credential
Sourcepub fn digest_username(&self) -> &str
pub fn digest_username(&self) -> &str
The name used for digest authentication: auth_username when set
and non-empty, otherwise username.
Trait Implementations§
Source§impl Clone for Credential
impl Clone for Credential
Auto Trait Implementations§
impl Forget for Credential
impl Freeze for Credential
impl Move for Credential
impl RefUnwindSafe for Credential
impl Send for Credential
impl Sync for Credential
impl Unpin for Credential
impl UnsafeUnpin for Credential
impl UnwindSafe for Credential
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more