[][src]Struct libzmq::auth::AuthClient

pub struct AuthClient { /* fields omitted */ }

A client to configure the AuthServer.

There can be multiple AuthClient associated with the same AuthServer.

Example

#[cfg(feature = "curve")] {
    use libzmq::{prelude::*, auth::*, *};
    use std::{time::Duration};

    let server_cert = CurveCert::new_unique();
    let client_cert = CurveCert::new_unique();

    let addr: TcpAddr = "127.0.0.1:*".try_into()?;

    let server_creds = CurveServerCreds::new(server_cert.secret());

    // Creates a server using the `CurveServer` mechanism. Since `CURVE`
    // authentication is enabled by default, only sockets whose public key
    // is in the whitelist will be allowed to connect.
    let server = ServerBuilder::new()
        .bind(&addr)
        .mechanism(server_creds)
        .recv_timeout(Duration::from_millis(200))
        .build()?;

    // We need to tell the `AuthServer` to allow the client's public key.
    let _ = AuthBuilder::new().curve_registry(client_cert.public()).build()?;

    let bound = server.last_endpoint()?;

    let client_creds = CurveClientCreds::new(server_cert.public())
        .add_cert(client_cert);

    // Creates a server using the `CurveServer` mechanism. Since `CURVE`
    let client = ClientBuilder::new()
        .mechanism(client_creds)
        .connect(bound)
        .build()?;

    // The handshake is successfull so we can now send and receive messages.
    client.send("").unwrap();
    server.recv_msg().unwrap();
}

Implementations

impl AuthClient[src]

pub fn new() -> Result<Self, Error>[src]

Create a AuthClient connected to the AuthServer associated with the default global Ctx.

pub fn with_ctx(handle: CtxHandle) -> Result<Self, Error>[src]

Create a AuthClient connected to the AuthServer associated with the context aliased by the CtxHandle.

pub fn add_blacklist<I>(&self, ips: I) -> Result<(), Error<usize>> where
    I: IntoIpAddrs
[src]

Add the ips to the AuthServer's blacklist.

Blacklisted ips will be denied access.

pub fn remove_blacklist<I>(&self, ips: I) -> Result<(), Error<usize>> where
    I: IntoIpAddrs
[src]

Remove the ips from the AuthServer's blacklist, if they are present.

pub fn set_blacklist<I>(&self, ips: I) -> Result<(), Error> where
    I: IntoIpAddrs
[src]

Set the ips in the AuthServer's blacklist.

Blacklisted ips will be denied access.

pub fn add_whitelist<I>(&self, ips: I) -> Result<(), Error<usize>> where
    I: IntoIpAddrs
[src]

Add the ips to the AuthServer's whitelist.

If the whitelist is not empty, only ips in present in the whitelist are allowed. The whitelist takes precedence over the blacklist.

pub fn remove_whitelist<I>(&self, ips: I) -> Result<(), Error<usize>> where
    I: IntoIpAddrs
[src]

Remove the ips from the AuthServer's whitelist, if it is present.

pub fn set_whitelist<I>(&self, ips: I) -> Result<(), Error> where
    I: IntoIpAddrs
[src]

Set the ips in the AuthServer's whitelist.

If the whitelist is not empty, only ips in present in the whitelist are allowed. The whitelist takes precedence over the blacklist.

pub fn add_plain_registry<I, E>(&self, iter: I) -> Result<(), Error<usize>> where
    I: IntoIterator<Item = E>,
    E: Into<PlainClientCreds>, 
[src]

Add the credentials to the AuthServer's plain registry.

Only credentials present in the registry can successfully authenticate.

pub fn remove_plain_registry<I, E>(
    &self,
    usernames: I
) -> Result<(), Error<usize>> where
    I: IntoIterator<Item = E>,
    E: Into<String>, 
[src]

Remove the credentials with the given usernames from the plain registry.

pub fn set_plain_registry<I, E>(&self, creds: I) -> Result<(), Error> where
    I: IntoIterator<Item = E>,
    E: Into<PlainClientCreds>, 
[src]

Set the credentials in the AuthServer's plain registry.

Only credentials present in the registry can successfully authenticate.

pub fn add_curve_registry<I, E>(&self, keys: I) -> Result<(), Error<usize>> where
    I: IntoIterator<Item = E>,
    E: Into<CurvePublicKey>, 
[src]

Add the curve keys to the curve registry.

Only public keys present in the whitelist are allowed to authenticate via the CURVE mechanism.

pub fn remove_curve_registry<I, E>(&self, keys: I) -> Result<(), Error<usize>> where
    I: IntoIterator<Item = E>,
    E: Into<CurvePublicKey>, 
[src]

Remove the given public keys from the AuthServer's curve registry if they are present.

pub fn set_curve_registry<I, E>(&self, keys: I) -> Result<(), Error> where
    I: IntoIterator<Item = E>,
    E: Into<CurvePublicKey>, 
[src]

Set the public keys in the AuthServer's curve registry.

pub fn set_curve_auth(&self, enabled: bool) -> Result<(), Error>[src]

Sets whether to use authentication for the CURVE mechanism.

If it is set to true, then only sockets whose public key is present in the whitelist will be allowed to authenticate. Otherwise all sockets authenticate successfully.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,