auth

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2017 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package auth provides Google oauth2 and Azure credential bindings for mantle.

Index

Constants

View Source
const AzureProfilePath = ".azure/azureProfile.json"

Variables

This section is empty.

Functions

func GoogleClient

func GoogleClient() (*http.Client, error)

GoogleClient provides an http.Client authorized with an oauth2 token that is automatically cached and refreshed from a file named '.mantle-cache-google.json'. This uses interactive oauth2 authorization and requires a user follow to follow a web link and paste in an authorization token.

func GoogleClientFromJSONKey

func GoogleClientFromJSONKey(jsonKey []byte, scope ...string) (*http.Client, error)

GoogleClientFromJSONKey provides an http.Client authorized with an oauth2 token retrieved using a Google Developers service account's private JSON key file.

func GoogleServiceClient

func GoogleServiceClient() *http.Client

GoogleServiceClient fetchs a token from Google Compute Engine's metadata service. This should be used on GCE vms. The Default account is used.

func GoogleServiceTokenSource

func GoogleServiceTokenSource() oauth2.TokenSource

GoogleServiceTokenSource provides an oauth2.TokenSource authorized in the same manner as GoogleServiceClient().

func GoogleTokenSource

func GoogleTokenSource() (oauth2.TokenSource, error)

GoogleTokenSource provides an outh2.TokenSource authorized in the same manner as GoogleClient.

func GoogleTokenSourceFromJSONKey

func GoogleTokenSourceFromJSONKey(jsonKey []byte, scope ...string) (oauth2.TokenSource, error)

GoogleTokenSourceFromJSONKey provides an oauth2.TokenSource authorized in the same manner as GoogleClientFromJSONKey.

Types

type AzureEnvironment added in v0.3.0

type AzureEnvironment struct {
	ActiveDirectoryEndpointURL                        string `json:"activeDirectoryEndpointUrl"`
	ActiveDirectoryGraphAPIVersion                    string `json:"activeDirectoryGraphApiVersion"`
	ActiveDirectoryGraphResourceID                    string `json:"activeDirectoryGraphResourceId"`
	ActiveDirectoryResourceID                         string `json:"activeDirectoryResourceId"`
	AzureDataLakeAnalyticsCatalogAndJobEndpointSuffix string `json:"azureDataLakeAnalyticsCatalogAndJobEndpointSuffix"`
	AzureDataLakeStoreFileSystemEndpointSuffix        string `json:"azureDataLakeStoreFileSystemEndpointSuffix"`
	GalleryEndpointURL                                string `json:"galleryEndpointUrl"`
	KeyVaultDNSSuffix                                 string `json:"keyVaultDnsSuffix"`
	ManagementEndpointURL                             string `json:"managementEndpointUrl"`
	Name                                              string `json:"name"`
	PortalURL                                         string `json:"portalUrl"`
	PublishingProfileURL                              string `json:"publishingProfileUrl"`
	ResourceManagerEndpointURL                        string `json:"resourceManagerEndpointUrl"`
	SqlManagementEndpointURL                          string `json:"sqlManagementEndpointUrl"`
	SqlServerHostnameSuffix                           string `json:"sqlServerHostnameSuffix"`
	StorageEndpointSuffix                             string `json:"storageEndpointSuffix"`
}

type AzureManagementCertificate added in v0.3.0

type AzureManagementCertificate struct {
	Cert string `json:"cert"`
	Key  string `json:"key"`
}

type AzureProfile added in v0.3.0

type AzureProfile struct {
	Environments  []AzureEnvironment  `json:"environments"`
	Subscriptions []AzureSubscription `json:"subscriptions"`
}

AzureProfile represents a parsed Azure Profile Configuration File.

func ReadAzureProfile added in v0.3.0

func ReadAzureProfile(path string) (*AzureProfile, error)

ReadAzureProfile decodes an Azure Profile, as created by the Azure Cross-platform CLI.

If path is empty, $HOME/.azure/azureProfile.json is read.

func (*AzureProfile) AsOptions added in v0.3.0

func (ap *AzureProfile) AsOptions() []azure.Options

AsOptions converts all subscriptions into a slice of azure.Options. If there is an environment with a name matching the subscription, that environment's storage endpoint will be copied to the options.

func (*AzureProfile) SubscriptionOptions added in v0.3.0

func (ap *AzureProfile) SubscriptionOptions(name string) *azure.Options

SubscriptionOptions returns the name subscription in the Azure profile as a azure.Options struct. If the subscription name is "", the first subscription is returned. If there are no subscriptions or the named subscription is not found, SubscriptionOptions returns nil.

type AzureSubscription added in v0.3.0

type AzureSubscription struct {
	EnvironmentName       string                     `json:"environmentName"`
	ID                    string                     `json:"id"`
	IsDefault             bool                       `json:"isDefault"`
	ManagementCertificate AzureManagementCertificate `json:"managementCertificate"`
	ManagementEndpointURL string                     `json:"managementEndpointUrl"`
	Name                  string                     `json:"name"`
	RegisteredProviders   []string                   `json:"registeredProviders"`
	State                 string                     `json:"state"`
}

Jump to

Keyboard shortcuts

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