From de5fa9f9ceb2f8a30b302d3b69957bbdaf1b645c Mon Sep 17 00:00:00 2001 From: Ximon Eighteen <3304436+ximon18@users.noreply.github.com> Date: Wed, 30 Dec 2020 15:13:05 +0100 Subject: [PATCH] Clippy goodness. --- src/daemon/auth/authorizer.rs | 4 ++-- src/daemon/auth/common/session.rs | 1 - src/daemon/auth/providers/config_file/provider.rs | 6 +++--- src/daemon/auth/providers/openid_connect/provider.rs | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/daemon/auth/authorizer.rs b/src/daemon/auth/authorizer.rs index 7f301a63..8e62fc93 100644 --- a/src/daemon/auth/authorizer.rs +++ b/src/daemon/auth/authorizer.rs @@ -168,7 +168,7 @@ impl Authorizer { /// Submit credentials directly to the configured provider to establish a /// login session, if supported by the configured provider. pub fn login(&self, request: &hyper::Request) -> KrillResult { - self.primary_provider.login(request).and_then(|user| { + self.primary_provider.login(request).map(|user| { let visible_attributes = user .attributes .clone() @@ -188,7 +188,7 @@ impl Authorizer { info!("User logged in: {}", &user.id); } - Ok(user) + user }) } diff --git a/src/daemon/auth/common/session.rs b/src/daemon/auth/common/session.rs index c590e030..562ea042 100644 --- a/src/daemon/auth/common/session.rs +++ b/src/daemon/auth/common/session.rs @@ -1,6 +1,5 @@ use std::{ collections::HashMap, - io, sync::RwLock, time::{Duration, SystemTime, UNIX_EPOCH}, }; diff --git a/src/daemon/auth/providers/config_file/provider.rs b/src/daemon/auth/providers/config_file/provider.rs index f462e328..23c0d058 100644 --- a/src/daemon/auth/providers/config_file/provider.rs +++ b/src/daemon/auth/providers/config_file/provider.rs @@ -92,7 +92,7 @@ impl AuthProvider for ConfigFileAuthProvider { Some(token) => { // see if we can decode, decrypt and deserialize the users token // into a login session structure - let session = self.session_cache.decode(token.clone(), &self.key)?; + let session = self.session_cache.decode(token, &self.key)?; trace!("id={}, attributes={:?}", &session.id, &session.attributes); @@ -113,11 +113,11 @@ impl AuthProvider for ConfigFileAuthProvider { if user.password_hash == password_hash { let api_token = self.session_cache.encode(&id, &user.attributes, &[], &self.key, None)?; - return Ok(LoggedInUser { + Ok(LoggedInUser { token: api_token, id: id.to_string(), attributes: user.attributes.clone(), - }); + }) } else { Err(Error::ApiInvalidCredentials("Incorrect password".to_string())) } diff --git a/src/daemon/auth/providers/openid_connect/provider.rs b/src/daemon/auth/providers/openid_connect/provider.rs index 0477ee0c..bc1c2447 100644 --- a/src/daemon/auth/providers/openid_connect/provider.rs +++ b/src/daemon/auth/providers/openid_connect/provider.rs @@ -483,7 +483,7 @@ impl AuthProvider for OpenIDConnectAuthProvider { Some(token) => { // see if we can decode, decrypt and deserialize the users token // into a login session structure - let session = self.session_cache.decode(token.clone(), &self.session_key)?; + let session = self.session_cache.decode(token, &self.session_key)?; let status = session.status();