Skip to content

SASLScram256

faststream.security.SASLScram256 #

SASLScram256(username, password, ssl_context=None, use_ssl=None)

Bases: BaseSecurity

Security configuration for SASL/SCRAM-SHA-256 authentication.

This class defines security configuration for SASL/SCRAM-SHA-256 authentication, which includes a username and password.

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

    self.username = username
    self.password = password

ssl_context instance-attribute #

ssl_context = ssl_context

use_ssl instance-attribute #

use_ssl = use_ssl

username instance-attribute #

username = username

password instance-attribute #

password = password

get_requirement #

get_requirement()

Get the security requirements for SASL/SCRAM-SHA-256 authentication.

Source code in faststream/security.py
def get_requirement(self) -> List["AnyDict"]:
    """Get the security requirements for SASL/SCRAM-SHA-256 authentication."""
    return [{"scram256": []}]

get_schema #

get_schema()

Get the security schema for SASL/SCRAM-SHA-256 authentication.

Source code in faststream/security.py
def get_schema(self) -> Dict[str, Dict[str, str]]:
    """Get the security schema for SASL/SCRAM-SHA-256 authentication."""
    return {"scram256": {"type": "scramSha256"}}