Skip to main content

AuthProvider

Trait AuthProvider 

Source
pub trait AuthProvider:
    Send
    + Sync
    + Debug {
    // Required methods
    fn method(&self) -> &str;
    fn initial(&self) -> Result<Bytes, AuthError>;

    // Provided method
    fn respond_to_challenge(
        &self,
        _challenge: &[u8],
    ) -> Result<Bytes, AuthError> { ... }
}
Expand description

Synchronous, sans-io authentication provider.

Concrete impls live in:

  • TokenAuth (in-tree, this crate)
  • TlsAuth (in-tree, this crate)
  • magnetar-auth-oauth2::OAuth2Provider
  • magnetar-auth-sasl::SaslPlain (and the optional Kerberos surface)
  • magnetar-auth-athenz::AthenzProvider (stub for M6 — surfaces Unsupported)

Required Methods§

Source

fn method(&self) -> &str

The Pulsar auth_method_name (e.g. "token", "tls", "oauth2").

Source

fn initial(&self) -> Result<Bytes, AuthError>

Bytes to populate in the initial CommandConnect.auth_data.

Providers that derive their material from external state (e.g. a token file) must re-read that state here so that rotation works without reconstructing the provider.

Provided Methods§

Source

fn respond_to_challenge(&self, _challenge: &[u8]) -> Result<Bytes, AuthError>

Bytes to populate in the CommandAuthResponse after the broker issued a CommandAuthChallenge.

The default implementation simply re-invokes AuthProvider::initial, matching the “refresh-and-resend” semantics of the Pulsar Java client. Providers that participate in a real multi-step handshake (SASL, GSSAPI) override this to consume the server challenge.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§