Skip to content

Commit

Permalink
Add an interface for Azure blockstorage to Authenticate credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
Le Tran committed Aug 31, 2022
1 parent 6284b78 commit 2f3a071
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pkg/blockstorage/azure/azuredisk.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,22 @@ func (s *AdStorage) Type() blockstorage.Type {
return blockstorage.TypeAD
}

// Authenticate check Azure creds if the credType is supported
func (s *AdStorage) Authenticate(ctx context.Context, credType string, creds map[string]string) (CredsValidity, error) {
// check if credType is supported
if !isCredTypeSupported(credType) {
return CredsTypeNotSupported, errors.New("Credential type is not supported")
}
// base on cred type: authenticate
switch credType {
case CredTypeManagedIdentity:
msiAuth := &msiAuthenticator{}
return msiAuth.authenticate(creds)
default:
return CredsTypeNotSupported, errors.New("Credential type is not supported")
}
}

// NewProvider returns a provider for the Azure blockstorage type
func NewProvider(ctx context.Context, config map[string]string) (blockstorage.Provider, error) {
azCli, err := NewClient(ctx, config)
Expand Down

0 comments on commit 2f3a071

Please sign in to comment.