auth

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

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

Index

Constants

View Source
const AliyunConfigPath = ".aliyun/config.json"
View Source
const (
	AzureCredentialsPath = ".azure/azureCreds.json"
)
View Source
const DOConfigPath = ".config/digitalocean.json"
View Source
const ESXConfigPath = ".config/esx.json"
View Source
const GCPConfigPath = ".config/gcp.json"
View Source
const PacketConfigPath = ".config/packet.json"

Variables

This section is empty.

Functions

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 GoogleClientFromKeyFile

func GoogleClientFromKeyFile(path string, scope ...string) (*http.Client, error)

func GoogleServiceClient

func GoogleServiceClient() *http.Client

GoogleServiceClient fetchs a token from Google Compute Engine's metadata service. This should be used on GCP 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 GoogleTokenSourceFromJSONKey

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

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

func ReadAliyunConfig

func ReadAliyunConfig(path string) (map[string]AliyunProfile, error)

ReadAliyunConfig decodes an aliyun config file

If path is empty, $HOME/.aliyun/config.json is read.

func ReadDOConfig

func ReadDOConfig(path string) (map[string]DOProfile, error)

ReadDOConfig decodes a DigitalOcean config file, which is a custom format used by Mantle to hold personal access tokens.

If path is empty, $HOME/.config/digitalocean.json is read.

func ReadESXConfig

func ReadESXConfig(path string) (map[string]ESXProfile, error)

ReadESXConfig decodes a ESX config file, which is a custom format used by Mantle to hold ESX server information.

If path is empty, $HOME/.config/esx.json is read.

func ReadPacketConfig

func ReadPacketConfig(path string) (map[string]PacketProfile, error)

ReadPacketConfig decodes a Packet config file, which is a custom format used by Mantle to hold API keys.

If path is empty, $HOME/.config/packet.json is read.

Types

type AliyunConfig

type AliyunConfig struct {
	Profiles []AliyunProfile `json:"profiles"`
}

type AliyunProfile

type AliyunProfile struct {
	Name            string `json:"name"`
	AccessKeyID     string `json:"access_key_id"`
	AccessKeySecret string `json:"access_key_secret"`
	Region          string `json:"region_id"`
}

type AzureCredentials

type AzureCredentials struct {
	ClientID       string `json:"appId"`
	ClientSecret   string `json:"password"`
	SubscriptionID string `json:"subscription"`
	TenantID       string `json:"tenant"`
}

func ReadAzureCredentials

func ReadAzureCredentials(path string) (AzureCredentials, error)

ReadAzureCredentials picks up the credentials as described in the docs.

If path is empty, $AZURE_CREDENTIALS or $HOME/.azure/azureCreds.json is read.

type DOProfile

type DOProfile struct {
	AccessToken string `json:"token"`
}

DOProfile represents a parsed DigitalOcean profile. This is a custom format specific to Mantle.

type ESXProfile

type ESXProfile struct {
	Server   string `json:"server"`
	User     string `json:"user"`
	Password string `json:"password"`
}

ESXProfile represents a parsed ESX profile. This is a custom format specific to Mantle.

type PacketProfile

type PacketProfile struct {
	ApiKey  string `json:"api_key"`
	Project string `json:"project"`
}

PacketProfile represents a parsed Packet profile. This is a custom format specific to Mantle.

Jump to

Keyboard shortcuts

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