Skip to content

Md5 auth #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Md5 auth #55

wants to merge 1 commit into from

Conversation

Svennisen
Copy link
Collaborator

Left to figure out:
Whats the right format to store user:pw in userlist?
hashmap errors?
actually do hash comparison

Left to figure out:
Whats the right format to store user:pw in userlist?
hashmap errors?
actually do hash:x comparison
md5.update(salt.to_be_bytes().to_vec());


let password_string: String = String::from_utf8(password_hash).expect("Could not get password hash");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a panic, return an error instead.

Copy link
Contributor

@levkk levkk Mar 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better yet, use String::from_utf8_lossy which always returns successfully.

}
};

let map: HashMap<String, String> = serde_json::from_str(&contents).expect("JSON was not well-formatted");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a panic, return an error instead.

@@ -94,6 +95,15 @@ async fn main() {
}
};

// Prepare user list
match userlist::parse("userlist.json").await {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can make this typed. Checkout the example in config.rs where we used TOML. The structure of the config file can be typed with a struct, so when you parse it you can detect errors & also you won't have to check for them when you use the config elsewhere in the code.

@levkk
Copy link
Contributor

levkk commented Jun 20, 2022

Implemented in #77

@levkk levkk closed this Jun 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants