Merge pull request #7276 from paulmey/fix-7267
Fix Azure interactive authentication
This commit is contained in:
commit
9787e787d4
|
@ -10,7 +10,11 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewDeviceFlowOAuthTokenProvider(env azure.Environment, say func(string), tenantID string) oAuthTokenProvider {
|
func NewDeviceFlowOAuthTokenProvider(env azure.Environment, say func(string), tenantID string) oAuthTokenProvider {
|
||||||
return &deviceflowOauthTokenProvider{}
|
return &deviceflowOauthTokenProvider{
|
||||||
|
env: env,
|
||||||
|
say: say,
|
||||||
|
tenantID: tenantID,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type deviceflowOauthTokenProvider struct {
|
type deviceflowOauthTokenProvider struct {
|
||||||
|
|
|
@ -155,8 +155,7 @@ func (c ClientConfig) useDeviceLogin() bool {
|
||||||
c.ClientID == "" &&
|
c.ClientID == "" &&
|
||||||
c.ClientSecret == "" &&
|
c.ClientSecret == "" &&
|
||||||
c.ClientJWT == "" &&
|
c.ClientJWT == "" &&
|
||||||
c.ClientCertPath == "" &&
|
c.ClientCertPath == ""
|
||||||
c.TenantID == ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c ClientConfig) useMSI() bool {
|
func (c ClientConfig) useMSI() bool {
|
||||||
|
|
|
@ -268,11 +268,18 @@ func getCloud() *azure.Environment {
|
||||||
// tests for assertRequiredParametersSet
|
// tests for assertRequiredParametersSet
|
||||||
|
|
||||||
func Test_ClientConfig_CanUseDeviceCode(t *testing.T) {
|
func Test_ClientConfig_CanUseDeviceCode(t *testing.T) {
|
||||||
cfg := emptyClientConfig()
|
// TenantID is optional, but Builder will look up tenant ID before requesting
|
||||||
cfg.SubscriptionID = "12345"
|
t.Run("without TenantID", func(t *testing.T) {
|
||||||
// TenantID is optional
|
cfg := emptyClientConfig()
|
||||||
|
cfg.SubscriptionID = "12345"
|
||||||
assertValid(t, cfg)
|
assertValid(t, cfg)
|
||||||
|
})
|
||||||
|
t.Run("with TenantID", func(t *testing.T) {
|
||||||
|
cfg := emptyClientConfig()
|
||||||
|
cfg.SubscriptionID = "12345"
|
||||||
|
cfg.TenantID = "12345"
|
||||||
|
assertValid(t, cfg)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func assertValid(t *testing.T, cfg ClientConfig) {
|
func assertValid(t *testing.T, cfg ClientConfig) {
|
||||||
|
|
Loading…
Reference in New Issue