-
Notifications
You must be signed in to change notification settings - Fork 863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot use azure.PublicCloud.KeyVaultEndpoint as an OAuth resource #697
Comments
Thanks again @chessman, @jhendrixMSFT will be looking into this |
Some additional context from a conversation I had with @devigned last night: The formatting of this string is getting in the way because we are needing to authenticate against a Resource ID, which happens to look like the KeyVault endpoint, but could be any arbitrary string. For that reason, whether or not the slash is included is important information to send over the wire. As per this bug, we seem to be choosing poorly for KeyVault. To make matters somewhat more confusing, other resource IDs seem to match their endpoints. One thing that should help out this situation is that the 401 that is returned should tell us exactly how to respond. Now that still leaves us a couple of action items we could pursue here:
|
This has been resolved in PR Azure/go-autorest#156, with this new functionality you can write the following authenticator. kv := keyvault.New()
auth := autorest.NewBearerAuthorizerCallback(kv.Sender, func(tenantID, resource string) (*autorest.BearerAuthorizer, error) {
oauthConfig, err := adal.NewOAuthConfig(azure.PublicCloud.ActiveDirectoryEndpoint, tenantID)
if err != nil {
return nil, err
}
spt, err := adal.NewServicePrincipalToken(*oauthConfig, clientID, "secret", resource)
if err != nil {
return nil, err
}
return autorest.NewBearerAuthorizer(spt), nil
})
kv.Authorizer = auth |
I see this issue has been closed and it will work. However I think the fix rely on client sending a request and get 401 response, then correct the resource string. Why don't we just fix the KV resource string? KeyVaultEndpoint: "https://vault.azure.net/", |
@yangl900 |
Possible we define separate KeyVaultResourceUri in the SDK? I would be good if we can avoid making 401s. I understand each service may have different authentication logic, some cares about the trailing slash and some doesn't. But I'm hoping for the core Azure services, we just make it right for user. |
We could do that, please open an issue in this repo to track that (and of course we accept PRs too :)). |
@jhendrixMSFT @yangl900 |
azure.PublicCloud.KeyVaultEndpoint
has a trailing slash. If I get authorizer with this resource, key vault client fails. But it works withhttps://vault.azure.net
.I think, it should be tolerant to trailing slashes.
Reproduction is here: https://github.com/chessman/azure-kv-slash-bug.
The text was updated successfully, but these errors were encountered: