pub struct SecurityScheme { /* private fields */ }Expand description
How clients authenticate to an AsyncAPI server, per the AsyncAPI 3.0
security scheme types.
Constructed with the per-kind constructors (scram_sha512,
user_password, …) and attached to a server with
ServerSpec::with_security. For a scheme shape the constructors do not model, use
custom with the raw AsyncAPI security scheme object.
§Examples
use ruststream::SecurityScheme;
let scheme = SecurityScheme::user_password().with_description("service credentials");Implementations§
Source§impl SecurityScheme
impl SecurityScheme
Sourcepub fn user_password() -> Self
pub fn user_password() -> Self
Username and password credentials (userPassword).
§Examples
use ruststream::SecurityScheme;
let scheme = SecurityScheme::user_password();Sourcepub fn api_key(location: ApiKeyLocation) -> Self
pub fn api_key(location: ApiKeyLocation) -> Self
An API key carried in the transport credentials (apiKey).
§Examples
use ruststream::{ApiKeyLocation, SecurityScheme};
let scheme = SecurityScheme::api_key(ApiKeyLocation::User);Sourcepub fn x509() -> Self
pub fn x509() -> Self
Mutual TLS with client certificates (X509).
§Examples
use ruststream::SecurityScheme;
let scheme = SecurityScheme::x509();Sourcepub fn scram_sha256() -> Self
pub fn scram_sha256() -> Self
SASL SCRAM-SHA-256 (scramSha256).
§Examples
use ruststream::SecurityScheme;
let scheme = SecurityScheme::scram_sha256();Sourcepub fn scram_sha512() -> Self
pub fn scram_sha512() -> Self
SASL SCRAM-SHA-512 (scramSha512).
§Examples
use ruststream::SecurityScheme;
let scheme = SecurityScheme::scram_sha512();Sourcepub fn gssapi() -> Self
pub fn gssapi() -> Self
SASL GSSAPI / Kerberos (gssapi).
§Examples
use ruststream::SecurityScheme;
let scheme = SecurityScheme::gssapi();Sourcepub fn http(scheme: impl Into<String>) -> Self
pub fn http(scheme: impl Into<String>) -> Self
An HTTP authentication scheme (http), e.g. "basic" or "bearer" - for brokers with
HTTP-based control or connection endpoints.
§Examples
use ruststream::SecurityScheme;
let scheme = SecurityScheme::http("bearer");Sourcepub fn http_api_key(
name: impl Into<String>,
location: HttpApiKeyLocation,
) -> Self
pub fn http_api_key( name: impl Into<String>, location: HttpApiKeyLocation, ) -> Self
An API key in an HTTP query parameter, header, or cookie (httpApiKey).
§Examples
use ruststream::{HttpApiKeyLocation, SecurityScheme};
let scheme = SecurityScheme::http_api_key("X-Api-Key", HttpApiKeyLocation::Header);Sourcepub fn open_id_connect(url: impl Into<String>) -> Self
pub fn open_id_connect(url: impl Into<String>) -> Self
OpenID Connect discovery (openIdConnect), pointing at the provider’s discovery URL.
§Examples
use ruststream::SecurityScheme;
let scheme = SecurityScheme::open_id_connect("https://idp.example.com/.well-known/openid-configuration");Sourcepub fn oauth2(flows: Value) -> Self
pub fn oauth2(flows: Value) -> Self
OAuth2 (oauth2) with the given AsyncAPI flows object, passed as raw JSON (the flows
shape is deep and deployment-specific, so it is not modeled field by field).
§Examples
use ruststream::SecurityScheme;
let scheme = SecurityScheme::oauth2(serde_json::json!({
"clientCredentials": {
"tokenUrl": "https://idp.example.com/token",
"availableScopes": { "kafka:write": "produce" },
}
}));Sourcepub fn custom(object: Value) -> Self
pub fn custom(object: Value) -> Self
An arbitrary AsyncAPI security scheme object, emitted as-is - the escape hatch for
kinds or fields the constructors do not model.
§Examples
use ruststream::SecurityScheme;
let scheme = SecurityScheme::custom(serde_json::json!({ "type": "symmetricEncryption" }));Sourcepub fn with_description(self, description: impl Into<String>) -> Self
pub fn with_description(self, description: impl Into<String>) -> Self
Builder-style setter for the scheme description.
§Examples
use ruststream::SecurityScheme;
let scheme = SecurityScheme::plain().with_description("SASL over TLS");Trait Implementations§
Source§impl Clone for SecurityScheme
impl Clone for SecurityScheme
Source§fn clone(&self) -> SecurityScheme
fn clone(&self) -> SecurityScheme
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more