Skip to main content

AuthValidator

Trait AuthValidator 

Source
pub trait AuthValidator: Send + Sync {
    // Required method
    fn validate(
        &self,
        scheme: &str,
        param: &str,
    ) -> Result<AuthResult, AuthError>;
}
Expand description

Trait for validating streaming client credentials.

The server calls validate after receiving a Hello message. Return AuthResult on success or AuthError on failure.

§Example: Custom validator

use snapcast_server::auth::{AuthValidator, AuthResult, AuthError};

struct MyValidator;

impl AuthValidator for MyValidator {
    fn validate(&self, scheme: &str, param: &str) -> Result<AuthResult, AuthError> {
        // Look up in database, LDAP, etc.
        Ok(AuthResult {
            username: "user".into(),
            permissions: vec!["Streaming".into()],
        })
    }
}

Trait for validating streaming client credentials.

Required Methods§

Source

fn validate(&self, scheme: &str, param: &str) -> Result<AuthResult, AuthError>

Validate credentials from the Hello message’s auth field.

Implementors§