pub struct AzureAdAuth { /* private fields */ }Expand description
Azure AD authentication provider.
This provider supports Azure AD / Entra ID federated authentication
using pre-acquired access tokens (Tier 1) or token acquisition
with the azure-identity feature (Tier 2).
§Example
use mssql_auth::AzureAdAuth;
// Using a pre-acquired token
let auth = AzureAdAuth::with_token("eyJ0eXAi...");Implementations§
Source§impl AzureAdAuth
impl AzureAdAuth
Sourcepub fn with_token(token: impl Into<Cow<'static, str>>) -> Self
pub fn with_token(token: impl Into<Cow<'static, str>>) -> Self
Create an Azure AD authenticator with a pre-acquired token.
This is the simplest form - provide a valid access token obtained from Azure AD / Entra ID via your preferred method.
§Arguments
token- A valid JWT access token for Azure SQL Database
Sourcepub fn with_token_expiring(
token: impl Into<Cow<'static, str>>,
expires_in: Duration,
) -> Self
pub fn with_token_expiring( token: impl Into<Cow<'static, str>>, expires_in: Duration, ) -> Self
Create an Azure AD authenticator with a token and expiration.
Providing the expiration time allows the driver to proactively refresh tokens before they expire.
§Arguments
token- A valid JWT access tokenexpires_in- Duration until the token expires
Sourcepub fn from_credentials(credentials: &Credentials) -> Result<Self, AuthError>
pub fn from_credentials(credentials: &Credentials) -> Result<Self, AuthError>
Create from existing credentials.
Returns an error if the credentials are not Azure AD credentials.
Sourcepub fn with_library(self, library: FedAuthLibrary) -> Self
pub fn with_library(self, library: FedAuthLibrary) -> Self
Set the library type to report to the server.
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if the token is expired.
Sourcepub fn is_expiring_soon(&self, within: Duration) -> bool
pub fn is_expiring_soon(&self, within: Duration) -> bool
Check if the token is expiring soon (within the given duration).
Sourcepub fn build_feature_data(&self) -> Bytes
pub fn build_feature_data(&self) -> Bytes
Build the FEDAUTH feature extension data for Login7.
Format:
- 1 byte: Library type (ADAL=1, SecurityToken=2, MSAL=3)
- 1 byte: Workflow (0x00 for pre-acquired token)
- 4 bytes: FedAuth token length (big-endian)
- N bytes: FedAuth token (UTF-16LE encoded)
Sourcepub fn build_token_data(&self) -> Bytes
pub fn build_token_data(&self) -> Bytes
Build the FEDAUTH token packet data.
This is the token data sent in response to FEDAUTHINFO from the server.
Trait Implementations§
Source§impl AuthProvider for AzureAdAuth
impl AuthProvider for AzureAdAuth
Source§fn method(&self) -> AuthMethod
fn method(&self) -> AuthMethod
Source§fn authenticate(&self) -> Result<AuthData, AuthError>
fn authenticate(&self) -> Result<AuthData, AuthError>
Source§fn feature_extension_data(&self) -> Option<Bytes>
fn feature_extension_data(&self) -> Option<Bytes>
Source§fn needs_refresh(&self) -> bool
fn needs_refresh(&self) -> bool
Source§impl Clone for AzureAdAuth
impl Clone for AzureAdAuth
Source§fn clone(&self) -> AzureAdAuth
fn clone(&self) -> AzureAdAuth
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more