This repository has been archived by the owner on Mar 2, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Boris Rybalkin <[email protected]>
- Loading branch information
Showing
8 changed files
with
959 additions
and
21 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Pi-hole: A black hole for Internet advertisements | ||
// (c) 2019 Pi-hole, LLC (https://pi-hole.net) | ||
// Network-wide ad blocking via your own hardware. | ||
// | ||
// API | ||
// LDAP Config | ||
// | ||
// This file is copyright under the latest version of the EUPL. | ||
// Please see LICENSE file for your rights under this license. | ||
|
||
/// Configuration settings for LDAP authentication | ||
#[derive(Deserialize, Clone)] | ||
pub struct LdapConfig { | ||
/// If LDAP should be enabled | ||
#[serde(default = "default_enabled")] | ||
pub enabled: bool, | ||
|
||
/// LDAP server address | ||
#[serde(default = "default_address")] | ||
pub address: String, | ||
|
||
/// Bind Dn | ||
#[serde(default = "default_bind_dn")] | ||
pub bind_dn: String | ||
} | ||
|
||
impl Default for LdapConfig { | ||
fn default() -> Self { | ||
LdapConfig { | ||
enabled: default_enabled(), | ||
address: default_address(), | ||
bind_dn: default_bind_dn() | ||
} | ||
} | ||
} | ||
|
||
impl LdapConfig { | ||
pub fn is_valid(&self) -> bool { | ||
true | ||
} | ||
} | ||
|
||
fn default_enabled() -> bool { | ||
false | ||
} | ||
|
||
fn default_address() -> String { | ||
"ldap://localhost:389".to_owned() | ||
} | ||
|
||
fn default_bind_dn() -> String { | ||
"".to_owned() | ||
} | ||
|
||
#[cfg(test)] | ||
mod test { | ||
use super::LdapConfig; | ||
|
||
/// The default config is valid | ||
#[test] | ||
fn valid_ldap() { | ||
let ldap_config = LdapConfig::default(); | ||
|
||
assert!(ldap_config.is_valid()) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,5 +12,6 @@ mod file_locations; | |
mod general; | ||
mod root_config; | ||
mod web; | ||
mod ldap; | ||
|
||
pub use self::root_config::Config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters