Client

Struct Client 

Source
pub struct Client<S> { /* private fields */ }
Expand description

A TACACS+ client.

Implementations§

Source§

impl<S: AsyncRead + AsyncWrite + Unpin> Client<S>

Source

pub fn new<K: AsRef<[u8]>>( connection_factory: ConnectionFactory<S>, secret: Option<K>, ) -> Self

Initializes a new TACACS+ client that uses the provided factory to open connections to a server.

[RFC8907 section 10.5.1] specifies that clients SHOULD NOT allow secret keys less than 16 characters in length. This constructor does not check for that, but consider yourself warned.

If an incorrect secret is provided to this constructor, you might notice ClientError::InvalidPacketReceived errors when attempting different TACACS+ operations. Specific inner error variants in such cases could be WrongBodyBufferSize or BadText.

Additionally, if a secret is provided in this constructor but one is not configured for the remote TACACS+ server, or vice versa, you will again see ClientError::InvalidPacketReceived errors, but rather with an inner error variant of DeserializeError::IncorrectUnencryptedFlag.

If no secret is provided in this constructor, the returned client does not obfuscate packets sent over the provided connection. Per RFC8907 section 4.5, unobfuscated packet transfer MUST NOT be used in production, so prefer to provide a secret (of a secure length) where possible.

Source

pub async fn authenticate( &self, context: SessionContext, password: &str, authentication_type: AuthenticationType, ) -> Result<AuthenticationResponse, ClientError>

Authenticates against a TACACS+ server with a username and password using the specified protocol.

Source

pub async fn authorize( &self, context: SessionContext, arguments: Vec<Argument<'_>>, ) -> Result<AuthorizationResponse, ClientError>

Performs TACACS+ authorization against the server with the provided arguments.

A merged Vec of all of the sent and received arguments is returned, with values replaced from the server as necessary. No guarantees are made for the replacement of several arguments with the same name, however, since even RFC8907 doesn’t specify how to handle that case.

Source

pub async fn account_begin<'args, A: AsRef<[Argument<'args>]>>( &self, context: SessionContext, arguments: A, ) -> Result<(AccountingTask<&Self>, AccountingResponse), ClientError>

Starts tracking a task via the TACACS+ accounting mechanism.

The task_id and start_time arguments specified in RFC8907 section 8.3 are set internally in addition to the provided arguments.

This function only sends a start record to a TACACS+ server; the update() and stop() methods on the returned AccountingTask should be used for sending additional accounting records.

Trait Implementations§

Source§

impl<S: Clone> Clone for Client<S>

Source§

fn clone(&self) -> Client<S>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<S: Debug> Debug for Client<S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<S> Freeze for Client<S>

§

impl<S> !RefUnwindSafe for Client<S>

§

impl<S> Send for Client<S>
where S: Send,

§

impl<S> Sync for Client<S>
where S: Send,

§

impl<S> Unpin for Client<S>

§

impl<S> !UnwindSafe for Client<S>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

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

Source§

fn vzip(self) -> V