option to pass managed identity client id to AD authentication (#45)
* https://github.com/Azure/azure-amqp-common-go/issues/44 option to use managed identity to be used for MSI authentication * https://github.com/Azure/azure-amqp-common-go/issues/44 option to use managed identity to be used for MSI authentication * fix formatting * rename method Co-authored-by: Muthusamy Saravanan <saravanan.muthusamy@bluvision.com> Co-authored-by: Joel Hendrix <jhendrix@microsoft.com>
This commit is contained in:
Родитель
27bcf08005
Коммит
43896b23e5
|
@ -188,7 +188,7 @@ func (c *TokenProviderConfiguration) NewServicePrincipalToken() (*adal.ServicePr
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
spToken, err := adal.NewServicePrincipalTokenFromMSI(msiEndpoint, c.ResourceURI)
|
||||
spToken, err := c.getMSIToken(msiEndpoint)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get oauth token from MSI: %v", err)
|
||||
}
|
||||
|
@ -198,6 +198,13 @@ func (c *TokenProviderConfiguration) NewServicePrincipalToken() (*adal.ServicePr
|
|||
return spToken, nil
|
||||
}
|
||||
|
||||
func (c *TokenProviderConfiguration) getMSIToken(msiEndpoint string) (*adal.ServicePrincipalToken, error) {
|
||||
if c.ClientID == "" {
|
||||
return adal.NewServicePrincipalTokenFromMSI(msiEndpoint, c.ResourceURI)
|
||||
}
|
||||
return adal.NewServicePrincipalTokenFromMSIWithUserAssignedID(msiEndpoint, c.ResourceURI, c.ClientID)
|
||||
}
|
||||
|
||||
// GetToken gets a CBS JWT
|
||||
func (t *TokenProvider) GetToken(audience string) (*auth.Token, error) {
|
||||
token := t.tokenProvider.Token()
|
||||
|
|
Загрузка…
Ссылка в новой задаче