azure

package
v1.9.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AzureServiceBusResourceName string = "servicebus"
	AzureEventHubsResourceName  string = "eventhubs"
)
View Source
const DefaultAzureEnvironment = "AZUREPUBLICCLOUD"

Default Azure environment.

Variables

View Source
var (
	StorageAccountNameKeys   = []string{"accountName", "storageAccount", "storageAccountName"}
	StorageAccountKeyKeys    = []string{"accountKey", "accessKey", "storageAccessKey", "storageAccountKey"}
	StorageContainerNameKeys = []string{"containerName", "container", "storageAccountContainer"}
	StorageQueueNameKeys     = []string{"queueName", "queue", "storageAccountQueue"}
	StorageTableNameKeys     = []string{"tableName", "table", "storageAccountTable"}
	StorageEndpointKeys      = []string{"endpoint", "storageEndpoint", "storageAccountEndpoint", "queueEndpointUrl"}
)
View Source
var MetadataKeys = map[string][]string{

	"Certificate": {"azureCertificate", "spnCertificate"},

	"CertificateFile": {"azureCertificateFile", "spnCertificateFile"},

	"CertificatePassword": {"azureCertificatePassword", "spnCertificatePassword"},

	"ClientID": {"azureClientId", "spnClientId", "clientId"},

	"ClientSecret": {"azureClientSecret", "spnClientSecret", "clientSecret"},

	"TenantID": {"azureTenantId", "spnTenantId", "tenantId"},

	"AzureEnvironment": {"azureEnvironment"},
}

MetadataKeys : Keys for all metadata properties.

Functions

func GetAzureStorageBlobCredentials

func GetAzureStorageBlobCredentials(log logger.Logger, accountName string, metadata map[string]string) (azblob.Credential, *azure.Environment, error)

GetAzureStorageBlobCredentials returns a azblob.Credential object that can be used to authenticate an Azure Blob Storage SDK pipeline ("track 1"). First it tries to authenticate using shared key credentials (using an account key) if present. It falls back to attempting to use Azure AD (via a service principal or MSI).

func GetAzureStorageQueueCredentials

func GetAzureStorageQueueCredentials(log logger.Logger, accountName string, metadata map[string]string) (azqueue.Credential, *azure.Environment, error)

GetAzureStorageQueueCredentials returns a azqueues.Credential object that can be used to authenticate an Azure Queue Storage SDK pipeline ("track 1"). First it tries to authenticate using shared key credentials (using an account key) if present. It falls back to attempting to use Azure AD (via a service principal or MSI).

Types

type CertConfig

type CertConfig struct {
	*auth.ClientCertificateConfig
	CertificateData []byte
}

CertConfig provides the options to get a bearer authorizer from a client certificate.

func NewCertConfig

func NewCertConfig(clientID string, tenantID string, certificatePath string, certificateBytes []byte, certificatePassword string, resource string, env *azure.Environment) CertConfig

NewCertConfig creates an CertConfig object configured to obtain an Authorizer through Client Credentials, using a certificate.

func (CertConfig) GetTokenCredential

func (c CertConfig) GetTokenCredential() (token azcore.TokenCredential, err error)

GetTokenCredential returns the azcore.TokenCredential object from client certificate.

func (CertConfig) ServicePrincipalToken

func (c CertConfig) ServicePrincipalToken() (*adal.ServicePrincipalToken, error)

ServicePrincipalToken gets a ServicePrincipalToken object from client certificate.

func (CertConfig) ServicePrincipalTokenByCertBytes

func (c CertConfig) ServicePrincipalTokenByCertBytes() (*adal.ServicePrincipalToken, error)

ServicePrincipalTokenByCertBytes gets the service principal token by CertificateBytes.

type CredentialsConfig

type CredentialsConfig struct {
	*auth.ClientCredentialsConfig
}

CredentialsConfig provides the options to get a bearer authorizer from client credentials.

func NewCredentialsConfig

func NewCredentialsConfig(clientID string, tenantID string, clientSecret string, resource string, env *azure.Environment) CredentialsConfig

NewCredentialsConfig creates an CredentialsConfig object configured to obtain an Authorizer through Client Credentials.

func (CredentialsConfig) GetTokenCredential

func (c CredentialsConfig) GetTokenCredential() (token azcore.TokenCredential, err error)

GetTokenCredential returns the azcore.TokenCredential object from the credentials.

func (CredentialsConfig) ServicePrincipalToken

func (c CredentialsConfig) ServicePrincipalToken() (*adal.ServicePrincipalToken, error)

ServicePrincipalToken gets a ServicePrincipalToken object from the credentials.

type EnvironmentSettings

type EnvironmentSettings struct {
	Values           map[string]string
	Resource         string
	AzureEnvironment *azure.Environment
}

EnvironmentSettings hold settings to authenticate with Azure.

func NewEnvironmentSettings

func NewEnvironmentSettings(resourceName string, values map[string]string) (EnvironmentSettings, error)

NewEnvironmentSettings returns a new EnvironmentSettings configured for a given Azure resource.

func (EnvironmentSettings) GetAMQPTokenProvider

func (s EnvironmentSettings) GetAMQPTokenProvider() (*amqpaad.TokenProvider, error)

GetAMQPTokenProvider creates a TokenProvider for AAD for AMQP retrieved from, in order: 1. Client credentials 2. Client certificate 3. MSI.

func (EnvironmentSettings) GetAuthorizer

func (s EnvironmentSettings) GetAuthorizer() (autorest.Authorizer, error)

GetAuthorizer creates an Authorizer retrieved from, in order: 1. Client credentials 2. Client certificate 3. MSI This is used by the older Azure SDKs.

func (EnvironmentSettings) GetAzureEnvironment

func (s EnvironmentSettings) GetAzureEnvironment() (*azure.Environment, error)

GetAzureEnvironment returns the Azure environment for a given name.

func (EnvironmentSettings) GetClientCert

func (s EnvironmentSettings) GetClientCert() (CertConfig, error)

GetClientCert creates a config object from the available certificate credentials. An error is returned if no certificate credentials are available.

func (EnvironmentSettings) GetClientCredentials

func (s EnvironmentSettings) GetClientCredentials() (CredentialsConfig, error)

GetClientCredentials creates a config object from the available client credentials. An error is returned if no certificate credentials are available.

func (EnvironmentSettings) GetEnvironment

func (s EnvironmentSettings) GetEnvironment(key string) (val string, ok bool)

GetAzureEnvironment returns the Azure environment for a given name, supporting aliases too.

func (EnvironmentSettings) GetMSI

func (s EnvironmentSettings) GetMSI() MSIConfig

GetMSI creates a MSI config object from the available client ID.

func (EnvironmentSettings) GetServicePrincipalToken

func (s EnvironmentSettings) GetServicePrincipalToken() (*adal.ServicePrincipalToken, error)

GetServicePrincipalToken returns a Service Principal Token retrieved from, in order: 1. Client credentials 2. Client certificate 3. MSI This is used by the older Azure SDKs.

func (EnvironmentSettings) GetTokenCredential

func (s EnvironmentSettings) GetTokenCredential() (azcore.TokenCredential, error)

GetTokenCredential returns an azcore.TokenCredential retrieved from, in order: 1. Client credentials 2. Client certificate 3. MSI This is used by the newer ("track 2") Azure SDKs.

type MSIConfig

type MSIConfig struct {
	Resource string
	ClientID string
}

MSIConfig provides the options to get a bearer authorizer through MSI.

func NewMSIConfig

func NewMSIConfig(resource string) MSIConfig

NewMSIConfig creates an MSIConfig object configured to obtain an Authorizer through MSI.

func (MSIConfig) GetTokenCredential

func (c MSIConfig) GetTokenCredential() (token azcore.TokenCredential, err error)

GetTokenCredential returns the azcore.TokenCredential object from MSI.

func (MSIConfig) ServicePrincipalToken

func (c MSIConfig) ServicePrincipalToken() (*adal.ServicePrincipalToken, error)

ServicePrincipalToken gets the ServicePrincipalToken object from MSI.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL