This commit is contained in:
Eugene Pankov 2022-07-23 21:47:04 +02:00
parent 47518c6253
commit d6fba30573
No known key found for this signature in database
GPG key ID: 5896FCBBDD1CF4F4
8 changed files with 12 additions and 7 deletions

View file

@ -192,7 +192,7 @@ pub enum UserAuthCredential {
#[serde(rename = "publickey")]
PublicKey { key: Secret<String> },
#[serde(rename = "otp")]
TOTP {
Totp {
#[serde(with = "crate::helpers::serde_base64_secret")]
key: OtpSecretKey,
},

View file

@ -39,7 +39,7 @@ fn credential_is_type(c: &UserAuthCredential, k: &str) -> bool {
match c {
UserAuthCredential::Password { .. } => k == "password",
UserAuthCredential::PublicKey { .. } => k == "publickey",
UserAuthCredential::TOTP { .. } => k == "otp",
UserAuthCredential::Totp { .. } => k == "otp",
}
}
@ -143,7 +143,7 @@ impl ConfigProvider for FileConfigProvider {
}
AuthCredential::Otp(client_otp) => {
match user.credentials.iter().find(|credential| match credential {
UserAuthCredential::TOTP {
UserAuthCredential::Totp {
key: ref user_otp_key,
} => verify_totp(client_otp.expose_secret(), user_otp_key),
_ => false,

View file

@ -26,6 +26,7 @@ macro_rules! try_block {
}
#[test]
#[allow(clippy::assertions_on_constants)]
fn test_catch() {
let mut caught = false;
try_block!({
@ -39,6 +40,7 @@ fn test_catch() {
}
#[test]
#[allow(clippy::assertions_on_constants)]
fn test_success() {
try_block!({
let _: u32 = "123".parse()?;

View file

@ -98,6 +98,7 @@ fn construct_uri(req: &Request, options: &TargetHTTPOptions, websocket: bool) ->
let scheme = target_uri.scheme().context("No scheme in the URL")?;
uri = uri.scheme(scheme.clone());
#[allow(clippy::unwrap_used)]
if websocket {
uri = uri.scheme(
Scheme::from_str(if scheme == &Scheme::from_str("http").unwrap() {

View file

@ -45,7 +45,7 @@ pub enum ConnectionError {
Key(#[from] russh_keys::Error),
#[error(transparent)]
SSH(#[from] russh::Error),
Ssh(#[from] russh::Error),
#[error("Could not resolve address")]
Resolve,
@ -377,7 +377,7 @@ impl RemoteClient {
Err(error) => {
let connection_error = match error {
ClientHandlerError::ConnectionError(e) => e,
ClientHandlerError::Ssh(e) => ConnectionError::SSH(e),
ClientHandlerError::Ssh(e) => ConnectionError::Ssh(e),
ClientHandlerError::Internal => ConnectionError::Internal,
};
error!(error=?connection_error, "Connection error");
@ -396,6 +396,7 @@ impl RemoteClient {
}
}
SSHTargetAuth::PublicKey => {
#[allow(clippy::explicit_auto_deref)]
let keys = load_client_keys(&*self.services.config.lock().await)?;
for key in keys.into_iter() {
let key_str = key.as_openssh();

View file

@ -815,7 +815,7 @@ impl ServerSession {
pub async fn _data(&mut self, server_channel_id: ServerChannelId, data: Bytes) -> Result<()> {
let channel_id = self.map_channel(&server_channel_id)?;
debug!(channel=%server_channel_id.0, ?data, "Data");
if self.rc_state == RCState::Connecting && data.get(0) == Some(&3) {
if self.rc_state == RCState::Connecting && data.first() == Some(&3) {
info!(channel=%channel_id, "User requested connection abort (Ctrl-C)");
self.request_disconnect().await;
return Ok(());

View file

@ -53,6 +53,7 @@ pub(crate) async fn command(cli: &crate::Cli) -> Result<()> {
loop {
let retention = { services.config.lock().await.store.log.retention };
let interval = retention / 10;
#[allow(clippy::explicit_auto_deref)]
match cleanup_db(&mut *services.db.lock().await, &retention).await {
Err(error) => error!(?error, "Failed to cleanup the database"),
Ok(_) => debug!("Database cleaned up, next in {:?}", interval),

View file

@ -246,7 +246,7 @@ pub(crate) async fn command(cli: &crate::Cli) -> Result<()> {
} else {
info!(
" {} --config {} run",
std::env::args().next().unwrap(),
std::env::args().next().unwrap_or_else(|| "warpgate".to_string()),
cli.config.display()
);
}