From fb801c95d418dcf67c082b9a96317ccde8a4086f Mon Sep 17 00:00:00 2001 From: BlackDex Date: Fri, 19 Nov 2021 17:50:16 +0100 Subject: [PATCH] Upd Dockerfiles, crates. Fixed rust 2018 idioms - Updated crates - Fixed Dockerfiles to build using the rust stable version - Enabled warnings for rust 2018 idioms and fixed them. --- Cargo.lock | 20 ++++++++++---------- Cargo.toml | 4 ++-- docker/Dockerfile.j2 | 9 ++++++--- docker/amd64/Dockerfile | 7 +++++-- docker/amd64/Dockerfile.alpine | 7 +++++-- docker/amd64/Dockerfile.buildx | 7 +++++-- docker/amd64/Dockerfile.buildx.alpine | 7 +++++-- docker/arm64/Dockerfile | 7 +++++-- docker/arm64/Dockerfile.buildx | 7 +++++-- docker/armv6/Dockerfile | 7 +++++-- docker/armv6/Dockerfile.buildx | 7 +++++-- docker/armv7/Dockerfile | 7 +++++-- docker/armv7/Dockerfile.alpine | 5 ++++- docker/armv7/Dockerfile.buildx | 7 +++++-- docker/armv7/Dockerfile.buildx.alpine | 5 ++++- src/api/admin.rs | 6 +++--- src/auth.rs | 6 +++--- src/config.rs | 4 ++-- src/error.rs | 6 +++--- src/main.rs | 3 +-- src/util.rs | 8 ++++---- 21 files changed, 92 insertions(+), 54 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 30baef4e..f9f4f9d1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -882,9 +882,9 @@ checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" [[package]] name = "handlebars" -version = "4.1.4" +version = "4.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1874024f4a29f47d609014caec0b1c866f1c1eb0661a09c9733ecc4757f5f88" +checksum = "8ad84da8f63da982543fc85fcabaee2ad1fdd809d99d64a48887e2e942ddfe46" dependencies = [ "log", "pest", @@ -985,15 +985,15 @@ checksum = "acd94fdbe1d4ff688b67b04eee2e17bd50995534a61539e45adfefb45e5e5503" [[package]] name = "httpdate" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6456b8a6c8f33fee7d958fcd1b60d55b11940a79e63ae87013e6d22e26034440" +checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" [[package]] name = "hyper" -version = "0.14.14" +version = "0.14.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b91bb1f221b6ea1f1e4371216b70f40748774c2fb5971b450c07773fb92d26b" +checksum = "436ec0091e4f20e655156a30a0df3770fe2900aa301e548e08446ec794b6953c" dependencies = [ "bytes 1.1.0", "futures-channel", @@ -1625,9 +1625,9 @@ dependencies = [ [[package]] name = "openssl-sys" -version = "0.9.70" +version = "0.9.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6517987b3f8226b5da3661dad65ff7f300cc59fb5ea8333ca191fc65fde3edf" +checksum = "7df13d165e607909b363a4757a6f133f8a818a74e9d3a98d09c6128e15fa4c73" dependencies = [ "autocfg", "cc", @@ -2538,9 +2538,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.70" +version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e277c495ac6cd1a01a58d0a0c574568b4d1ddf14f59965c6a58b8d96400b54f3" +checksum = "063bf466a64011ac24040a49009724ee60a57da1b437617ceb32e53ad61bfb19" dependencies = [ "itoa", "ryu", diff --git a/Cargo.toml b/Cargo.toml index 6530d1f6..e3def32b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -57,7 +57,7 @@ chashmap = "2.2.2" # A generic serialization/deserialization framework serde = { version = "1.0.130", features = ["derive"] } -serde_json = "1.0.70" +serde_json = "1.0.71" # Logging log = "0.4.14" @@ -116,7 +116,7 @@ tracing = { version = "0.1.29", features = ["log"] } # Needed to have lettre tra lettre = { version = "0.10.0-rc.4", features = ["smtp-transport", "builder", "serde", "native-tls", "hostname", "tracing"], default-features = false } # Template library -handlebars = { version = "4.1.4", features = ["dir_source"] } +handlebars = { version = "4.1.5", features = ["dir_source"] } # For favicon extraction from main website html5ever = "0.25.1" diff --git a/docker/Dockerfile.j2 b/docker/Dockerfile.j2 index ff9ed1af..00b624df 100644 --- a/docker/Dockerfile.j2 +++ b/docker/Dockerfile.j2 @@ -3,10 +3,10 @@ # This file was generated using a Jinja2 template. # Please make your changes in `Dockerfile.j2` and then `make` the individual Dockerfiles. -{% set build_stage_base_image = "rust:1.55-buster" %} +{% set build_stage_base_image = "rust:1.56-buster" %} {% if "alpine" in target_file %} {% if "amd64" in target_file %} -{% set build_stage_base_image = "clux/muslrust:nightly-2021-10-23" %} +{% set build_stage_base_image = "clux/muslrust:stable" %} {% set runtime_stage_base_image = "alpine:3.14" %} {% set package_arch_target = "x86_64-unknown-linux-musl" %} {% elif "armv7" in target_file %} @@ -268,7 +268,6 @@ EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage WORKDIR / -COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault {% if package_arch_target is defined %} COPY --from=build /app/target/{{ package_arch_target }}/release/vaultwarden . @@ -282,5 +281,9 @@ COPY docker/start.sh /start.sh HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"] # Configures the startup! +# We should be able to remove the dumb-init now with Rocket 0.5 +# But the balenalib images have some issues with there entry.sh +# See: https://github.com/balena-io-library/base-images/issues/735 +# Lets keep using dumb-init for now, since that is working fine. ENTRYPOINT ["/usr/bin/dumb-init", "--"] CMD ["/start.sh"] diff --git a/docker/amd64/Dockerfile b/docker/amd64/Dockerfile index 8ec84d8c..aa28f19e 100644 --- a/docker/amd64/Dockerfile +++ b/docker/amd64/Dockerfile @@ -27,7 +27,7 @@ FROM vaultwarden/web-vault@sha256:0e8daf80abb73ebca69d1971847450d24da45a74a525fd643246ee1dfa02108b as vault ########################## BUILD IMAGE ########################## -FROM rust:1.55-buster as build +FROM rust:1.56-buster as build # Debian-based builds support multidb ARG DB=sqlite,mysql,postgresql @@ -112,7 +112,6 @@ EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage WORKDIR / -COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/release/vaultwarden . @@ -122,5 +121,9 @@ COPY docker/start.sh /start.sh HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"] # Configures the startup! +# We should be able to remove the dumb-init now with Rocket 0.5 +# But the balenalib images have some issues with there entry.sh +# See: https://github.com/balena-io-library/base-images/issues/735 +# Lets keep using dumb-init for now, since that is working fine. ENTRYPOINT ["/usr/bin/dumb-init", "--"] CMD ["/start.sh"] diff --git a/docker/amd64/Dockerfile.alpine b/docker/amd64/Dockerfile.alpine index 974600e0..41dcce17 100644 --- a/docker/amd64/Dockerfile.alpine +++ b/docker/amd64/Dockerfile.alpine @@ -27,7 +27,7 @@ FROM vaultwarden/web-vault@sha256:0e8daf80abb73ebca69d1971847450d24da45a74a525fd643246ee1dfa02108b as vault ########################## BUILD IMAGE ########################## -FROM clux/muslrust:nightly-2021-10-23 as build +FROM clux/muslrust:stable as build # Alpine-based AMD64 (musl) does not support mysql/mariadb during compile time. ARG DB=sqlite,postgresql @@ -104,7 +104,6 @@ EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage WORKDIR / -COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/x86_64-unknown-linux-musl/release/vaultwarden . @@ -114,5 +113,9 @@ COPY docker/start.sh /start.sh HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"] # Configures the startup! +# We should be able to remove the dumb-init now with Rocket 0.5 +# But the balenalib images have some issues with there entry.sh +# See: https://github.com/balena-io-library/base-images/issues/735 +# Lets keep using dumb-init for now, since that is working fine. ENTRYPOINT ["/usr/bin/dumb-init", "--"] CMD ["/start.sh"] diff --git a/docker/amd64/Dockerfile.buildx b/docker/amd64/Dockerfile.buildx index 62a036b0..af42b76c 100644 --- a/docker/amd64/Dockerfile.buildx +++ b/docker/amd64/Dockerfile.buildx @@ -27,7 +27,7 @@ FROM vaultwarden/web-vault@sha256:0e8daf80abb73ebca69d1971847450d24da45a74a525fd643246ee1dfa02108b as vault ########################## BUILD IMAGE ########################## -FROM rust:1.55-buster as build +FROM rust:1.56-buster as build # Debian-based builds support multidb ARG DB=sqlite,mysql,postgresql @@ -112,7 +112,6 @@ EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage WORKDIR / -COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/release/vaultwarden . @@ -122,5 +121,9 @@ COPY docker/start.sh /start.sh HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"] # Configures the startup! +# We should be able to remove the dumb-init now with Rocket 0.5 +# But the balenalib images have some issues with there entry.sh +# See: https://github.com/balena-io-library/base-images/issues/735 +# Lets keep using dumb-init for now, since that is working fine. ENTRYPOINT ["/usr/bin/dumb-init", "--"] CMD ["/start.sh"] diff --git a/docker/amd64/Dockerfile.buildx.alpine b/docker/amd64/Dockerfile.buildx.alpine index 60dc2518..db865329 100644 --- a/docker/amd64/Dockerfile.buildx.alpine +++ b/docker/amd64/Dockerfile.buildx.alpine @@ -27,7 +27,7 @@ FROM vaultwarden/web-vault@sha256:0e8daf80abb73ebca69d1971847450d24da45a74a525fd643246ee1dfa02108b as vault ########################## BUILD IMAGE ########################## -FROM clux/muslrust:nightly-2021-10-23 as build +FROM clux/muslrust:stable as build # Alpine-based AMD64 (musl) does not support mysql/mariadb during compile time. ARG DB=sqlite,postgresql @@ -104,7 +104,6 @@ EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage WORKDIR / -COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/x86_64-unknown-linux-musl/release/vaultwarden . @@ -114,5 +113,9 @@ COPY docker/start.sh /start.sh HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"] # Configures the startup! +# We should be able to remove the dumb-init now with Rocket 0.5 +# But the balenalib images have some issues with there entry.sh +# See: https://github.com/balena-io-library/base-images/issues/735 +# Lets keep using dumb-init for now, since that is working fine. ENTRYPOINT ["/usr/bin/dumb-init", "--"] CMD ["/start.sh"] diff --git a/docker/arm64/Dockerfile b/docker/arm64/Dockerfile index 4357e59f..0c38e5ce 100644 --- a/docker/arm64/Dockerfile +++ b/docker/arm64/Dockerfile @@ -27,7 +27,7 @@ FROM vaultwarden/web-vault@sha256:0e8daf80abb73ebca69d1971847450d24da45a74a525fd643246ee1dfa02108b as vault ########################## BUILD IMAGE ########################## -FROM rust:1.55-buster as build +FROM rust:1.56-buster as build # Debian-based builds support multidb ARG DB=sqlite,mysql,postgresql @@ -155,7 +155,6 @@ EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage WORKDIR / -COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/aarch64-unknown-linux-gnu/release/vaultwarden . @@ -165,5 +164,9 @@ COPY docker/start.sh /start.sh HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"] # Configures the startup! +# We should be able to remove the dumb-init now with Rocket 0.5 +# But the balenalib images have some issues with there entry.sh +# See: https://github.com/balena-io-library/base-images/issues/735 +# Lets keep using dumb-init for now, since that is working fine. ENTRYPOINT ["/usr/bin/dumb-init", "--"] CMD ["/start.sh"] diff --git a/docker/arm64/Dockerfile.buildx b/docker/arm64/Dockerfile.buildx index e1aeb59c..df9a44a2 100644 --- a/docker/arm64/Dockerfile.buildx +++ b/docker/arm64/Dockerfile.buildx @@ -27,7 +27,7 @@ FROM vaultwarden/web-vault@sha256:0e8daf80abb73ebca69d1971847450d24da45a74a525fd643246ee1dfa02108b as vault ########################## BUILD IMAGE ########################## -FROM rust:1.55-buster as build +FROM rust:1.56-buster as build # Debian-based builds support multidb ARG DB=sqlite,mysql,postgresql @@ -155,7 +155,6 @@ EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage WORKDIR / -COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/aarch64-unknown-linux-gnu/release/vaultwarden . @@ -165,5 +164,9 @@ COPY docker/start.sh /start.sh HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"] # Configures the startup! +# We should be able to remove the dumb-init now with Rocket 0.5 +# But the balenalib images have some issues with there entry.sh +# See: https://github.com/balena-io-library/base-images/issues/735 +# Lets keep using dumb-init for now, since that is working fine. ENTRYPOINT ["/usr/bin/dumb-init", "--"] CMD ["/start.sh"] diff --git a/docker/armv6/Dockerfile b/docker/armv6/Dockerfile index 4062062d..5a524295 100644 --- a/docker/armv6/Dockerfile +++ b/docker/armv6/Dockerfile @@ -27,7 +27,7 @@ FROM vaultwarden/web-vault@sha256:0e8daf80abb73ebca69d1971847450d24da45a74a525fd643246ee1dfa02108b as vault ########################## BUILD IMAGE ########################## -FROM rust:1.55-buster as build +FROM rust:1.56-buster as build # Debian-based builds support multidb ARG DB=sqlite,mysql,postgresql @@ -155,7 +155,6 @@ EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage WORKDIR / -COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/arm-unknown-linux-gnueabi/release/vaultwarden . @@ -165,5 +164,9 @@ COPY docker/start.sh /start.sh HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"] # Configures the startup! +# We should be able to remove the dumb-init now with Rocket 0.5 +# But the balenalib images have some issues with there entry.sh +# See: https://github.com/balena-io-library/base-images/issues/735 +# Lets keep using dumb-init for now, since that is working fine. ENTRYPOINT ["/usr/bin/dumb-init", "--"] CMD ["/start.sh"] diff --git a/docker/armv6/Dockerfile.buildx b/docker/armv6/Dockerfile.buildx index 6c672455..136fc429 100644 --- a/docker/armv6/Dockerfile.buildx +++ b/docker/armv6/Dockerfile.buildx @@ -27,7 +27,7 @@ FROM vaultwarden/web-vault@sha256:0e8daf80abb73ebca69d1971847450d24da45a74a525fd643246ee1dfa02108b as vault ########################## BUILD IMAGE ########################## -FROM rust:1.55-buster as build +FROM rust:1.56-buster as build # Debian-based builds support multidb ARG DB=sqlite,mysql,postgresql @@ -155,7 +155,6 @@ EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage WORKDIR / -COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/arm-unknown-linux-gnueabi/release/vaultwarden . @@ -165,5 +164,9 @@ COPY docker/start.sh /start.sh HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"] # Configures the startup! +# We should be able to remove the dumb-init now with Rocket 0.5 +# But the balenalib images have some issues with there entry.sh +# See: https://github.com/balena-io-library/base-images/issues/735 +# Lets keep using dumb-init for now, since that is working fine. ENTRYPOINT ["/usr/bin/dumb-init", "--"] CMD ["/start.sh"] diff --git a/docker/armv7/Dockerfile b/docker/armv7/Dockerfile index 7e456fd7..d38be097 100644 --- a/docker/armv7/Dockerfile +++ b/docker/armv7/Dockerfile @@ -27,7 +27,7 @@ FROM vaultwarden/web-vault@sha256:0e8daf80abb73ebca69d1971847450d24da45a74a525fd643246ee1dfa02108b as vault ########################## BUILD IMAGE ########################## -FROM rust:1.55-buster as build +FROM rust:1.56-buster as build # Debian-based builds support multidb ARG DB=sqlite,mysql,postgresql @@ -155,7 +155,6 @@ EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage WORKDIR / -COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/armv7-unknown-linux-gnueabihf/release/vaultwarden . @@ -165,5 +164,9 @@ COPY docker/start.sh /start.sh HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"] # Configures the startup! +# We should be able to remove the dumb-init now with Rocket 0.5 +# But the balenalib images have some issues with there entry.sh +# See: https://github.com/balena-io-library/base-images/issues/735 +# Lets keep using dumb-init for now, since that is working fine. ENTRYPOINT ["/usr/bin/dumb-init", "--"] CMD ["/start.sh"] diff --git a/docker/armv7/Dockerfile.alpine b/docker/armv7/Dockerfile.alpine index 6e62cedf..404d090f 100644 --- a/docker/armv7/Dockerfile.alpine +++ b/docker/armv7/Dockerfile.alpine @@ -111,7 +111,6 @@ EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage WORKDIR / -COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/armv7-unknown-linux-musleabihf/release/vaultwarden . @@ -121,5 +120,9 @@ COPY docker/start.sh /start.sh HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"] # Configures the startup! +# We should be able to remove the dumb-init now with Rocket 0.5 +# But the balenalib images have some issues with there entry.sh +# See: https://github.com/balena-io-library/base-images/issues/735 +# Lets keep using dumb-init for now, since that is working fine. ENTRYPOINT ["/usr/bin/dumb-init", "--"] CMD ["/start.sh"] diff --git a/docker/armv7/Dockerfile.buildx b/docker/armv7/Dockerfile.buildx index 8d9e938b..33834022 100644 --- a/docker/armv7/Dockerfile.buildx +++ b/docker/armv7/Dockerfile.buildx @@ -27,7 +27,7 @@ FROM vaultwarden/web-vault@sha256:0e8daf80abb73ebca69d1971847450d24da45a74a525fd643246ee1dfa02108b as vault ########################## BUILD IMAGE ########################## -FROM rust:1.55-buster as build +FROM rust:1.56-buster as build # Debian-based builds support multidb ARG DB=sqlite,mysql,postgresql @@ -155,7 +155,6 @@ EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage WORKDIR / -COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/armv7-unknown-linux-gnueabihf/release/vaultwarden . @@ -165,5 +164,9 @@ COPY docker/start.sh /start.sh HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"] # Configures the startup! +# We should be able to remove the dumb-init now with Rocket 0.5 +# But the balenalib images have some issues with there entry.sh +# See: https://github.com/balena-io-library/base-images/issues/735 +# Lets keep using dumb-init for now, since that is working fine. ENTRYPOINT ["/usr/bin/dumb-init", "--"] CMD ["/start.sh"] diff --git a/docker/armv7/Dockerfile.buildx.alpine b/docker/armv7/Dockerfile.buildx.alpine index f235b09a..461ac193 100644 --- a/docker/armv7/Dockerfile.buildx.alpine +++ b/docker/armv7/Dockerfile.buildx.alpine @@ -111,7 +111,6 @@ EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage WORKDIR / -COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/armv7-unknown-linux-musleabihf/release/vaultwarden . @@ -121,5 +120,9 @@ COPY docker/start.sh /start.sh HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"] # Configures the startup! +# We should be able to remove the dumb-init now with Rocket 0.5 +# But the balenalib images have some issues with there entry.sh +# See: https://github.com/balena-io-library/base-images/issues/735 +# Lets keep using dumb-init for now, since that is working fine. ENTRYPOINT ["/usr/bin/dumb-init", "--"] CMD ["/start.sh"] diff --git a/src/api/admin.rs b/src/api/admin.rs index e11ab427..2e008df2 100644 --- a/src/api/admin.rs +++ b/src/api/admin.rs @@ -142,7 +142,7 @@ fn admin_url(referer: Referer) -> String { } #[get("/", rank = 2)] -fn admin_login(flash: Option) -> ApiResult> { +fn admin_login(flash: Option>) -> ApiResult> { // If there is an error, show it let msg = flash.map(|msg| format!("{}: {}", msg.kind(), msg.message())); let json = json!({ @@ -165,7 +165,7 @@ struct LoginForm { #[post("/", data = "")] fn post_admin_login( data: Form, - cookies: &CookieJar, + cookies: &CookieJar<'_>, ip: ClientIp, referer: Referer, ) -> Result> { @@ -297,7 +297,7 @@ fn test_smtp(data: Json, _token: AdminToken) -> EmptyResult { } #[get("/logout")] -fn logout(cookies: &CookieJar, referer: Referer) -> Redirect { +fn logout(cookies: &CookieJar<'_>, referer: Referer) -> Redirect { cookies.remove(Cookie::named(COOKIE_NAME)); Redirect::to(admin_url(referer)) } diff --git a/src/auth.rs b/src/auth.rs index 7eaf1494..a2d64b30 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -38,7 +38,7 @@ static PRIVATE_RSA_KEY: Lazy = Lazy::new(|| { static PUBLIC_RSA_KEY_VEC: Lazy> = Lazy::new(|| { read_file(&CONFIG.public_rsa_key()).unwrap_or_else(|e| panic!("Error loading public RSA Key.\n{}", e)) }); -static PUBLIC_RSA_KEY: Lazy = Lazy::new(|| { +static PUBLIC_RSA_KEY: Lazy> = Lazy::new(|| { DecodingKey::from_rsa_pem(&PUBLIC_RSA_KEY_VEC).unwrap_or_else(|e| panic!("Error decoding public RSA Key.\n{}", e)) }); @@ -411,7 +411,7 @@ pub struct OrgHeaders { // org_id is usually the second path param ("/organizations/"), // but there are cases where it is a query value. // First check the path, if this is not a valid uuid, try the query values. -fn get_org_id(request: &Request) -> Option { +fn get_org_id(request: &Request<'_>) -> Option { if let Some(Ok(org_id)) = request.param::(1) { if uuid::Uuid::parse_str(&org_id).is_ok() { return Some(org_id); @@ -512,7 +512,7 @@ impl From for Headers { // col_id is usually the fourth path param ("/organizations//collections/"), // but there could be cases where it is a query value. // First check the path, if this is not a valid uuid, try the query values. -fn get_col_id(request: &Request) -> Option { +fn get_col_id(request: &Request<'_>) -> Option { if let Some(Ok(col_id)) = request.param::(3) { if uuid::Uuid::parse_str(&col_id).is_ok() { return Some(col_id); diff --git a/src/config.rs b/src/config.rs index cccfadff..9b40ceda 100644 --- a/src/config.rs +++ b/src/config.rs @@ -969,7 +969,7 @@ where fn case_helper<'reg, 'rc>( h: &Helper<'reg, 'rc>, - r: &'reg Handlebars, + r: &'reg Handlebars<'_>, ctx: &'rc Context, rc: &mut RenderContext<'reg, 'rc>, out: &mut dyn Output, @@ -986,7 +986,7 @@ fn case_helper<'reg, 'rc>( fn js_escape_helper<'reg, 'rc>( h: &Helper<'reg, 'rc>, - _r: &'reg Handlebars, + _r: &'reg Handlebars<'_>, _ctx: &'rc Context, _rc: &mut RenderContext<'reg, 'rc>, out: &mut dyn Output, diff --git a/src/error.rs b/src/error.rs index 6c94c422..fe1ae1ab 100644 --- a/src/error.rs +++ b/src/error.rs @@ -24,7 +24,7 @@ macro_rules! make_error { } } impl std::fmt::Display for Error { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match &self.error {$( ErrorKind::$name(e) => f.write_str(&$usr_msg_fun(e, &self.message)), )+} @@ -93,7 +93,7 @@ make_error! { } impl std::fmt::Debug for Error { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self.source() { Some(e) => write!(f, "{}.\n[CAUSE] {:#?}", self.message, e), None => match self.error { @@ -194,7 +194,7 @@ use rocket::request::Request; use rocket::response::{self, Responder, Response}; impl<'r> Responder<'r, 'static> for Error { - fn respond_to(self, _: &Request) -> response::Result<'static> { + fn respond_to(self, _: &Request<'_>) -> response::Result<'static> { match self.error { ErrorKind::Empty(_) => {} // Don't print the error in this situation ErrorKind::Simple(_) => {} // Don't print the error in this situation diff --git a/src/main.rs b/src/main.rs index 2b8869de..00f308ad 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,5 @@ #![forbid(unsafe_code)] -// #![warn(rust_2018_idioms)] +#![warn(rust_2018_idioms)] #![warn(rust_2021_compatibility)] #![cfg_attr(feature = "unstable", feature(ip))] // The recursion_limit is mainly triggered by the json!() macro. @@ -8,7 +8,6 @@ // If you go above 128 it will cause rust-analyzer to fail, #![recursion_limit = "87"] -extern crate openssl; #[macro_use] extern crate rocket; #[macro_use] diff --git a/src/util.rs b/src/util.rs index b0e4fa05..99f7be64 100644 --- a/src/util.rs +++ b/src/util.rs @@ -49,7 +49,7 @@ impl Fairing for AppHeaders { pub struct Cors(); impl Cors { - fn get_header(headers: &HeaderMap, name: &str) -> String { + fn get_header(headers: &HeaderMap<'_>, name: &str) -> String { match headers.get_one(name) { Some(h) => h.to_string(), _ => "".to_string(), @@ -58,7 +58,7 @@ impl Cors { // Check a request's `Origin` header against the list of allowed origins. // If a match exists, return it. Otherwise, return None. - fn get_allowed_origin(headers: &HeaderMap) -> Option { + fn get_allowed_origin(headers: &HeaderMap<'_>) -> Option { let origin = Cors::get_header(headers, "Origin"); let domain_origin = CONFIG.domain_origin(); let safari_extension_origin = "file://"; @@ -130,7 +130,7 @@ impl<'r, R: 'r + Responder<'r, 'static> + Send> Responder<'r, 'static> for Cache pub struct SafeString(String); impl std::fmt::Display for SafeString { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { self.0.fmt(f) } } @@ -462,7 +462,7 @@ struct UpCaseVisitor; impl<'de> Visitor<'de> for UpCaseVisitor { type Value = Value; - fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { formatter.write_str("an object or an array") }