Skip to content

Commit 2eee923

Browse files
authored
Remove TokenCredential::clear_cache (#2385)
* Remove TokenCredential::clear_cache * remove implementations * delete azure_identity's TokenCache implementation * keep caching behavior; remove only the public API * allow unused TokenCache::clear
1 parent 97c10c3 commit 2eee923

17 files changed

+3
-107
lines changed

sdk/core/azure_core/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
### Breaking Changes
1616

17+
- Removed `azure_core::credentials::TokenCredential::clear_cache()`
1718
- Consolidated all the `tokio` features into a single feature named `tokio`. Traits remain separate but `tokio` support is enabled with a single feature.
1819
- Moved `AppendToUrlQuery` type under `http` module.
1920
- Moved `ByteStream` and `SeekableStream` types under `stream` module.

sdk/core/azure_core/src/credentials.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,4 @@ impl AccessToken {
100100
pub trait TokenCredential: Send + Sync + Debug {
101101
/// Gets a `AccessToken` for the specified resource
102102
async fn get_token(&self, scopes: &[&str]) -> crate::Result<AccessToken>;
103-
104-
/// Clear the credential's cache.
105-
async fn clear_cache(&self) -> crate::Result<()>;
106103
}

sdk/core/azure_core_test/src/credentials.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ impl TokenCredential for MockCredential {
2626
);
2727
Ok(AccessToken { token, expires_on })
2828
}
29-
30-
async fn clear_cache(&self) -> azure_core::Result<()> {
31-
Ok(())
32-
}
3329
}
3430

3531
/// Gets a `TokenCredential` appropriate for the current environment.

sdk/cosmos/azure_data_cosmos/src/pipeline/authorization_policy.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,6 @@ mod tests {
175175
OffsetDateTime::now_utc().saturating_add(time::Duration::minutes(5)),
176176
))
177177
}
178-
179-
async fn clear_cache(&self) -> azure_core::Result<()> {
180-
Ok(())
181-
}
182178
}
183179

184180
#[tokio::test]

sdk/identity/azure_identity/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
- `ClientAssertionCredential` constructors moved some parameters to an `Option<ClientAssertionCredentialOptions>` parameter.
1717
- Removed `get_subscription()` and `get_tenant()` from `AzureCliCredential`.
1818
- `WorkloadIdentityCredential` constructors moved some parameters to an `Option<ClientAssertionCredentialOptions>` parameter.
19+
- Removed `clear_cache()` from all credential types
1920

2021
### Bugs Fixed
2122

sdk/identity/azure_identity/examples/specific_credential.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -81,20 +81,6 @@ impl TokenCredential for SpecificAzureCredentialKind {
8181
}
8282
}
8383
}
84-
85-
async fn clear_cache(&self) -> azure_core::Result<()> {
86-
match self {
87-
#[cfg(not(target_arch = "wasm32"))]
88-
SpecificAzureCredentialKind::AzureCli(credential) => credential.clear_cache().await,
89-
SpecificAzureCredentialKind::VirtualMachine(credential) => {
90-
credential.clear_cache().await
91-
}
92-
SpecificAzureCredentialKind::AppService(credential) => credential.clear_cache().await,
93-
SpecificAzureCredentialKind::WorkloadIdentity(credential) => {
94-
credential.clear_cache().await
95-
}
96-
}
97-
}
9884
}
9985

10086
/// Define a credential that uses an environment variable named `AZURE_CREDENTIAL_KIND`
@@ -161,8 +147,4 @@ impl TokenCredential for SpecificAzureCredential {
161147
async fn get_token(&self, scopes: &[&str]) -> azure_core::Result<AccessToken> {
162148
self.source.get_token(scopes).await
163149
}
164-
165-
async fn clear_cache(&self) -> azure_core::Result<()> {
166-
self.source.clear_cache().await
167-
}
168150
}

sdk/identity/azure_identity/src/azure_pipelines_credential.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,6 @@ impl TokenCredential for AzurePipelinesCredential {
111111
async fn get_token(&self, scopes: &[&str]) -> azure_core::Result<AccessToken> {
112112
self.0.get_token(scopes).await
113113
}
114-
115-
async fn clear_cache(&self) -> azure_core::Result<()> {
116-
self.0.clear_cache().await
117-
}
118114
}
119115

120116
#[derive(Debug)]

sdk/identity/azure_identity/src/chained_token_credential.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -114,21 +114,6 @@ impl TokenCredential for ChainedTokenCredential {
114114
async fn get_token(&self, scopes: &[&str]) -> azure_core::Result<AccessToken> {
115115
self.cache.get_token(scopes, self.get_token(scopes)).await
116116
}
117-
118-
/// Clear the credential's cache.
119-
async fn clear_cache(&self) -> azure_core::Result<()> {
120-
// clear the internal cache as well as each of the underlying providers
121-
self.cache.clear().await?;
122-
123-
for source in &self.sources {
124-
source.clear_cache().await?;
125-
}
126-
127-
// clear the successful credential if we are clearing the token cache
128-
self.successful_credential.write().await.take();
129-
130-
Ok(())
131-
}
132117
}
133118

134119
fn format_aggregate_error(errors: &[Error]) -> String {
@@ -182,10 +167,6 @@ mod tests {
182167
*count += 1;
183168
Err(Error::message(ErrorKind::Credential, "failed to get token"))
184169
}
185-
186-
async fn clear_cache(&self) -> azure_core::Result<()> {
187-
Ok(())
188-
}
189170
}
190171

191172
#[tokio::test]

sdk/identity/azure_identity/src/credentials/app_service_managed_identity_credential.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,4 @@ impl TokenCredential for AppServiceManagedIdentityCredential {
5555
async fn get_token(&self, scopes: &[&str]) -> azure_core::Result<AccessToken> {
5656
self.credential.get_token(scopes).await
5757
}
58-
59-
async fn clear_cache(&self) -> azure_core::Result<()> {
60-
self.credential.clear_cache().await
61-
}
6258
}

sdk/identity/azure_identity/src/credentials/azure_cli_credentials.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -293,11 +293,6 @@ impl TokenCredential for AzureCliCredential {
293293
async fn get_token(&self, scopes: &[&str]) -> azure_core::Result<AccessToken> {
294294
self.cache.get_token(scopes, self.get_token(scopes)).await
295295
}
296-
297-
/// Clear the credential's cache.
298-
async fn clear_cache(&self) -> azure_core::Result<()> {
299-
self.cache.clear().await
300-
}
301296
}
302297

303298
impl From<TokenCredentialOptions> for AzureCliCredentialOptions {

0 commit comments

Comments
 (0)