lint, removed lazy_static

This commit is contained in:
Eugene Pankov 2022-11-03 23:44:51 +01:00
parent 42f9c68788
commit 2b7baac016
No known key found for this signature in database
GPG key ID: 5896FCBBDD1CF4F4
8 changed files with 26 additions and 28 deletions

4
Cargo.lock generated
View file

@ -4783,7 +4783,6 @@ dependencies = [
"delegate", "delegate",
"futures", "futures",
"humantime-serde", "humantime-serde",
"lazy_static",
"once_cell", "once_cell",
"password-hash 0.4.1", "password-hash 0.4.1",
"poem", "poem",
@ -4819,7 +4818,6 @@ dependencies = [
"data-encoding", "data-encoding",
"futures", "futures",
"humantime-serde", "humantime-serde",
"lazy_static",
"once_cell", "once_cell",
"packet", "packet",
"password-hash 0.4.1", "password-hash 0.4.1",
@ -4898,7 +4896,7 @@ dependencies = [
"delegate", "delegate",
"futures", "futures",
"http", "http",
"lazy_static", "once_cell",
"percent-encoding", "percent-encoding",
"poem", "poem",
"poem-openapi", "poem-openapi",

View file

@ -159,8 +159,8 @@ impl DetailApi {
let mut credentials = body.credentials.clone(); let mut credentials = body.credentials.clone();
for credential in credentials.iter_mut() { for credential in credentials.iter_mut() {
if let UserAuthCredential::Password(ref mut c) = credential { if let UserAuthCredential::Password(ref mut c) = credential {
if parse_hash(&c.hash.expose_secret()).is_err() { if parse_hash(c.hash.expose_secret()).is_err() {
c.hash = hash_password(&c.hash.expose_secret()).into(); c.hash = hash_password(c.hash.expose_secret()).into();
} }
} }
} }

View file

@ -13,7 +13,6 @@ chrono = { version = "0.4", features = ["serde"] }
data-encoding = "2.3" data-encoding = "2.3"
delegate = "0.6" delegate = "0.6"
humantime-serde = "1.1" humantime-serde = "1.1"
lazy_static = "1.4"
futures = "0.3" futures = "0.3"
once_cell = "1.14" once_cell = "1.14"
password-hash = "0.4" password-hash = "0.4"

View file

@ -16,7 +16,6 @@ bytes = "1.2"
chrono = { version = "0.4", features = ["serde"] } chrono = { version = "0.4", features = ["serde"] }
data-encoding = "2.3" data-encoding = "2.3"
humantime-serde = "1.1" humantime-serde = "1.1"
lazy_static = "1.4"
futures = "0.3" futures = "0.3"
once_cell = "1.14" once_cell = "1.14"
packet = "0.1" packet = "0.1"

View file

@ -13,7 +13,7 @@ data-encoding = "2.3"
delegate = "0.6" delegate = "0.6"
futures = "0.3" futures = "0.3"
http = "0.2" http = "0.2"
lazy_static = "1.4" once_cell = "1.14"
poem = { version = "^1.3.42", features = [ poem = { version = "^1.3.42", features = [
"cookie", "cookie",
"session", "session",

View file

@ -9,6 +9,7 @@ use futures::{SinkExt, StreamExt};
use http::header::HeaderName; use http::header::HeaderName;
use http::uri::{Authority, Scheme}; use http::uri::{Authority, Scheme};
use http::Uri; use http::Uri;
use once_cell::sync::Lazy;
use poem::web::websocket::{CloseCode, Message, WebSocket}; use poem::web::websocket::{CloseCode, Message, WebSocket};
use poem::{Body, IntoResponse, Request, Response}; use poem::{Body, IntoResponse, Request, Response};
use tokio_tungstenite::{connect_async_with_config, tungstenite}; use tokio_tungstenite::{connect_async_with_config, tungstenite};
@ -61,24 +62,21 @@ impl SomeRequestBuilder for http::request::Builder {
} }
} }
lazy_static::lazy_static! { static DONT_FORWARD_HEADERS: Lazy<HashSet<HeaderName>> = Lazy::new(|| {
#[allow(clippy::mutable_key_type)] #[allow(clippy::mutable_key_type)]
static ref DONT_FORWARD_HEADERS: HashSet<HeaderName> = { let mut s = HashSet::new();
#[allow(clippy::mutable_key_type)] s.insert(http::header::ACCEPT_ENCODING);
let mut s = HashSet::new(); s.insert(http::header::SEC_WEBSOCKET_EXTENSIONS);
s.insert(http::header::ACCEPT_ENCODING); s.insert(http::header::SEC_WEBSOCKET_ACCEPT);
s.insert(http::header::SEC_WEBSOCKET_EXTENSIONS); s.insert(http::header::SEC_WEBSOCKET_KEY);
s.insert(http::header::SEC_WEBSOCKET_ACCEPT); s.insert(http::header::SEC_WEBSOCKET_VERSION);
s.insert(http::header::SEC_WEBSOCKET_KEY); s.insert(http::header::UPGRADE);
s.insert(http::header::SEC_WEBSOCKET_VERSION); s.insert(http::header::HOST);
s.insert(http::header::UPGRADE); s.insert(http::header::CONNECTION);
s.insert(http::header::HOST); s.insert(http::header::STRICT_TRANSPORT_SECURITY);
s.insert(http::header::CONNECTION); s.insert(http::header::UPGRADE_INSECURE_REQUESTS);
s.insert(http::header::STRICT_TRANSPORT_SECURITY); s
s.insert(http::header::UPGRADE_INSECURE_REQUESTS); });
s
};
}
static X_FORWARDED_FOR: HeaderName = HeaderName::from_static("x-forwarded-for"); static X_FORWARDED_FOR: HeaderName = HeaderName::from_static("x-forwarded-for");
static X_FORWARDED_HOST: HeaderName = HeaderName::from_static("x-forwarded-host"); static X_FORWARDED_HOST: HeaderName = HeaderName::from_static("x-forwarded-host");
@ -451,7 +449,7 @@ async fn proxy_ws_inner(
.send(Message::Close(data.map(|data| { .send(Message::Close(data.map(|data| {
( (
CloseCode::from(data.code), CloseCode::from(data.code),
data.reason.to_owned().to_string(), data.reason.into_owned().to_string(),
) )
}))) })))
.await?; .await?;

View file

@ -36,7 +36,9 @@ pub(crate) async fn command(cli: &crate::Cli, username: &Option<String>) -> Resu
.iter_mut() .iter_mut()
.find(|x| &x.username == username) .find(|x| &x.username == username)
.ok_or_else(|| anyhow::anyhow!("User not found"))?, .ok_or_else(|| anyhow::anyhow!("User not found"))?,
None => { None =>
{
#[allow(clippy::indexing_slicing)]
&mut users[dialoguer::Select::with_theme(&theme) &mut users[dialoguer::Select::with_theme(&theme)
.with_prompt("Select a user to recover access for") .with_prompt("Select a user to recover access for")
.items(&usernames) .items(&usernames)
@ -61,7 +63,7 @@ pub(crate) async fn command(cli: &crate::Cli, username: &Option<String>) -> Resu
hash: Secret::new(hash_password(&password)), hash: Secret::new(hash_password(&password)),
})); }));
user.credential_policy user.credential_policy
.get_or_insert_with(|| Default::default()) .get_or_insert_with(Default::default)
.http = Some(vec![CredentialKind::Password]); .http = Some(vec![CredentialKind::Password]);
let model = User::ActiveModel { let model = User::ActiveModel {

View file

@ -1,3 +1,5 @@
#![allow(clippy::collapsible_else_if)]
use std::fs::{create_dir_all, File}; use std::fs::{create_dir_all, File};
use std::io::Write; use std::io::Write;
use std::net::{SocketAddr, ToSocketAddrs}; use std::net::{SocketAddr, ToSocketAddrs};