...

Package auth

import "github.com/Azure/go-autorest/autorest/azure/auth"
Overview
Index

Overview ▾

Index ▾

Constants
func NewAuthorizerFromCLI() (autorest.Authorizer, error)
func NewAuthorizerFromCLIWithResource(resource string) (autorest.Authorizer, error)
func NewAuthorizerFromEnvironment() (autorest.Authorizer, error)
func NewAuthorizerFromEnvironmentWithResource(resource string) (autorest.Authorizer, error)
func NewAuthorizerFromFile(resourceBaseURI string) (autorest.Authorizer, error)
func NewAuthorizerFromFileWithResource(resource string) (autorest.Authorizer, error)
type AuthorizerConfig
type ClientCertificateConfig
    func NewClientCertificateConfig(certificatePath string, certificatePassword string, clientID string, tenantID string) ClientCertificateConfig
    func (ccc ClientCertificateConfig) Authorizer() (autorest.Authorizer, error)
    func (ccc ClientCertificateConfig) MultiTenantServicePrincipalToken() (*adal.MultiTenantServicePrincipalToken, error)
    func (ccc ClientCertificateConfig) ServicePrincipalToken() (*adal.ServicePrincipalToken, error)
type ClientCredentialsConfig
    func NewClientCredentialsConfig(clientID string, clientSecret string, tenantID string) ClientCredentialsConfig
    func (ccc ClientCredentialsConfig) Authorizer() (autorest.Authorizer, error)
    func (ccc ClientCredentialsConfig) MultiTenantServicePrincipalToken() (*adal.MultiTenantServicePrincipalToken, error)
    func (ccc ClientCredentialsConfig) ServicePrincipalToken() (*adal.ServicePrincipalToken, error)
type DeviceFlowConfig
    func NewDeviceFlowConfig(clientID string, tenantID string) DeviceFlowConfig
    func (dfc DeviceFlowConfig) Authorizer() (autorest.Authorizer, error)
    func (dfc DeviceFlowConfig) ServicePrincipalToken() (*adal.ServicePrincipalToken, error)
type EnvironmentSettings
    func GetSettingsFromEnvironment() (s EnvironmentSettings, err error)
    func (settings EnvironmentSettings) GetAuthorizer() (autorest.Authorizer, error)
    func (settings EnvironmentSettings) GetClientCertificate() (ClientCertificateConfig, error)
    func (settings EnvironmentSettings) GetClientCredentials() (ClientCredentialsConfig, error)
    func (settings EnvironmentSettings) GetDeviceFlow() DeviceFlowConfig
    func (settings EnvironmentSettings) GetMSI() MSIConfig
    func (settings EnvironmentSettings) GetSubscriptionID() string
    func (settings EnvironmentSettings) GetUsernamePassword() (UsernamePasswordConfig, error)
type FileSettings
    func GetSettingsFromFile() (FileSettings, error)
    func (settings FileSettings) ClientCertificateAuthorizer(baseURI string) (autorest.Authorizer, error)
    func (settings FileSettings) ClientCertificateAuthorizerWithResource(resource string) (autorest.Authorizer, error)
    func (settings FileSettings) ClientCredentialsAuthorizer(baseURI string) (autorest.Authorizer, error)
    func (settings FileSettings) ClientCredentialsAuthorizerWithResource(resource string) (autorest.Authorizer, error)
    func (settings FileSettings) GetAuthorizer(resourceBaseURI string) (autorest.Authorizer, error)
    func (settings FileSettings) GetSubscriptionID() string
    func (settings FileSettings) ServicePrincipalTokenFromClientCertificate(baseURI string) (*adal.ServicePrincipalToken, error)
    func (settings FileSettings) ServicePrincipalTokenFromClientCertificateWithResource(resource string) (*adal.ServicePrincipalToken, error)
    func (settings FileSettings) ServicePrincipalTokenFromClientCredentials(baseURI string) (*adal.ServicePrincipalToken, error)
    func (settings FileSettings) ServicePrincipalTokenFromClientCredentialsWithResource(resource string) (*adal.ServicePrincipalToken, error)
type MSIConfig
    func NewMSIConfig() MSIConfig
    func (mc MSIConfig) Authorizer() (autorest.Authorizer, error)
    func (mc MSIConfig) ServicePrincipalToken() (*adal.ServicePrincipalToken, error)
type UsernamePasswordConfig
    func NewUsernamePasswordConfig(username string, password string, clientID string, tenantID string) UsernamePasswordConfig
    func (ups UsernamePasswordConfig) Authorizer() (autorest.Authorizer, error)
    func (ups UsernamePasswordConfig) ServicePrincipalToken() (*adal.ServicePrincipalToken, error)

Package files

auth.go

Constants

The possible keys in the Values map.

const (
    SubscriptionID          = "AZURE_SUBSCRIPTION_ID"
    TenantID                = "AZURE_TENANT_ID"
    AuxiliaryTenantIDs      = "AZURE_AUXILIARY_TENANT_IDS"
    ClientID                = "AZURE_CLIENT_ID"
    ClientSecret            = "AZURE_CLIENT_SECRET"
    CertificatePath         = "AZURE_CERTIFICATE_PATH"
    CertificatePassword     = "AZURE_CERTIFICATE_PASSWORD"
    Username                = "AZURE_USERNAME"
    Password                = "AZURE_PASSWORD"
    EnvironmentName         = "AZURE_ENVIRONMENT"
    Resource                = "AZURE_AD_RESOURCE"
    ActiveDirectoryEndpoint = "ActiveDirectoryEndpoint"
    ResourceManagerEndpoint = "ResourceManagerEndpoint"
    GraphResourceID         = "GraphResourceID"
    SQLManagementEndpoint   = "SQLManagementEndpoint"
    GalleryEndpoint         = "GalleryEndpoint"
    ManagementEndpoint      = "ManagementEndpoint"
)

func NewAuthorizerFromCLI

func NewAuthorizerFromCLI() (autorest.Authorizer, error)

NewAuthorizerFromCLI creates an Authorizer configured from Azure CLI 2.0 for local development scenarios.

func NewAuthorizerFromCLIWithResource

func NewAuthorizerFromCLIWithResource(resource string) (autorest.Authorizer, error)

NewAuthorizerFromCLIWithResource creates an Authorizer configured from Azure CLI 2.0 for local development scenarios.

func NewAuthorizerFromEnvironment

func NewAuthorizerFromEnvironment() (autorest.Authorizer, error)

NewAuthorizerFromEnvironment creates an Authorizer configured from environment variables in the order: 1. Client credentials 2. Client certificate 3. Username password 4. MSI

func NewAuthorizerFromEnvironmentWithResource

func NewAuthorizerFromEnvironmentWithResource(resource string) (autorest.Authorizer, error)

NewAuthorizerFromEnvironmentWithResource creates an Authorizer configured from environment variables in the order: 1. Client credentials 2. Client certificate 3. Username password 4. MSI

func NewAuthorizerFromFile

func NewAuthorizerFromFile(resourceBaseURI string) (autorest.Authorizer, error)

NewAuthorizerFromFile creates an Authorizer configured from a configuration file in the following order. 1. Client credentials 2. Client certificate The path to the configuration file must be specified in the AZURE_AUTH_LOCATION environment variable. resourceBaseURI - used to determine the resource type

func NewAuthorizerFromFileWithResource

func NewAuthorizerFromFileWithResource(resource string) (autorest.Authorizer, error)

NewAuthorizerFromFileWithResource creates an Authorizer configured from a configuration file in the following order. 1. Client credentials 2. Client certificate The path to the configuration file must be specified in the AZURE_AUTH_LOCATION environment variable.

type AuthorizerConfig

AuthorizerConfig provides an authorizer from the configuration provided.

type AuthorizerConfig interface {
    Authorizer() (autorest.Authorizer, error)
}

type ClientCertificateConfig

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

type ClientCertificateConfig struct {
    ClientID            string
    CertificatePath     string
    CertificatePassword string
    TenantID            string
    AuxTenants          []string
    AADEndpoint         string
    Resource            string
}

func NewClientCertificateConfig

func NewClientCertificateConfig(certificatePath string, certificatePassword string, clientID string, tenantID string) ClientCertificateConfig

NewClientCertificateConfig creates a ClientCertificateConfig object configured to obtain an Authorizer through client certificate. Defaults to Public Cloud and Resource Manager Endpoint.

func (ClientCertificateConfig) Authorizer

func (ccc ClientCertificateConfig) Authorizer() (autorest.Authorizer, error)

Authorizer gets an authorizer object from client certificate.

func (ClientCertificateConfig) MultiTenantServicePrincipalToken

func (ccc ClientCertificateConfig) MultiTenantServicePrincipalToken() (*adal.MultiTenantServicePrincipalToken, error)

MultiTenantServicePrincipalToken creates a MultiTenantServicePrincipalToken from client certificate.

func (ClientCertificateConfig) ServicePrincipalToken

func (ccc ClientCertificateConfig) ServicePrincipalToken() (*adal.ServicePrincipalToken, error)

ServicePrincipalToken creates a ServicePrincipalToken from client certificate.

type ClientCredentialsConfig

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

type ClientCredentialsConfig struct {
    ClientID     string
    ClientSecret string
    TenantID     string
    AuxTenants   []string
    AADEndpoint  string
    Resource     string
}

func NewClientCredentialsConfig

func NewClientCredentialsConfig(clientID string, clientSecret string, tenantID string) ClientCredentialsConfig

NewClientCredentialsConfig creates an AuthorizerConfig object configured to obtain an Authorizer through Client Credentials. Defaults to Public Cloud and Resource Manager Endpoint.

func (ClientCredentialsConfig) Authorizer

func (ccc ClientCredentialsConfig) Authorizer() (autorest.Authorizer, error)

Authorizer gets the authorizer from client credentials.

func (ClientCredentialsConfig) MultiTenantServicePrincipalToken

func (ccc ClientCredentialsConfig) MultiTenantServicePrincipalToken() (*adal.MultiTenantServicePrincipalToken, error)

MultiTenantServicePrincipalToken creates a MultiTenantServicePrincipalToken from client credentials.

func (ClientCredentialsConfig) ServicePrincipalToken

func (ccc ClientCredentialsConfig) ServicePrincipalToken() (*adal.ServicePrincipalToken, error)

ServicePrincipalToken creates a ServicePrincipalToken from client credentials.

type DeviceFlowConfig

DeviceFlowConfig provides the options to get a bearer authorizer using device flow authentication.

type DeviceFlowConfig struct {
    ClientID    string
    TenantID    string
    AADEndpoint string
    Resource    string
}

func NewDeviceFlowConfig

func NewDeviceFlowConfig(clientID string, tenantID string) DeviceFlowConfig

NewDeviceFlowConfig creates a DeviceFlowConfig object configured to obtain an Authorizer through device flow. Defaults to Public Cloud and Resource Manager Endpoint.

func (DeviceFlowConfig) Authorizer

func (dfc DeviceFlowConfig) Authorizer() (autorest.Authorizer, error)

Authorizer gets the authorizer from device flow.

func (DeviceFlowConfig) ServicePrincipalToken

func (dfc DeviceFlowConfig) ServicePrincipalToken() (*adal.ServicePrincipalToken, error)

ServicePrincipalToken gets the service principal token from device flow.

type EnvironmentSettings

EnvironmentSettings contains the available authentication settings.

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

func GetSettingsFromEnvironment

func GetSettingsFromEnvironment() (s EnvironmentSettings, err error)

GetSettingsFromEnvironment returns the available authentication settings from the environment.

func (EnvironmentSettings) GetAuthorizer

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

GetAuthorizer creates an Authorizer configured from environment variables in the order: 1. Client credentials 2. Client certificate 3. Username password 4. MSI

func (EnvironmentSettings) GetClientCertificate

func (settings EnvironmentSettings) GetClientCertificate() (ClientCertificateConfig, error)

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

func (EnvironmentSettings) GetClientCredentials

func (settings EnvironmentSettings) GetClientCredentials() (ClientCredentialsConfig, error)

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

func (EnvironmentSettings) GetDeviceFlow

func (settings EnvironmentSettings) GetDeviceFlow() DeviceFlowConfig

GetDeviceFlow creates a device-flow config object from the available client and tenant IDs.

func (EnvironmentSettings) GetMSI

func (settings EnvironmentSettings) GetMSI() MSIConfig

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

func (EnvironmentSettings) GetSubscriptionID

func (settings EnvironmentSettings) GetSubscriptionID() string

GetSubscriptionID returns the available subscription ID or an empty string.

func (EnvironmentSettings) GetUsernamePassword

func (settings EnvironmentSettings) GetUsernamePassword() (UsernamePasswordConfig, error)

GetUsernamePassword creates a config object from the available username/password credentials. An error is returned if no username/password credentials are available.

type FileSettings

FileSettings contains the available authentication settings.

type FileSettings struct {
    Values map[string]string
}

func GetSettingsFromFile

func GetSettingsFromFile() (FileSettings, error)

GetSettingsFromFile returns the available authentication settings from an Azure CLI authentication file.

func (FileSettings) ClientCertificateAuthorizer

func (settings FileSettings) ClientCertificateAuthorizer(baseURI string) (autorest.Authorizer, error)

ClientCertificateAuthorizer creates an authorizer from the available certificate credentials.

func (FileSettings) ClientCertificateAuthorizerWithResource

func (settings FileSettings) ClientCertificateAuthorizerWithResource(resource string) (autorest.Authorizer, error)

ClientCertificateAuthorizerWithResource creates an authorizer from the available certificate credentials and the specified resource.

func (FileSettings) ClientCredentialsAuthorizer

func (settings FileSettings) ClientCredentialsAuthorizer(baseURI string) (autorest.Authorizer, error)

ClientCredentialsAuthorizer creates an authorizer from the available client credentials.

func (FileSettings) ClientCredentialsAuthorizerWithResource

func (settings FileSettings) ClientCredentialsAuthorizerWithResource(resource string) (autorest.Authorizer, error)

ClientCredentialsAuthorizerWithResource creates an authorizer from the available client credentials and the specified resource.

func (FileSettings) GetAuthorizer

func (settings FileSettings) GetAuthorizer(resourceBaseURI string) (autorest.Authorizer, error)

GetAuthorizer create an Authorizer in the following order. 1. Client credentials 2. Client certificate resourceBaseURI - used to determine the resource type

func (FileSettings) GetSubscriptionID

func (settings FileSettings) GetSubscriptionID() string

GetSubscriptionID returns the available subscription ID or an empty string.

func (FileSettings) ServicePrincipalTokenFromClientCertificate

func (settings FileSettings) ServicePrincipalTokenFromClientCertificate(baseURI string) (*adal.ServicePrincipalToken, error)

ServicePrincipalTokenFromClientCertificate creates a ServicePrincipalToken from the available certificate credentials.

func (FileSettings) ServicePrincipalTokenFromClientCertificateWithResource

func (settings FileSettings) ServicePrincipalTokenFromClientCertificateWithResource(resource string) (*adal.ServicePrincipalToken, error)

ServicePrincipalTokenFromClientCertificateWithResource creates a ServicePrincipalToken from the available certificate credentials.

func (FileSettings) ServicePrincipalTokenFromClientCredentials

func (settings FileSettings) ServicePrincipalTokenFromClientCredentials(baseURI string) (*adal.ServicePrincipalToken, error)

ServicePrincipalTokenFromClientCredentials creates a ServicePrincipalToken from the available client credentials.

func (FileSettings) ServicePrincipalTokenFromClientCredentialsWithResource

func (settings FileSettings) ServicePrincipalTokenFromClientCredentialsWithResource(resource string) (*adal.ServicePrincipalToken, error)

ServicePrincipalTokenFromClientCredentialsWithResource creates a ServicePrincipalToken from the available client credentials and the specified resource.

type MSIConfig

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

type MSIConfig struct {
    Resource string
    ClientID string
}

func NewMSIConfig

func NewMSIConfig() MSIConfig

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

func (MSIConfig) Authorizer

func (mc MSIConfig) Authorizer() (autorest.Authorizer, error)

Authorizer gets the authorizer from MSI.

func (MSIConfig) ServicePrincipalToken

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

ServicePrincipalToken creates a ServicePrincipalToken from MSI.

type UsernamePasswordConfig

UsernamePasswordConfig provides the options to get a bearer authorizer from a username and a password.

type UsernamePasswordConfig struct {
    ClientID    string
    Username    string
    Password    string
    TenantID    string
    AADEndpoint string
    Resource    string
}

func NewUsernamePasswordConfig

func NewUsernamePasswordConfig(username string, password string, clientID string, tenantID string) UsernamePasswordConfig

NewUsernamePasswordConfig creates an UsernamePasswordConfig object configured to obtain an Authorizer through username and password. Defaults to Public Cloud and Resource Manager Endpoint.

func (UsernamePasswordConfig) Authorizer

func (ups UsernamePasswordConfig) Authorizer() (autorest.Authorizer, error)

Authorizer gets the authorizer from a username and a password.

func (UsernamePasswordConfig) ServicePrincipalToken

func (ups UsernamePasswordConfig) ServicePrincipalToken() (*adal.ServicePrincipalToken, error)

ServicePrincipalToken creates a ServicePrincipalToken from username and password.