azure

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultAzureEnvironment = "AZUREPUBLICCLOUD"

Default Azure environment

Variables

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 GetAzureStorageCredentials

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

GetAzureStorageCredentials returns a azblob.Credential object that can be used to authenticate an Azure Blob Storage SDK pipeline. 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) 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) 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) GetAuthorizer

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

GetAuthorizer creates an Authorizer retrieved from, in order: 1. Client credentials 2. Client certificate 3. MSI

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) (string, 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

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) ServicePrincipalToken

func (mc 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