feat: added verification for the ssh keys #42
3 changed files with 9 additions and 2 deletions
|
@ -56,6 +56,7 @@
|
|||
DATABASE = "database.db";
|
||||
CSV = "wolves.csv";
|
||||
HOST_PORT = cfg.host_port;
|
||||
SSH_ROOT = "/skynet_old/home";
|
||||
|
||||
# Email stuff
|
||||
EMAIL_SMTP = cfg.mail.host;
|
||||
|
|
|
@ -188,6 +188,7 @@ pub struct Config {
|
|||
pub mail_smtp: String,
|
||||
pub mail_user: String,
|
||||
pub mail_pass: String,
|
||||
pub ssh_root: String,
|
||||
}
|
||||
|
||||
pub fn get_config() -> Config {
|
||||
|
@ -205,6 +206,7 @@ pub fn get_config() -> Config {
|
|||
mail_smtp: "".to_string(),
|
||||
mail_user: "".to_string(),
|
||||
mail_pass: "".to_string(),
|
||||
ssh_root: "/skynet_old/home".to_string(),
|
||||
};
|
||||
|
||||
if let Ok(x) = env::var("LDAP_HOST") {
|
||||
|
@ -237,6 +239,9 @@ pub fn get_config() -> Config {
|
|||
if let Ok(x) = env::var("EMAIL_PASS") {
|
||||
config.mail_pass = x.trim().to_string();
|
||||
}
|
||||
if let Ok(x) = env::var("SSH_ROOT") {
|
||||
config.ssh_root = x.trim().to_string();
|
||||
}
|
||||
|
||||
config
|
||||
}
|
||||
|
|
|
@ -458,9 +458,10 @@ pub mod ssh {
|
|||
return Ok(json!({"result": "error", "error": "Skynet email not permitted."}).into());
|
||||
}
|
||||
|
||||
let config = &req.state().config;
|
||||
|
||||
// check if <root>/<user>/.ssh/authorized_keys exists
|
||||
//let root = "/skynet_old";
|
||||
let root = ".";
|
||||
let root = &config.ssh_root;
|
||||
let path = format!("{}/{}/.ssh/authorized_keys", root, user);
|
||||
let mut keys = vec![];
|
||||
if fs::read_to_string(&path).is_ok() {
|
||||
|
|
Loading…
Reference in a new issue