aboutsummaryrefslogtreecommitdiff
path: root/src/login/static_provider.rs
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2022-06-03 14:00:19 +0200
committerQuentin Dufour <quentin@deuxfleurs.fr>2022-06-03 14:00:19 +0200
commit43f443c7a85e5172b5c1a6a69db775659214196d (patch)
tree6b6fd650094606f57cc05b1e10ac99fd3a772207 /src/login/static_provider.rs
parent8f3a34da33bf386c048790615ec1f63e89d22f6b (diff)
downloadaerogramme-43f443c7a85e5172b5c1a6a69db775659214196d.tar.gz
aerogramme-43f443c7a85e5172b5c1a6a69db775659214196d.zip
WIP login
Diffstat (limited to 'src/login/static_provider.rs')
-rw-r--r--src/login/static_provider.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/login/static_provider.rs b/src/login/static_provider.rs
index cc6ffb6..a95ab24 100644
--- a/src/login/static_provider.rs
+++ b/src/login/static_provider.rs
@@ -29,12 +29,15 @@ impl StaticLoginProvider {
#[async_trait]
impl LoginProvider for StaticLoginProvider {
async fn login(&self, username: &str, password: &str) -> Result<Credentials> {
+ tracing::debug!(user=%username, "login");
match self.users.get(username) {
None => bail!("User {} does not exist", username),
Some(u) => {
+ tracing::debug!(user=%username, "verify password");
if !verify_password(password, &u.password)? {
bail!("Wrong password");
}
+ tracing::debug!(user=%username, "fetch bucket");
let bucket = u
.bucket
.clone()
@@ -43,6 +46,7 @@ impl LoginProvider for StaticLoginProvider {
"No bucket configured and no default bucket specieid"
))?;
+ tracing::debug!(user=%username, "fetch configuration");
let storage = StorageCredentials {
k2v_region: self.k2v_region.clone(),
s3_region: self.s3_region.clone(),
@@ -51,6 +55,7 @@ impl LoginProvider for StaticLoginProvider {
bucket,
};
+ tracing::debug!(user=%username, "fetch keys");
let keys = match (&u.master_key, &u.secret_key) {
(Some(m), Some(s)) => {
let master_key = Key::from_slice(&base64::decode(m)?)
@@ -69,6 +74,7 @@ impl LoginProvider for StaticLoginProvider {
_ => bail!("Either both master and secret key or none of them must be specified for user"),
};
+ tracing::debug!(user=%username, "logged");
Ok(Credentials { storage, keys })
}
}