Publish: Warn when keyring has no password (#8827)

When trying to upload without a password but with the keyring, check
that the keyring has a password for the upload URL and username and warn
if it doesn't.

Fixes #8781
This commit is contained in:
konsti 2024-11-27 20:54:49 +01:00 committed by GitHub
parent 68e3228f2b
commit 0b0d0f44f8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 166 additions and 10 deletions

View file

@ -76,7 +76,7 @@ impl Credentials {
}
}
pub(crate) fn username(&self) -> Option<&str> {
pub fn username(&self) -> Option<&str> {
self.username.as_deref()
}
@ -84,7 +84,7 @@ impl Credentials {
self.username.clone()
}
pub(crate) fn password(&self) -> Option<&str> {
pub fn password(&self) -> Option<&str> {
self.password.as_deref()
}

View file

@ -35,7 +35,7 @@ impl KeyringProvider {
/// Returns [`None`] if no password was found for the username or if any errors
/// are encountered in the keyring backend.
#[instrument(skip_all, fields(url = % url.to_string(), username))]
pub(crate) async fn fetch(&self, url: &Url, username: &str) -> Option<Credentials> {
pub async fn fetch(&self, url: &Url, username: &str) -> Option<Credentials> {
// Validate the request
debug_assert!(
url.host_str().is_some(),