crud_auth/lib.rs
1//! ## Crud auth trait
2//!
3//! Authentification trait crate for [crud-api](../crud-api).
4//!
5
6use async_trait::async_trait;
7use clap::{ArgMatches, Command};
8use config::Config;
9
10/// Authification module for Crud.
11/// Import an implementation of this trait to manage authification.
12/// TODO: Add some examples
13#[async_trait]
14pub trait CrudAuth {
15 /// Create the arguments for the CLI.
16 /// For examples, it can create the `--login`, `--password` arguments.
17 fn clap_auth(&self, app: Command) -> Command;
18
19 /// Process the arguments created by [clap_auth] function.
20 fn clap_matches(&mut self, args: &ArgMatches, app: &mut Command, settings: &Config);
21
22 /// Create an authentification header as a pair (_name_,_valeur_)
23 fn auth_header(&self) -> (String, String);
24
25 /// The helpmessage displayed when the user is unauthorized.
26 fn error_help_message(&self) -> String;
27}
28
29#[cfg(test)]
30mod tests {
31 #[test]
32 fn it_works() {
33 let result = 2 + 2;
34 assert_eq!(result, 4);
35 }
36}