Skip to main content

BasicAuthLayer

Struct BasicAuthLayer 

Source
pub struct BasicAuthLayer { /* private fields */ }
Expand description

Middleware layer that adds HTTP Basic authentication headers to requests.

This layer automatically adds the Authorization header with Basic authentication credentials to all outgoing requests.

§Examples

use kintone::middleware::BasicAuthLayer;

// Enable Basic authentication
let basic_auth = BasicAuthLayer::new(Some(("username".to_string(), "password".to_string())));

// Disable Basic authentication
let no_auth = BasicAuthLayer::new(None);

Combined with other middleware:

use std::time::Duration;
use kintone::client::{Auth, KintoneClientBuilder};
use kintone::middleware;

let client = KintoneClientBuilder::new(
        "https://your-domain.cybozu.com",
        Auth::api_token("your-api-token".to_owned())
    )
    .layer(middleware::BasicAuthLayer::new(Some(("basicauth_user".to_string(), "basicauth_password".to_string()))))
    .layer(middleware::RetryLayer::new()
        .with_max_attempts(5)
        .with_initial_delay(Duration::from_secs(1))
        .with_max_delay(Duration::from_secs(8))
    )
    .layer(middleware::LoggingLayer::new())
    .build();

Implementations§

Source§

impl BasicAuthLayer

Source

pub fn new(credentials: Option<(String, String)>) -> Self

Creates a new Basic authentication layer with optional credentials.

§Arguments
  • credentials - Optional tuple of (username, password) for Basic authentication. Pass None to disable Basic authentication, or Some((username, password)) to enable it.
§Examples
use kintone::middleware::BasicAuthLayer;

// Enable Basic authentication
let basic_auth = BasicAuthLayer::new(Some(("myuser".to_string(), "mypassword".to_string())));

// Disable Basic authentication
let no_auth = BasicAuthLayer::new(None);
Source

pub fn enabled(username: impl Into<String>, password: impl Into<String>) -> Self

Creates a new Basic authentication layer with the provided credentials.

This is a convenience method that automatically wraps the credentials in Some().

§Arguments
  • username - The username for Basic authentication
  • password - The password for Basic authentication
§Examples
use kintone::middleware::BasicAuthLayer;

let basic_auth = BasicAuthLayer::enabled("myuser", "mypassword");
Source

pub fn disabled() -> Self

Creates a new Basic authentication layer with authentication disabled.

This is a convenience method that creates a layer that won’t add any authentication headers to requests.

§Examples
use kintone::middleware::BasicAuthLayer;

let no_auth = BasicAuthLayer::disabled();

Trait Implementations§

Source§

impl<Inner: Handler> Layer<Inner> for BasicAuthLayer

Source§

type Outer = BasicAuthHandler<Inner>

Source§

fn layer(self, inner: Inner) -> Self::Outer

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> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V