[−][src]Struct libzmq::auth::AuthClient
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]
I: IntoIpAddrs,
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]
I: IntoIpAddrs,
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]
I: IntoIpAddrs,
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]
I: IntoIpAddrs,
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]
I: IntoIpAddrs,
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]
I: IntoIpAddrs,
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]
I: IntoIterator<Item = E>,
E: Into<PlainClientCreds>,
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]
&self,
usernames: I
) -> Result<(), Error<usize>> where
I: IntoIterator<Item = E>,
E: Into<String>,
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]
I: IntoIterator<Item = E>,
E: Into<PlainClientCreds>,
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]
I: IntoIterator<Item = E>,
E: Into<CurvePublicKey>,
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]
I: IntoIterator<Item = E>,
E: Into<CurvePublicKey>,
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]
I: IntoIterator<Item = E>,
E: Into<CurvePublicKey>,
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
impl RefUnwindSafe for AuthClient
impl Send for AuthClient
impl Sync for AuthClient
impl Unpin for AuthClient
impl UnwindSafe for AuthClient
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,