From d95e737cb76974d0edfc695d9faec695019469d8 Mon Sep 17 00:00:00 2001 From: Shahram Kalantari Date: Thu, 31 Oct 2024 08:41:38 +1000 Subject: [PATCH] chore: remove unused code Signed-off-by: Shahram Kalantari --- pkg/certificateprovider/azurekeyvault/auth.go | 38 ------------------- .../azurekeyvault/auth.go | 38 ------------------- 2 files changed, 76 deletions(-) diff --git a/pkg/certificateprovider/azurekeyvault/auth.go b/pkg/certificateprovider/azurekeyvault/auth.go index 138fc57ce..9323f4607 100644 --- a/pkg/certificateprovider/azurekeyvault/auth.go +++ b/pkg/certificateprovider/azurekeyvault/auth.go @@ -35,44 +35,6 @@ const ( DefaultTokenAudience = "api://AzureADTokenExchange" //nolint ) -// authResult contains the subset of results from token acquisition operation in ConfidentialClientApplication -// For details see https://aka.ms/msal-net-authenticationresult -type authResult struct { - accessToken string - expiresOn time.Time - grantedScopes []string - declinedScopes []string -} - -// func getAuthorizerForWorkloadIdentity(ctx context.Context, tenantID, clientID, resource string) (autorest.Authorizer, error) { -// scope := resource -// // .default needs to be added to the scope -// if !strings.Contains(resource, ".default") { -// scope = fmt.Sprintf("%s/.default", resource) -// } - -// result, err := azureauth.GetAADAccessToken(ctx, tenantID, clientID, scope) -// if err != nil { -// return nil, fmt.Errorf("failed to acquire token: %w", err) -// } - -// if _, err = parseExpiresOn(result.ExpiresOn.UTC().Local().Format(expiresOnDateFormat)); err != nil { -// return nil, fmt.Errorf("failed to parse expires_on: %w", err) -// } - -// return autorest.NewBearerAuthorizer(authResult{ -// accessToken: result.AccessToken, -// expiresOn: result.ExpiresOn, -// grantedScopes: result.GrantedScopes, -// declinedScopes: result.DeclinedScopes, -// }), nil -// } - -// OAuthToken implements the OAuthTokenProvider interface. It returns the current access token. -func (ar authResult) OAuthToken() string { - return ar.accessToken -} - // Vendored from https://github.com/Azure/go-autorest/blob/79575dd7ba2e88e7ce7ab84e167ec6653dcb70c1/autorest/adal/token.go // converts expires_on to the number of seconds func parseExpiresOn(s interface{}) (json.Number, error) { diff --git a/pkg/keymanagementprovider/azurekeyvault/auth.go b/pkg/keymanagementprovider/azurekeyvault/auth.go index a01d5beb0..1de94181a 100644 --- a/pkg/keymanagementprovider/azurekeyvault/auth.go +++ b/pkg/keymanagementprovider/azurekeyvault/auth.go @@ -35,44 +35,6 @@ const ( DefaultTokenAudience = "api://AzureADTokenExchange" //nolint ) -// authResult contains the subset of results from token acquisition operation in ConfidentialClientApplication -// For details see https://aka.ms/msal-net-authenticationresult -type authResult struct { - accessToken string - expiresOn time.Time - grantedScopes []string - declinedScopes []string -} - -// func getAuthorizerForWorkloadIdentity(ctx context.Context, tenantID, clientID, resource string) (autorest.Authorizer, error) { -// scope := resource -// // .default needs to be added to the scope -// if !strings.Contains(resource, ".default") { -// scope = fmt.Sprintf("%s/.default", resource) -// } - -// result, err := azureauth.GetAADAccessToken(ctx, tenantID, clientID, scope) -// if err != nil { -// return nil, fmt.Errorf("failed to acquire token: %w", err) -// } - -// if _, err = parseExpiresOn(result.ExpiresOn.UTC().Local().Format(expiresOnDateFormat)); err != nil { -// return nil, fmt.Errorf("failed to parse expires_on: %w", err) -// } - -// return autorest.NewBearerAuthorizer(authResult{ -// accessToken: result.AccessToken, -// expiresOn: result.ExpiresOn, -// grantedScopes: result.GrantedScopes, -// declinedScopes: result.DeclinedScopes, -// }), nil -// } - -// OAuthToken implements the OAuthTokenProvider interface. It returns the current access token. -func (ar authResult) OAuthToken() string { - return ar.accessToken -} - // Vendored from https://github.com/Azure/go-autorest/blob/79575dd7ba2e88e7ce7ab84e167ec6653dcb70c1/autorest/adal/token.go // converts expires_on to the number of seconds func parseExpiresOn(s interface{}) (json.Number, error) {