diff options
author | KunoiSayami <[email protected]> | 2021-05-16 00:31:22 +0800 |
---|---|---|
committer | KunoiSayami <[email protected]> | 2021-05-16 01:14:21 +0800 |
commit | 345197aa4aa148346f14eb3ef1cc76109c9198c4 (patch) | |
tree | 0b068f1dd92e15f95f3437df9cb99d9737abee3b | |
parent | 2f051ba28328f57552fd8758bdd8877e2b0d86ef (diff) |
doc: Add configure sections to READMEv1.0.0
-rw-r--r-- | Cargo.lock | 2 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | README.md | 35 | ||||
-rw-r--r-- | src/datastructures.rs | 19 | ||||
-rw-r--r-- | src/main.rs | 2 |
5 files changed, 33 insertions, 27 deletions
@@ -377,7 +377,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "cgit-simple-authentication" -version = "0.4.2" +version = "1.0.0" dependencies = [ "anyhow", "argon2", @@ -1,6 +1,6 @@ [package] name = "cgit-simple-authentication" -version = "0.4.2" +version = "1.0.0" authors = ["KunoiSayami <[email protected]>"] edition = "2018" @@ -1,14 +1,41 @@ # Cgit simple authentication -This project is currently developing, minor version may incompatible with previous minor version. +Simple authentication for [cgit](https://wiki.archlinux.org/title/Cgit) powered by [sqlite](https://wiki.archlinux.org/title/SQLite) and [redis](https://wiki.archlinux.org/title/Redis) -## Notice +## Configure -Upgrade from v0.1.x to v0.2.x should reset database due to password storage method changed. +Add this project as cgit [`auth-filter`](https://man.archlinux.org/man/cgitrc.5#FILTER_API) + +```conf +auth-filter=/opt/cgit-simple-authentication/target/release/cgit-simple-authentication +``` + +Available options for this filter: + +```conf +# Set cookie time to live +cgit-simple-auth-cookie-ttl=600 +# Specify database location (Default is /etc/cgit/auth.db) +cgit-simple-auth-database=/etc/cgit/auth.db +# Should authenticate in repositories root view +cgit-simple-auth-bypass-root=false +# Should enable authenticate in all repository +cgit-simple-auth-full-protect=true +``` + +Available options for repositories: + +_Should set `cgit-simple-auth-full-protect=false`_ + +```conf +repo.url=test +# Enable protect for this repository +repo.protect=true +``` ## Source -Most idea from: https://github.com/varphone/cgit-gogs-auth-filter +Most of the ideas come from: https://github.com/varphone/cgit-gogs-auth-filter ## License diff --git a/src/datastructures.rs b/src/datastructures.rs index 83f3bc6..51f000c 100644 --- a/src/datastructures.rs +++ b/src/datastructures.rs @@ -38,7 +38,6 @@ const DEFAULT_COOKIE_TTL: u64 = 1200; const DEFAULT_DATABASE_LOCATION: &str = "/etc/cgit/auth.db"; pub const CACHE_DIR: &str = "/var/cache/cgit"; pub type RandIntType = u32; -//pub const MINIMUM_SECRET_LENGTH: usize = 8; pub const COOKIE_LENGTH: usize = 32; pub fn get_current_timestamp() -> u64 { @@ -347,23 +346,6 @@ impl FormData { pub fn get_user(&self) -> &String { &self.user } - - pub fn get_password_argon2(&self) -> Result<String> { - Self::get_string_argon2_hash(&self.password) - } - - #[allow(dead_code)] - pub fn get_password_argon2_cache(&mut self) -> Result<String> { - if self.hash.is_empty() { - self.hash = self.get_password_argon2()?; - } - Ok(self.hash.clone()) - } - - #[allow(dead_code)] - pub fn get_argon2_without_calc(&self) -> &String { - &self.hash - } } impl From<&[u8]> for FormData { @@ -459,7 +441,6 @@ impl Cookie { format!("{}_{}", self.timestamp, self.randint) } - #[allow(dead_code)] pub fn get_user(&self) -> &str { self.user.as_str() } diff --git a/src/main.rs b/src/main.rs index b42d827..45fb166 100644 --- a/src/main.rs +++ b/src/main.rs @@ -230,7 +230,6 @@ async fn verify_login(cfg: &Config, data: &FormData) -> Result<bool> { pub struct Meta<'a> { action: &'a str, redirect: &'a str, - //custom_warning: &'a str, } // Processing the `body` called by cgit. @@ -240,7 +239,6 @@ async fn cmd_body(matches: &ArgMatches<'_>, _cfg: Config) { let meta = Meta { action: matches.value_of("login-url").unwrap_or(""), redirect: matches.value_of("current-url").unwrap_or(""), - //custom_warning: cfg.get_secret_warning() }; handlebars .render_template_to_write(source, &meta, std::io::stdout()) |