Skip to content

Commit

Permalink
Merge pull request #9466 from rust-lang/renovate/secrecy-0.x
Browse files Browse the repository at this point in the history
Update Rust crate secrecy to v0.10.1
  • Loading branch information
Turbo87 committed Sep 18, 2024
2 parents bafd659 + 86a9715 commit 4245dfd
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ rand = "=0.8.5"
reqwest = { version = "=0.12.7", features = ["blocking", "gzip", "json"] }
rss = { version = "=2.0.9", default-features = false, features = ["atom"] }
scheduled-thread-pool = "=0.2.7"
secrecy = "=0.8.0"
secrecy = "=0.10.1"
semver = { version = "=1.0.23", features = ["serde"] }
sentry = { version = "=0.34.0", features = ["tracing", "tower", "tower-axum-matched-path", "tower-http"] }
serde = { version = "=1.0.210", features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion crates/crates_io_index/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ anyhow = "=1.0.89"
base64 = "=0.22.1"
crates_io_env_vars = { path = "../crates_io_env_vars" }
git2 = "=0.19.0"
secrecy = "=0.8.0"
secrecy = "=0.10.1"
serde = { version = "=1.0.210", features = ["derive"] }
serde_json = "=1.0.128"
tempfile = "=3.12.0"
Expand Down
2 changes: 1 addition & 1 deletion crates/crates_io_smoke_test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ bytes = "=1.7.2"
clap = { version = "=4.5.17", features = ["derive", "env", "unicode", "wrap_help"] }
crates_io_index = { path = "../crates_io_index" }
reqwest = { version = "=0.12.7", features = ["gzip", "json"] }
secrecy = "=0.8.0"
secrecy = "=0.10.1"
semver = { version = "=1.0.23", features = ["serde"] }
serde = { version = "=1.0.210", features = ["derive"] }
serde_json = "=1.0.128"
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/krate/owners.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use diesel::prelude::*;
use diesel_async::async_connection_wrapper::AsyncConnectionWrapper;
use http::request::Parts;
use http::StatusCode;
use secrecy::{ExposeSecret, Secret};
use secrecy::{ExposeSecret, SecretString};
use serde_json::Value;
use tokio::runtime::Handle;

Expand Down Expand Up @@ -253,7 +253,7 @@ pub struct OwnerInviteEmail {
inviter: String,
domain: String,
crate_name: String,
token: Secret<String>,
token: SecretString,
}

impl OwnerInviteEmail {
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/user/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ pub async fn update_user(
.do_update()
.set(&new_email)
.returning(emails::token)
.get_result(conn)
.map(SecretString::new)
.get_result::<String>(conn)
.map(SecretString::from)
.map_err(|_| server_error("Error in creating token"))?;

// This swallows any errors that occur while attempting to send the email. Some users have
Expand Down
4 changes: 2 additions & 2 deletions src/models/krate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use diesel::dsl;
use diesel::pg::Pg;
use diesel::prelude::*;
use diesel::sql_types::{Bool, Text};
use secrecy::Secret;
use secrecy::SecretString;
use thiserror::Error;

use crate::controllers::helpers::pagination::*;
Expand Down Expand Up @@ -522,7 +522,7 @@ impl Crate {
pub enum NewOwnerInvite {
/// The invitee was a [`User`], and they must accept the invite through the
/// UI or via the provided invite token.
User(User, Secret<String>),
User(User, SecretString),

/// The invitee was a [`Team`], and they were immediately added as an owner.
Team(Team),
Expand Down
4 changes: 2 additions & 2 deletions src/models/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ impl<'a> NewUser<'a> {
.values(&new_email)
.on_conflict_do_nothing()
.returning(emails::token)
.get_result(conn)
.get_result::<String>(conn)
.optional()?
.map(SecretString::new);
.map(SecretString::from);

if let Some(token) = token {
// Swallows any error. Some users might insert an invalid email address here.
Expand Down
8 changes: 4 additions & 4 deletions src/util/token.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use diesel::{deserialize::FromSql, pg::Pg, serialize::ToSql, sql_types::Bytea};
use rand::{distributions::Uniform, rngs::OsRng, Rng};
use secrecy::{ExposeSecret, SecretString, SecretVec};
use secrecy::{ExposeSecret, SecretSlice, SecretString};
use sha2::{Digest, Sha256};

const TOKEN_LENGTH: usize = 32;
Expand All @@ -19,7 +19,7 @@ pub struct InvalidTokenError;

#[derive(FromSqlRow, AsExpression)]
#[diesel(sql_type = Bytea)]
pub struct HashedToken(SecretVec<u8>);
pub struct HashedToken(SecretSlice<u8>);

impl HashedToken {
pub fn parse(plaintext: &str) -> Result<Self, InvalidTokenError> {
Expand Down Expand Up @@ -77,8 +77,8 @@ impl PlainToken {
}
}

impl ExposeSecret<String> for PlainToken {
fn expose_secret(&self) -> &String {
impl ExposeSecret<str> for PlainToken {
fn expose_secret(&self) -> &str {
self.0.expose_secret()
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/views.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ impl From<CreatedApiToken> for EncodableApiTokenWithToken {
fn from(token: CreatedApiToken) -> Self {
EncodableApiTokenWithToken {
token: token.model,
plaintext: token.plaintext.expose_secret().clone(),
plaintext: token.plaintext.expose_secret().to_string(),
}
}
}
Expand Down

0 comments on commit 4245dfd

Please sign in to comment.