Skip to content

Commit

Permalink
check if WIF is enabled on this edition of Vault
Browse files Browse the repository at this point in the history
  • Loading branch information
fairclothjm committed Apr 26, 2024
1 parent 3c6787b commit 733c6e8
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions path_config.go
Expand Up @@ -5,10 +5,12 @@ package azureauth

import (
"context"
"errors"
"time"

"github.com/hashicorp/vault/sdk/framework"
"github.com/hashicorp/vault/sdk/helper/pluginidentityutil"
"github.com/hashicorp/vault/sdk/helper/pluginutil"
"github.com/hashicorp/vault/sdk/logical"
)

Expand Down Expand Up @@ -221,6 +223,19 @@ func (b *azureAuthBackend) pathConfigWrite(ctx context.Context, req *logical.Req
return logical.ErrorResponse("only one of 'client_secret' or 'identity_token_audience' can be set"), nil
}

// generate token to check if WIF is enabled on this edition of Vault
if config.IdentityTokenAudience != "" {
_, err := b.System().GenerateIdentityToken(ctx, &pluginutil.IdentityTokenRequest{
Audience: config.IdentityTokenAudience,
})
if err != nil {
if errors.Is(err, pluginidentityutil.ErrPluginWorkloadIdentityUnsupported) {

Check failure on line 232 in path_config.go

View workflow job for this annotation

GitHub Actions / run-tests / Run Tests

undefined: pluginidentityutil.ErrPluginWorkloadIdentityUnsupported
return logical.ErrorResponse(err.Error()), nil
}
return nil, err
}
}

// Create a settings object to validate all required settings
// are available
if _, err := b.getAzureSettings(ctx, config); err != nil {
Expand Down

0 comments on commit 733c6e8

Please sign in to comment.