mirror of
https://github.com/go-acme/lego.git
synced 2025-01-07 08:57:00 +02:00
azure: Allow for the use of MSI (#1110)
This commit is contained in:
parent
ae818a411c
commit
1ac1986687
1
go.mod
1
go.mod
@ -6,7 +6,6 @@ require (
|
|||||||
cloud.google.com/go v0.54.0
|
cloud.google.com/go v0.54.0
|
||||||
github.com/Azure/azure-sdk-for-go v32.4.0+incompatible
|
github.com/Azure/azure-sdk-for-go v32.4.0+incompatible
|
||||||
github.com/Azure/go-autorest/autorest v0.5.0
|
github.com/Azure/go-autorest/autorest v0.5.0
|
||||||
github.com/Azure/go-autorest/autorest/adal v0.2.0
|
|
||||||
github.com/Azure/go-autorest/autorest/azure/auth v0.1.0
|
github.com/Azure/go-autorest/autorest/azure/auth v0.1.0
|
||||||
github.com/Azure/go-autorest/autorest/to v0.2.0
|
github.com/Azure/go-autorest/autorest/to v0.2.0
|
||||||
github.com/Azure/go-autorest/autorest/validation v0.1.0 // indirect
|
github.com/Azure/go-autorest/autorest/validation v0.1.0 // indirect
|
||||||
|
@ -13,8 +13,6 @@ import (
|
|||||||
|
|
||||||
"github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2017-09-01/dns"
|
"github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2017-09-01/dns"
|
||||||
"github.com/Azure/go-autorest/autorest"
|
"github.com/Azure/go-autorest/autorest"
|
||||||
"github.com/Azure/go-autorest/autorest/adal"
|
|
||||||
"github.com/Azure/go-autorest/autorest/azure"
|
|
||||||
"github.com/Azure/go-autorest/autorest/azure/auth"
|
"github.com/Azure/go-autorest/autorest/azure/auth"
|
||||||
"github.com/Azure/go-autorest/autorest/to"
|
"github.com/Azure/go-autorest/autorest/to"
|
||||||
"github.com/go-acme/lego/v3/challenge/dns01"
|
"github.com/go-acme/lego/v3/challenge/dns01"
|
||||||
@ -240,20 +238,17 @@ func toRelativeRecord(domain, zone string) string {
|
|||||||
|
|
||||||
func getAuthorizer(config *Config) (autorest.Authorizer, error) {
|
func getAuthorizer(config *Config) (autorest.Authorizer, error) {
|
||||||
if config.ClientID != "" && config.ClientSecret != "" && config.TenantID != "" {
|
if config.ClientID != "" && config.ClientSecret != "" && config.TenantID != "" {
|
||||||
oauthConfig, err := adal.NewOAuthConfig(azure.PublicCloud.ActiveDirectoryEndpoint, config.TenantID)
|
credentialsConfig := auth.NewClientCredentialsConfig(config.ClientID, config.ClientSecret, config.TenantID)
|
||||||
|
|
||||||
|
spToken, err := credentialsConfig.ServicePrincipalToken()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, fmt.Errorf("failed to get oauth token from client credentials: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
spt, err := adal.NewServicePrincipalToken(*oauthConfig, config.ClientID, config.ClientSecret, azure.PublicCloud.ResourceManagerEndpoint)
|
spToken.SetSender(config.HTTPClient)
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
spt.SetSender(config.HTTPClient)
|
return autorest.NewBearerAuthorizer(spToken), nil
|
||||||
return autorest.NewBearerAuthorizer(spt), nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return auth.NewAuthorizerFromEnvironment()
|
return auth.NewAuthorizerFromEnvironment()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user