Skip to main content

SecurityScheme

Struct SecurityScheme 

Source
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

Source

pub fn user_password() -> Self

Username and password credentials (userPassword).

§Examples
use ruststream::SecurityScheme;
let scheme = SecurityScheme::user_password();
Source

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);
Source

pub fn x509() -> Self

Mutual TLS with client certificates (X509).

§Examples
use ruststream::SecurityScheme;
let scheme = SecurityScheme::x509();
Source

pub fn plain() -> Self

SASL PLAIN (plain).

§Examples
use ruststream::SecurityScheme;
let scheme = SecurityScheme::plain();
Source

pub fn scram_sha256() -> Self

SASL SCRAM-SHA-256 (scramSha256).

§Examples
use ruststream::SecurityScheme;
let scheme = SecurityScheme::scram_sha256();
Source

pub fn scram_sha512() -> Self

SASL SCRAM-SHA-512 (scramSha512).

§Examples
use ruststream::SecurityScheme;
let scheme = SecurityScheme::scram_sha512();
Source

pub fn gssapi() -> Self

SASL GSSAPI / Kerberos (gssapi).

§Examples
use ruststream::SecurityScheme;
let scheme = SecurityScheme::gssapi();
Source

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");
Source

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);
Source

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");
Source

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" },
    }
}));
Source

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" }));
Source

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

Source§

fn clone(&self) -> SecurityScheme

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for SecurityScheme

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for SecurityScheme

Source§

impl PartialEq for SecurityScheme

Source§

fn eq(&self, other: &SecurityScheme) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SecurityScheme

Auto Trait Implementations§

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> 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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more