forked from dapr/components-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move Service Bus Pubsub/Binding to common auth (dapr#1201)
* Move Service Bus Pubsub/Binding to common auth Both the pubsub and input/output binding for Azure Service Bus were connecting via a connection string. This is still supported but will now fallback to using AAD from the common auth library. This is also the recommended auth pattern going forward. * Move AMPQ specific auth and fix linter issues * Make conn string and namespace mutually exclusive * Move resourceName to a constant * Update auth_amqp.go * Update auth.go Co-authored-by: Long Dai <long.dai@intel.com> Co-authored-by: Simon Leet <31784195+CodeMonkeyLeet@users.noreply.github.com> Co-authored-by: Artur Souza <artursouza.ms@outlook.com> Co-authored-by: Dapr Bot <56698301+dapr-bot@users.noreply.github.com> Signed-off-by: Amit Mor <amitm@at-bay.com>
- Loading branch information
Showing
7 changed files
with
210 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// ------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation and Dapr Contributors. | ||
// Licensed under the MIT License. | ||
// ------------------------------------------------------------ | ||
|
||
package azure | ||
|
||
import "github.com/Azure/azure-amqp-common-go/v3/aad" | ||
|
||
const ( | ||
AzureServiceBusResourceName string = "servicebus" | ||
) | ||
|
||
// GetTokenProvider creates a TokenProvider for AAD retrieved from, in order: | ||
// 1. Client credentials | ||
// 2. Client certificate | ||
// 3. MSI. | ||
func (s EnvironmentSettings) GetAADTokenProvider() (*aad.TokenProvider, error) { | ||
spt, err := s.GetServicePrincipalToken() | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return aad.NewJWTProvider(aad.JWTProviderWithAADToken(spt), aad.JWTProviderWithAzureEnvironment(s.AzureEnvironment)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters