Skip to content

Commit

Permalink
chore: remove unused code
Browse files Browse the repository at this point in the history
Signed-off-by: Shahram Kalantari <[email protected]>
  • Loading branch information
shahramk64 committed Oct 30, 2024
1 parent 30dc131 commit d95e737
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 76 deletions.
38 changes: 0 additions & 38 deletions pkg/certificateprovider/azurekeyvault/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
38 changes: 0 additions & 38 deletions pkg/keymanagementprovider/azurekeyvault/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit d95e737

Please sign in to comment.