pub struct Client<S> { /* private fields */ }Expand description
A TACACS+ client.
Implementations§
Source§impl<S: AsyncRead + AsyncWrite + Unpin> Client<S>
impl<S: AsyncRead + AsyncWrite + Unpin> Client<S>
Sourcepub fn new<K: AsRef<[u8]>>(
connection_factory: ConnectionFactory<S>,
secret: Option<K>,
) -> Self
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.
Sourcepub async fn authenticate(
&self,
context: SessionContext,
password: &str,
authentication_type: AuthenticationType,
) -> Result<AuthenticationResponse, ClientError>
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.
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.
Sourcepub async fn account_begin<'args, A: AsRef<[Argument<'args>]>>(
&self,
context: SessionContext,
arguments: A,
) -> Result<(AccountingTask<&Self>, AccountingResponse), ClientError>
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.