Crate ids_daps_client

Source
Expand description

§ids-daps

The ids-daps crate provides a rust client for the Dynamic Attribute Token Service (DAPS) of the Reference Architecture Model 4 (RAM 4) of the International Data Spaces Association (IDSA).

§Usage

use ids_daps_client::{config::DapsConfigBuilder, DapsClient, ReqwestDapsClient};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create a DAPS client configuration
    let config = DapsConfigBuilder::default()
        .certs_url(certs_url)
        .token_url(token_url)
        .private_key(std::path::Path::new("./testdata/connector-certificate.p12"))
        .private_key_password(Some(std::borrow::Cow::from("Password1")))
        .scope(std::borrow::Cow::from("idsc:IDS_CONNECTORS_ALL"))
        .certs_cache_ttl(1_u64)
        .build()
        .expect("Failed to build DAPS-Config");

    // Create DAPS client
    let client: ReqwestDapsClient = DapsClient::new(&config);

    // Request a DAT token
    let dat = client.request_dat().await?;
    println!("DAT Token: {dat}");

    // Validate the DAT token
    if client.validate_dat(&dat).await.is_ok() {
        println!("Validation successful");
    }

    Ok(())
}

Modules§

cert
This module provides functions to work with DAPS certificates.
config

Structs§

DapsClient
The main struct of this crate. It provides the functionality to request and validate DAT tokens from a DAPS.
DatClaims
Claims within the DAT token.
TokenResponse
Token response from the DAPS.

Enums§

DapsError

Type Aliases§

ReqwestDapsClient
An alias for the DAPS client using the Reqwest HTTP client.