Azure / azure-sdk-for-go

This repository is for active development of the Azure SDK for Go. For consumers of the SDK we recommend visiting our public developer docs at:
https://docs.microsoft.com/azure/developer/go/
MIT License
1.65k stars 844 forks source link

[Question] Should SharedKeyCredential be included in azidentity? #15024

Closed ambientlight closed 3 years ago

ambientlight commented 3 years ago

Feature Request

In addition to AAD authentication, Azure Maps supports Shared Key Authentication like:

import (
    "github.com/Azure/azure-sdk-for-go/sdk/azcore"
)

type SharedKeyCredential struct {
    SubscriptionKey string
}

func (creds SharedKeyCredential) AuthenticationPolicy(options azcore.AuthenticationPolicyOptions) azcore.Policy {
    return azcore.PolicyFunc(func(req *azcore.Request) (*azcore.Response, error) {
        q := req.URL.Query()
        q.Add("subscription-key", creds.SubscriptionKey)
        req.URL.RawQuery = q.Encode()
        return req.Next()
    })
}

I haven't found such policy in sdk/azidentity/. Should something like above (probably with query parameter name also parametrizable) be included in azidentity module, or we should include it alongside our generated clients like in https://github.com/ambientlight/azure-sdk-for-go/commit/878a016305e8b4e2a89206ef5a0595d230bb2bc1 ?

jhendrixMSFT commented 3 years ago

The way it was explained to me is that azidentity is all about acquiring token credentials, so things like shared key are excluded. Also, are all shared key implementations uniform? My limited understanding is no.

For reference, azblob includes its own SharedKeyCredential here.

CC @schaabs