Add TTL cache for CSRF

O01eg
Jan 27, 2022, 1:47 PM
ZE5UFPX4K6VZXOJCYRIOUN32BFNWISSLG2BHIEJBLSUXCUITOM7AC

Dependencies

  • [2] HTYEGVBU Add data to reset password page
  • [*] WW3KRXX6 Add page for reset game password
  • [*] EVP2FSBH Split index page
  • [*] WVHXYKCV Add postgresql pools
  • [*] 4MZ4VIR7 Initial commit
  • [*] BCXEUKX6 Add config, static files and web server
  • [*] 7R6HAATP Optional publish static files if use reverse-proxy
  • [*] IM5ZPD4N Update dependencies

Change contents

  • edit in src/pages/reset_game_pwd.rs at line 58
    [2.2377]
    [2.2377]
    {
    let mut cache = data.cache.lock().await;
    cache.insert(csrf, token, std::time::Duration::from_secs(600));
    }
  • edit in src/pages/mod.rs at line 2
    [6.411]
    [6.411]
    use tokio::sync::Mutex;
    use ttl_cache::TtlCache;
    use uuid::Uuid;
  • edit in src/pages/mod.rs at line 13
    [6.559]
    [6.559]
    pub cache: Mutex<TtlCache<Uuid, Uuid>>,
  • edit in src/main.rs at line 41
    [6.856]
    [6.856]
    cache_capacity,
  • edit in src/main.rs at line 88
    [6.1899]
    [6.1899]
    cache: tokio::sync::Mutex::new(ttl_cache::TtlCache::new(cache_capacity)),
  • edit in src/config.rs at line 13
    [6.2141]
    [9.731]
    pub cache_capacity: usize,
  • edit in Cargo.toml at line 22
    [6.2576]
    [2.2575]
    ttl_cache = "0.5"
    tokio = "1.15"
  • edit in Cargo.lock at line 594
    [8.20545]
    [6.4026]
    "tokio",
  • edit in Cargo.lock at line 597
    [8.20554]
    [6.4046]
    "ttl_cache",
  • edit in Cargo.lock at line 876
    [10.8455]
    [10.8455]
    name = "linked-hash-map"
    version = "0.5.4"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3"
    [[package]]
  • edit in Cargo.lock at line 1596
    [8.40718]
    [8.40718]
    name = "ttl_cache"
    version = "0.5.1"
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "4189890526f0168710b6ee65ceaedf1460c48a14318ceec933cb26baa492096a"
    dependencies = [
    "linked-hash-map",
    ]
    [[package]]