Skip to content

SASLPlaintext

faststream.security.SASLPlaintext #

SASLPlaintext(
    username: str,
    password: str,
    ssl_context: Optional[SSLContext] = None,
    use_ssl: Optional[bool] = None,
)

Bases: BaseSecurity

Security configuration for SASL/PLAINTEXT authentication.

This class defines security configuration for SASL/PLAINTEXT authentication, which includes a username and password.

PARAMETER DESCRIPTION
username

The username for authentication.

TYPE: str

password

The password for authentication.

TYPE: str

ssl_context

An SSLContext object for SSL encryption. If None, SSL encryption is disabled.

TYPE: Optional[SSLContext] DEFAULT: None

use_ssl

A boolean indicating whether to use SSL encryption. Defaults to True.

TYPE: Optional[bool] DEFAULT: None

METHOD DESCRIPTION
get_requirement

Get the security requirements for SASL/PLAINTEXT authentication.

get_schema

Get the security schema for SASL/PLAINTEXT authentication.

Source code in faststream/security.py
def __init__(
    self,
    username: str,
    password: str,
    ssl_context: Optional[SSLContext] = None,
    use_ssl: Optional[bool] = None,
):
    super().__init__(ssl_context, use_ssl)
    self.username = username
    self.password = password

password instance-attribute #

password = password

ssl_context instance-attribute #

ssl_context = ssl_context

use_ssl instance-attribute #

use_ssl = use_ssl

username instance-attribute #

username = username

get_requirement #

get_requirement() -> List[AnyDict]

Get the security requirements for SASL/PLAINTEXT authentication.

RETURNS DESCRIPTION
List[AnyDict]

List[AnyDict]: A list of dictionaries representing security requirements.

Source code in faststream/security.py
def get_requirement(self) -> List[AnyDict]:
    """
    Get the security requirements for SASL/PLAINTEXT authentication.

    Returns:
        List[AnyDict]: A list of dictionaries representing security requirements.
    """
    return [{"user-password": []}]

get_schema #

get_schema() -> Dict[str, Dict[str, str]]

Get the security schema for SASL/PLAINTEXT authentication.

RETURNS DESCRIPTION
Dict[str, Dict[str, str]]

Dict[str, Dict[str, str]]: A dictionary representing the security schema.

Source code in faststream/security.py
def get_schema(self) -> Dict[str, Dict[str, str]]:
    """
    Get the security schema for SASL/PLAINTEXT authentication.

    Returns:
        Dict[str, Dict[str, str]]: A dictionary representing the security schema.
    """
    return {"user-password": {"type": "userPassword"}}

Last update: 2023-11-13