pub struct SqlServerAuth { /* private fields */ }Expand description
SQL Server authenticator for username/password authentication.
This provider handles traditional SQL Server authentication where credentials are sent via the Login7 packet with password obfuscation.
§Security Note
The password is obfuscated (XOR + nibble swap), not encrypted. Always use TLS encryption for the connection.
§Example
use mssql_auth::SqlServerAuth;
let auth = SqlServerAuth::new("sa", "Password123!");Implementations§
Source§impl SqlServerAuth
impl SqlServerAuth
Sourcepub fn new(
username: impl Into<Cow<'static, str>>,
password: impl Into<Cow<'static, str>>,
) -> Self
pub fn new( username: impl Into<Cow<'static, str>>, password: impl Into<Cow<'static, str>>, ) -> Self
Create a new SQL Server authenticator with credentials.
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 SQL Server credentials.
Sourcepub fn encode_password(password: &str) -> Vec<u8> ⓘ
pub fn encode_password(password: &str) -> Vec<u8> ⓘ
Encode a password for SQL Server Login7 packet.
SQL Server uses a simple XOR-based obfuscation for passwords in Login7 packets. This is NOT encryption - it’s just obfuscation. The connection should always be encrypted via TLS.
§Algorithm
For each UTF-16 code unit:
- XOR each byte with 0xA5
- Swap the high and low nibbles
Trait Implementations§
Source§impl AuthProvider for SqlServerAuth
impl AuthProvider for SqlServerAuth
Source§fn method(&self) -> AuthMethod
fn method(&self) -> AuthMethod
Get the authentication method this provider uses.
Source§fn authenticate(&self) -> Result<AuthData, AuthError>
fn authenticate(&self) -> Result<AuthData, AuthError>
Authenticate and produce authentication data. Read more
Source§fn feature_extension_data(&self) -> Option<Bytes>
fn feature_extension_data(&self) -> Option<Bytes>
Get additional feature extension data for Login7. Read more
Source§fn needs_refresh(&self) -> bool
fn needs_refresh(&self) -> bool
Check if this provider needs to refresh its authentication. Read more
Source§impl Clone for SqlServerAuth
impl Clone for SqlServerAuth
Source§fn clone(&self) -> SqlServerAuth
fn clone(&self) -> SqlServerAuth
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for SqlServerAuth
impl RefUnwindSafe for SqlServerAuth
impl Send for SqlServerAuth
impl Sync for SqlServerAuth
impl Unpin for SqlServerAuth
impl UnwindSafe for SqlServerAuth
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
Mutably borrows from an owned value. Read more