Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update keyring to 1.0.0 #721

Merged
merged 1 commit into from
Dec 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings
args: --features password-storage -- -D warnings
Copy link
Member Author

@messense messense Dec 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

password-storage related code wasn't checked by clippy previously.


black:
runs-on: ubuntu-latest
Expand Down
67 changes: 42 additions & 25 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 @@ -28,7 +28,7 @@ cbindgen = { version = "0.20.0", default-features = false }
flate2 = "1.0.18"
goblin = "0.4.3"
human-panic = { version = "1.0.3", optional = true }
keyring = { version = "0.10.4", optional = true }
keyring = { version = "1.0.0", optional = true }
platform-info = "0.2.0"
pretty_env_logger = { version = "0.4.0", optional = true }
regex = "1.4.5"
Expand Down
15 changes: 6 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ use configparser::ini::Ini;
use fs_err as fs;
#[cfg(feature = "human-panic")]
use human_panic::setup_panic;
#[cfg(feature = "password-storage")]
use keyring::{Keyring, KeyringError};
use maturin::GenerateProjectOptions;
use maturin::{
develop, init_project, new_project, source_distribution, write_dist_info, BridgeModel,
Expand Down Expand Up @@ -46,7 +44,7 @@ fn get_password(_username: &str) -> String {
#[cfg(feature = "keyring")]
{
let service = env!("CARGO_PKG_NAME");
let keyring = Keyring::new(&service, &_username);
let keyring = keyring::Entry::new(service, _username);
if let Ok(password) = keyring.get_password() {
return password;
};
Expand Down Expand Up @@ -458,13 +456,13 @@ fn upload_ui(items: &[PathBuf], publish: &PublishOpt) -> Result<()> {
#[cfg(feature = "keyring")]
{
// Delete the wrong password from the keyring
let old_username = registry.username.clone();
let keyring = Keyring::new(&env!("CARGO_PKG_NAME"), &old_username);
let old_username = registry.username;
let keyring = keyring::Entry::new(env!("CARGO_PKG_NAME"), &old_username);
match keyring.delete_password() {
Ok(()) => {
println!("🔑 Removed wrong password from keyring")
}
Err(KeyringError::NoPasswordFound) | Err(KeyringError::NoBackendFound) => {}
Err(keyring::Error::NoEntry) | Err(keyring::Error::NoStorageAccess(_)) => {}
Err(err) => {
eprintln!("⚠️ Warning: Failed to remove password from keyring: {}", err)
}
Expand Down Expand Up @@ -499,11 +497,10 @@ fn upload_ui(items: &[PathBuf], publish: &PublishOpt) -> Result<()> {
{
// We know the password is correct, so we can save it in the keyring
let username = registry.username.clone();
let keyring = Keyring::new(&env!("CARGO_PKG_NAME"), &username);
let password = registry.password.clone();
let keyring = keyring::Entry::new(env!("CARGO_PKG_NAME"), &username);
let password = registry.password;
match keyring.set_password(&password) {
Ok(()) => {}
Err(KeyringError::NoBackendFound) => {}
Err(err) => {
eprintln!(
"⚠️ Warning: Failed to store the password in the keyring: {:?}",
Expand Down