You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.0 KiB
43 lines
1.0 KiB
//! Settings for web server
|
|
//!
|
|
//! Usually derived from config
|
|
use super::*;
|
|
|
|
const DEFAULT_MAX_BODY_LEN_ARESP: u64 = 1024 * 4; // 4KB
|
|
const DEFAULT_MAX_BODY_LEN: u64 = 1024 * 1024 * 4; // 4MB
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
pub struct Settings
|
|
{
|
|
/// First is max body len for auth responses, 2nd is for data.
|
|
pub max_body_len: (u64, u64),
|
|
pub trust_x_forwarded_for: bool,
|
|
|
|
pub allow_passwd_auth: bool,
|
|
pub max_key_sigs_per_auth_response: usize,
|
|
|
|
/// How long is an auth request ID is valid.
|
|
pub auth_req_ttl_millis: u64,
|
|
/// How long is an authentication token valid for an action.
|
|
pub auth_token_ttl_millis: u64,
|
|
}
|
|
|
|
impl Default for Settings
|
|
{
|
|
#[inline]
|
|
fn default() -> Self
|
|
{
|
|
Self {
|
|
max_body_len: (DEFAULT_MAX_BODY_LEN_ARESP, DEFAULT_MAX_BODY_LEN),
|
|
trust_x_forwarded_for: false,
|
|
|
|
allow_passwd_auth: true,
|
|
max_key_sigs_per_auth_response: 16,
|
|
|
|
auth_req_ttl_millis: 5000, //5 s
|
|
auth_token_ttl_millis: 60 * 2000, //2 m
|
|
}
|
|
}
|
|
}
|
|
|