Skip to content

Commit d712d8d

Browse files
committed
drop unused callbacks
1 parent e795fb0 commit d712d8d

File tree

4 files changed

+6
-65
lines changed

4 files changed

+6
-65
lines changed

README.md

Lines changed: 3 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,6 @@ type CredentialsProviderOptions struct {
218218

219219
// Optional: Token manager configuration
220220
TokenManagerOptions manager.TokenManagerOptions
221-
222-
// Optional: Callback for re-authentication errors
223-
OnReAuthenticationError func(error) error
224-
225-
// Optional: Callback for retryable errors
226-
OnRetryableError func(error) error
227221
}
228222
```
229223

@@ -296,7 +290,7 @@ type ConfidentialIdentityProviderOptions struct {
296290
ClientID string
297291

298292
// Required: Type of credentials
299-
CredentialsType string // "ClientSecret" or "ClientCertificate"
293+
CredentialsType string // identity.ClientSecretCredentialType or identity.ClientCertificateCredentialType
300294

301295
// Required for ClientSecret: Client secret value
302296
ClientSecret string
@@ -358,10 +352,6 @@ options := entraid.CredentialsProviderOptions{
358352
ExpirationRefreshRatio: 0.7,
359353
LowerRefreshBoundMs: 10000,
360354
},
361-
OnReAuthenticationError: func(err error) error {
362-
log.Printf("Re-authentication error: %v", err)
363-
return err
364-
},
365355
}
366356
```
367357

@@ -383,14 +373,6 @@ options := entraid.CredentialsProviderOptions{
383373
},
384374
},
385375
},
386-
OnReAuthenticationError: func(err error) error {
387-
log.Printf("Re-authentication error: %v", err)
388-
return err
389-
},
390-
OnRetryableError: func(err error) error {
391-
log.Printf("Retryable error: %v", err)
392-
return err
393-
},
394376
}
395377
```
396378

@@ -658,7 +640,7 @@ A:
658640
- Default Azure: Uses environment-based authentication, good for development
659641

660642
### Q: How do I handle connection failures?
661-
A: The library includes built-in retry mechanisms. You can configure retry behavior using `RetryOptions`:
643+
A: The library includes built-in retry mechanisms in the TokenManager. You can configure retry behavior using `RetryOptions`:
662644
```go
663645
RetryOptions: manager.RetryOptions{
664646
MaxAttempts: 3,
@@ -698,34 +680,4 @@ func (p *CustomProvider) GetToken(ctx context.Context) (string, error) {
698680
```
699681

700682
### Q: What happens if token refresh fails?
701-
A: The library will retry according to the configured `RetryOptions`. If all retries fail, it will call the `OnReAuthenticationError` callback if provided. You can implement custom error handling:
702-
```go
703-
OnReAuthenticationError: func(err error) error {
704-
log.Printf("Re-authentication error: %v", err)
705-
// Implement your error handling logic
706-
return err
707-
}
708-
```
709-
710-
### Q: How do I handle different environments (dev/staging/prod)?
711-
A: Use environment variables and configuration options:
712-
```go
713-
// Development
714-
options := entraid.CredentialsProviderOptions{
715-
ClientID: os.Getenv("DEV_AZURE_CLIENT_ID"),
716-
TokenManagerOptions: manager.TokenManagerOptions{
717-
ExpirationRefreshRatio: 0.8, // More aggressive refresh
718-
},
719-
}
720-
721-
// Production
722-
options := entraid.CredentialsProviderOptions{
723-
ClientID: os.Getenv("PROD_AZURE_CLIENT_ID"),
724-
TokenManagerOptions: manager.TokenManagerOptions{
725-
ExpirationRefreshRatio: 0.7,
726-
RetryOptions: manager.RetryOptions{
727-
MaxAttempts: 5,
728-
},
729-
},
730-
}
731-
```
683+
A: The library will retry according to the configured `RetryOptions`. If all retries fail, the error will be propagated to the client.

credentials_provider.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,13 @@ func (e *entraidCredentialsProvider) onTokenNext(t *token.Token) {
3636
}
3737
}
3838

39-
// onError is a method that is called when the token manager encounters an error.
39+
// onTokenError is a method that is called when the token manager encounters an error.
4040
// It notifies all listeners with the error.
4141
func (e *entraidCredentialsProvider) onTokenError(err error) {
4242
e.rwLock.RLock()
4343
defer e.rwLock.RUnlock()
44-
// Notify all listeners with the error.
44+
45+
// Notify all listeners with the error
4546
for _, listener := range e.listeners {
4647
listener.OnError(err)
4748
}

providers.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ type CredentialsProviderOptions struct {
2020
// This is used to configure the token manager when requesting a token.
2121
TokenManagerOptions manager.TokenManagerOptions
2222

23-
// OnReAuthenticationError is a callback function that is called when a re-authentication error occurs.
24-
OnReAuthenticationError func(error) error
25-
26-
// OnRetryableError is a callback function that is called when a retriable error occurs.
27-
OnRetryableError func(error) error
28-
2923
// tokenManagerFactory is a private field that can be injected from within the package.
3024
// It is used to create a token manager for the credentials provider.
3125
tokenManagerFactory func(shared.IdentityProvider, manager.TokenManagerOptions) (manager.TokenManager, error)

providers_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,6 @@ func TestCredentialsProviderErrorHandling(t *testing.T) {
305305
TokenManagerOptions: manager.TokenManagerOptions{
306306
ExpirationRefreshRatio: 0.7,
307307
},
308-
OnReAuthenticationError: func(err error) error {
309-
return errors.New("custom re-auth error")
310-
},
311308
},
312309
ConfidentialIdentityProviderOptions: identity.ConfidentialIdentityProviderOptions{
313310
ClientID: "test-client-id",
@@ -347,9 +344,6 @@ func TestCredentialsProviderErrorHandling(t *testing.T) {
347344
TokenManagerOptions: manager.TokenManagerOptions{
348345
ExpirationRefreshRatio: 0.7,
349346
},
350-
OnRetryableError: func(err error) error {
351-
return errors.New("custom retry error")
352-
},
353347
},
354348
ConfidentialIdentityProviderOptions: identity.ConfidentialIdentityProviderOptions{
355349
ClientID: "test-client-id",

0 commit comments

Comments
 (0)