diff options
| author | KunoiSayami <[email protected]> | 2021-05-08 22:20:34 +0800 |
|---|---|---|
| committer | KunoiSayami <[email protected]> | 2021-05-08 22:20:34 +0800 |
| commit | 3cdf24651f7ee7914cc95970951d269c13fd13a5 (patch) | |
| tree | 185f1826a194fc7faea0d2337ac8996cc10131fd /src/datastructures.rs | |
| parent | a3eaa8611425c87ef940215650bad6668464c301 (diff) | |
feat: Support bypass root browsev0.1.3
* fix: Fix redirect not work properly
Diffstat (limited to 'src/datastructures.rs')
| -rw-r--r-- | src/datastructures.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/datastructures.rs b/src/datastructures.rs index 0438b70..2a19087 100644 --- a/src/datastructures.rs +++ b/src/datastructures.rs @@ -35,6 +35,7 @@ pub struct Config { pub cookie_ttl: u64, database: String, //access_node: hashmap, + pub bypass_root: bool, } impl Default for Config { @@ -42,6 +43,7 @@ impl Default for Config { Self { cookie_ttl: DEFAULT_COOKIE_TTL, database: DEFAULT_DATABASE_LOCATION.to_string(), + bypass_root: false, } } } @@ -55,6 +57,7 @@ impl Config { let file = read_to_string(path).unwrap_or_default(); let mut cookie_ttl: u64 = DEFAULT_COOKIE_TTL; let mut database: &str = "/etc/cgit/auth.db"; + let mut bypass_root: bool = false; for line in file.lines() { let line = line.trim(); if !line.contains('=') || !line.starts_with("cgit-simple-auth-") { @@ -66,16 +69,18 @@ impl Config { } else { line.split_once('=').unwrap() }; - let key_name = key.split_once("auth-").unwrap().1; + let key_name = key.split_once("auth-").unwrap().1.trim(); match key_name { "cookie-ttl" => cookie_ttl = value.parse().unwrap_or(DEFAULT_COOKIE_TTL), "database" => database = value, + "bypass-root" => bypass_root = value.to_lowercase().eq("true"), _ => {} } } Self { cookie_ttl, database: database.to_string(), + bypass_root, } } |
