pub struct ClientConfig {
pub key_id: String,
pub private_key_path: PathBuf,
pub jwks_path: Option<PathBuf>,
}Expand description
Configuration for an authenticated Open Payments client.
This struct contains all the necessary configuration for creating an authenticated client that can sign HTTP requests. It includes paths to cryptographic keys and identifiers used in the signing process.
§Example
use open_payments::client::ClientConfig;
use std::path::PathBuf;
let config = ClientConfig {
key_id: "my-key-2024".to_string(),
private_key_path: PathBuf::from("keys/private.pem"),
jwks_path: Some(PathBuf::from("keys/jwks.json")),
};Fields§
§key_id: String§private_key_path: PathBufPath to the private key file used for signing HTTP requests.
The private key should be in PEM format (either in plain text or base64 encoded) and compatible with Ed25519 signing. If the file doesn’t exist, a new key will be generated automatically.
jwks_path: Option<PathBuf>Optional path where the JSON Web Key Set (JWKS) should be saved.
If provided, the client will automatically generate a JWKS containing the public key corresponding to the private key and save it to this location.
§Usage
- Set to
Some(path)to enable automatic JWKS generation - Set to
Noneto disable JWKS generation - The JWKS file will be created automatically when the client is initialized
Example: Some(PathBuf::from("keys/jwks.json"))
Trait Implementations§
Source§impl Clone for ClientConfig
impl Clone for ClientConfig
Source§fn clone(&self) -> ClientConfig
fn clone(&self) -> ClientConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ClientConfig
impl Debug for ClientConfig
Source§impl Default for ClientConfig
impl Default for ClientConfig
Source§fn default() -> Self
fn default() -> Self
Creates a default configuration with reasonable defaults.
The default configuration uses:
- Empty key ID
private.keyas the private key pathjwks.jsonas the JWKS path
Note: You should typically override the key_id with a meaningful value
and consider using more secure paths for production environments.
§Example
use open_payments::client::ClientConfig;
let mut config = ClientConfig::default();
config.key_id = "my-key".to_string();