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

Add autorest.BearerAuthorizerCallback support to auth.CachedAuthorizer #130

Merged
merged 1 commit into from
Nov 29, 2021

Conversation

manicminer
Copy link
Owner

No description provided.

@manicminer manicminer added enhancement New feature or request package/auth labels Nov 29, 2021
@manicminer manicminer added this to the v0.37.0 milestone Nov 29, 2021
Copy link
Collaborator

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

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

one minor comment since the arguments are unused but this otherwise LGTM 👍

auth/cache.go Outdated
@@ -100,6 +101,21 @@ func (c *CachedAuthorizer) WithAuthorization() autorest.PrepareDecorator {
}
}

// BearerAuthorizerCallback is a helper that returns an *autorest.BearerAuthorizerCallback for use in data plane API clients in the Azure SDK
func (c *CachedAuthorizer) BearerAuthorizerCallback() *autorest.BearerAuthorizerCallback {
return autorest.NewBearerAuthorizerCallback(nil, func(tenantID, resource string) (*autorest.BearerAuthorizer, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

since neither of these are used we can make this:

Suggested change
return autorest.NewBearerAuthorizerCallback(nil, func(tenantID, resource string) (*autorest.BearerAuthorizer, error) {
return autorest.NewBearerAuthorizerCallback(nil, func(_, _ string) (*autorest.BearerAuthorizer, error) {

fwiw

Copy link
Owner Author

Choose a reason for hiding this comment

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

Good spot, thanks 👍

@manicminer manicminer force-pushed the feature/autorest-authorizer-callback branch from 24e3f30 to 89407ca Compare November 29, 2021 21:13
@manicminer
Copy link
Owner Author

Test results

Screenshot 2021-11-29 at 21 17 26

@manicminer manicminer merged commit e2f8457 into main Nov 29, 2021
@manicminer manicminer deleted the feature/autorest-authorizer-callback branch November 29, 2021 21:18
manicminer added a commit that referenced this pull request Nov 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request package/auth
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants