fix(jans-cedarling): add request timeouts to outbound HTTP clients (#… · JanssenProject/jans@a1b4975 (original) (raw)

Original file line number Diff line number Diff line change
@@ -74,6 +74,12 @@ the Cedarling will use the default value as specified in the property definition
74 74
75 75 - **`CEDARLING_DATA_STORE_MEMORY_ALERT_THRESHOLD`** : Memory usage threshold percentage (0.0-100.0) for triggering alerts. Default value is `80.0`. When capacity usage exceeds this threshold, `memory_alert_triggered` will be `true` in statistics.
76 76
77 +**HTTP client:**
78 +
79 +- **`CEDARLING_HTTP_REQUEST_TIMEOUT_MILLIS`** : Per-request timeout in seconds. Only applicable for native targets (not WASM). Default is `10` (10 seconds).
80 +- **`CEDARLING_HTTP_REQUEST_MAX_RETRIES`** : Maximum number of retry attempts per request. Only applicable for native targets (not WASM). Default is `3`.
81 +- **`CEDARLING_HTTP_REQUEST_RETRY_DELAY`** : Base delay between retries in seconds. Only applicable for native targets (not WASM). Default is `3` (3 seconds).
82 +
77 83 **Advanced configuration:**
78 84
79 85 - **`CEDARLING_MAX_BASE64_SIZE`** : Maximum size in bytes for Base64-encoded content (policies, schema, etc.)
Original file line number Diff line number Diff line change
@@ -5,8 +5,8 @@
5 5
6 6 use cedarling::{
7 7 AuthorizationConfig, AuthorizeMultiIssuerRequest, BootstrapConfig, Cedarling, DataStoreConfig,
8 -EntityData, InitCedarlingError, JwtConfig, LogConfig, LogLevel, LogTypeConfig,
9 -PolicyStoreConfig, TokenInput,
8 +EntityData, HttpClientConfig, InitCedarlingError, JwtConfig, LogConfig, LogLevel,
9 +LogTypeConfig, PolicyStoreConfig, TokenInput,
10 10 };
11 11 use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
12 12 use jsonwebtoken::Algorithm;
@@ -116,6 +116,7 @@ async fn prepare_cedarling_with_jwt_validation(
116 116 max_base64_size: None,
117 117 max_default_entities: None,
118 118 data_store_config: DataStoreConfig::default(),
119 +http_client_config: HttpClientConfig::default(),
119 120 };
120 121
121 122 Cedarling::new(&bootstrap_config).await
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
4 4 // Copyright (c) 2024, Gluu, Inc.
5 5
6 6 use cedarling::{
7 -AuthorizationConfig, BootstrapConfig, Cedarling, DataStoreConfig, EntityData,
7 +AuthorizationConfig, BootstrapConfig, Cedarling, DataStoreConfig, EntityData, HttpClientConfig,
8 8 InitCedarlingError, JwtConfig, LogConfig, LogLevel, LogTypeConfig, PolicyStoreConfig,
9 9 PolicyStoreSource, RequestUnsigned,
10 10 };
@@ -155,6 +155,7 @@ async fn prepare_cedarling() -> Result<Cedarling, InitCedarlingError> {
155 155 max_base64_size: None,
156 156 max_default_entities: None,
157 157 data_store_config: DataStoreConfig::default(),
158 +http_client_config: HttpClientConfig::default(),
158 159 };
159 160
160 161 Cedarling::new(&bootstrap_config).await
Original file line number Diff line number Diff line change
@@ -17,8 +17,8 @@ use std::time::Duration;
17 17
18 18 use cedarling::{
19 19 AuthorizationConfig, BootstrapConfig, Cedarling, DataApi, DataStoreConfig, EntityData,
20 -JwtConfig, LogConfig, LogLevel, LogTypeConfig, PolicyStoreConfig, PolicyStoreSource,
21 -RequestUnsigned,
20 +HttpClientConfig, JwtConfig, LogConfig, LogLevel, LogTypeConfig, PolicyStoreConfig,
21 +PolicyStoreSource, RequestUnsigned,
22 22 };
23 23 use criterion::{BenchmarkId, Criterion, Throughput, criterion_group, criterion_main};
24 24 use serde::Deserialize;
@@ -101,6 +101,7 @@ static BSCONFIG: LazyLock = LazyLock::new(| BootstrapConfig {
101 101 max_base64_size: None,
102 102 max_default_entities: None,
103 103 data_store_config: DataStoreConfig::default(),
104 +http_client_config: HttpClientConfig::default(),
104 105 });
105 106
106 107 static BSCONFIG_WITH_DATA_POLICY: LazyLock<BootstrapConfig> = LazyLock::new(|
@@ -118,6 +119,7 @@ static BSCONFIG_WITH_DATA_POLICY: LazyLock = LazyLock::new(| B
118 119 max_base64_size: None,
119 120 max_default_entities: None,
120 121 data_store_config: DataStoreConfig::default(),
122 +http_client_config: HttpClientConfig::default(),
121 123 });
122 124
123 125 // =============================================================================
Original file line number Diff line number Diff line change
@@ -9,8 +9,8 @@ use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
9 9 use tokio::runtime::Runtime;
10 10
11 11 use cedarling::{
12 -AuthorizationConfig, BootstrapConfig, Cedarling, DataStoreConfig, JwtConfig, LogConfig,
13 -LogLevel, LogTypeConfig, PolicyStoreConfig, PolicyStoreSource,
12 +AuthorizationConfig, BootstrapConfig, Cedarling, DataStoreConfig, HttpClientConfig, JwtConfig,
13 +LogConfig, LogLevel, LogTypeConfig, PolicyStoreConfig, PolicyStoreSource,
14 14 };
15 15
16 16 const POLICY_STORE: &str = include_str!("../../test_files/policy-store_ok.yaml");
@@ -46,4 +46,5 @@ static BSCONFIG_LOCAL: LazyLock = LazyLock::new(| BootstrapCon
46 46 max_base64_size: None,
47 47 max_default_entities: None,
48 48 data_store_config: DataStoreConfig::default(),
49 +http_client_config: HttpClientConfig::default(),
49 50 });
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
3 3 //
4 4 // Copyright (c) 2024, Gluu, Inc.
5 5
6 -use cedarling::{
6 +use cedarling::{HttpClientConfig,
7 7 AuthorizationConfig, BootstrapConfig, CedarEntityMapping, Cedarling, DataStoreConfig,
8 8 EntityData, JwtConfig, LogConfig, LogLevel, LogTypeConfig, PolicyStoreConfig,
9 9 PolicyStoreSource, RequestUnsigned, log_config::StdOutLoggerMode,
@@ -39,6 +39,7 @@ async fn main() -> Result<(), Box> {
39 39 max_default_entities: None,
40 40 max_base64_size: None,
41 41 data_store_config: DataStoreConfig::default(),
42 +http_client_config: HttpClientConfig::default(),
42 43 })
43 44 .await?;
44 45
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
5 5
6 6 #![allow(clippy::cast_precision_loss)]
7 7
8 -use cedarling::{
8 +use cedarling::{HttpClientConfig,
9 9 AuthorizationConfig, BootstrapConfig, CedarEntityMapping, Cedarling, DataStoreConfig,
10 10 EntityData, JwtConfig, LogConfig, LogLevel, LogTypeConfig, PolicyStoreConfig,
11 11 PolicyStoreSource, RequestUnsigned,
@@ -96,6 +96,7 @@ async fn initialize_cedarling() -> Result<Cedarling, Box>
96 96 max_base64_size: None,
97 97 max_default_entities: None,
98 98 data_store_config: DataStoreConfig::default(),
99 +http_client_config: HttpClientConfig::default(),
99 100 })
100 101 .await?;
101 102
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
6 6 // run this example using `cargo run --example lock_integration`
7 7
8 8 use cedarling::log_config::StdOutLoggerMode;
9 -use cedarling::{
9 +use cedarling::{HttpClientConfig,
10 10 AuthorizationConfig, BootstrapConfig, CedarEntityMapping, Cedarling, DataStoreConfig,
11 11 EntityData, JwtConfig, LockServiceConfig, LockTransport, LogConfig, LogLevel, LogTypeConfig,
12 12 PolicyStoreConfig, PolicyStoreSource, RequestUnsigned,
@@ -64,6 +64,7 @@ async fn main() -> Result<(), Box> {
64 64 max_default_entities: None,
65 65 max_base64_size: None,
66 66 data_store_config: DataStoreConfig::default(),
67 +http_client_config: HttpClientConfig::default(),
67 68 })
68 69 .await?;
69 70
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
9 9 // and `use std::env` prevents that compilation.
10 10 #![cfg(not(target_family = "wasm"))]
11 11
12 -use cedarling::{
12 +use cedarling::{HttpClientConfig,
13 13 AuthorizationConfig, BootstrapConfig, Cedarling, DataStoreConfig, JwtConfig, LogConfig,
14 14 LogLevel, LogStorage, LogTypeConfig, MemoryLogConfig, PolicyStoreConfig, PolicyStoreSource,
15 15 log_config::StdOutLoggerMode,
@@ -61,6 +61,7 @@ async fn main() -> Result<(), Box> {
61 61 max_default_entities: None,
62 62 max_base64_size: None,
63 63 data_store_config: DataStoreConfig::default(),
64 +http_client_config: HttpClientConfig::default(),
64 65 })
65 66 .await?;
66 67
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
6 6 #![allow(unused_imports)]
7 7 #![allow(dead_code)]
8 8
9 -use cedarling::{
9 +use cedarling::{HttpClientConfig,
10 10 AuthorizationConfig, AuthorizeMultiIssuerRequest, BootstrapConfig, Cedarling, DataStoreConfig,
11 11 EntityData, InitCedarlingError, JwtConfig, LogConfig, LogLevel, LogTypeConfig,
12 12 PolicyStoreConfig, TokenInput,
@@ -112,6 +112,7 @@ async fn init_cedarling_multi_issuer(
112 112 max_base64_size: None,
113 113 max_default_entities: None,
114 114 data_store_config: DataStoreConfig::default(),
115 +http_client_config: HttpClientConfig::default(),
115 116 };
116 117
117 118 Cedarling::new(&bootstrap_config).await