azure

package
v0.4.0-beta.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2020 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Copyright The KubeVault Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright The KubeVault Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright The KubeVault Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetServicePrincipalToken

func GetServicePrincipalToken(config *AzureAuthConfig, env *azure.Environment, resource string) (*adal.ServicePrincipalToken, error)

GetServicePrincipalToken creates a new service principal token based on the configuration

func NewKVService

func NewKVService(opts *Options) (kv.Service, error)

func ParseAzureEnvironment

func ParseAzureEnvironment(cloudName string) (*azure.Environment, error)

ParseAzureEnvironment returns azure environment by name

Types

type AzureAuthConfig

type AzureAuthConfig struct {
	// The cloud environment identifier. Takes values from https://github.com/Azure/go-autorest/blob/ec5f4903f77ed9927ac95b19ab8e44ada64c1356/autorest/azure/environments.go#L13
	Cloud string `json:"cloud"`
	// The AAD Tenant ID for the Subscription that the cluster is deployed in
	TenantID string `json:"tenantId"`
	//The ClientID for an AAD application with RBAC access to talk to Azure RM APIs
	AADClientID string `json:"aadClientId"`
	// The ClientSecret for an AAD application with RBAC access to talk to Azure RM APIs
	AADClientSecret string `json:"aadClientSecret"`
	// The path of a client certificate for an AAD application with RBAC access to talk to Azure RM APIs
	AADClientCertPath string `json:"aadClientCertPath"`
	// The password of the client certificate for an AAD application with RBAC access to talk to Azure RM APIs
	AADClientCertPassword string `json:"aadClientCertPassword"`
	// Use managed service identity for the virtual machine to access Azure ARM APIs
	UseManagedIdentityExtension bool `json:"useManagedIdentityExtension"`
}

AzureAuthConfig holds auth related part of cloud config

func GetConfigFromFile

func GetConfigFromFile(configFilePath string) (*AzureAuthConfig, error)

func NewAzureAuthConfig

func NewAzureAuthConfig() *AzureAuthConfig

func (*AzureAuthConfig) AddFlags

func (o *AzureAuthConfig) AddFlags(fs *pflag.FlagSet)

func (*AzureAuthConfig) GetKeyVaultToken

func (c *AzureAuthConfig) GetKeyVaultToken(grantType OAuthGrantType) (authorizer autorest.Authorizer, err error)

func (*AzureAuthConfig) Validate

func (o *AzureAuthConfig) Validate() []error

type KVService

type KVService struct {
	KeyClient    azurekv.BaseClient
	Ctx          context.Context
	VaultBaseUrl string
	SecretPrefix string
}

func (*KVService) CheckWriteAccess

func (k *KVService) CheckWriteAccess() error

func (*KVService) Get

func (k *KVService) Get(key string) ([]byte, error)

func (*KVService) GetLatestVersionOfSecret

func (k *KVService) GetLatestVersionOfSecret(vaultBaseUrl, secretName string) (string, error)

GetLatestVersionOfSecret will give latest version of secret according to created time

func (*KVService) GetSecret

func (k *KVService) GetSecret(secretName string) (*string, error)

GetSecret will give secret in response

func (*KVService) Set

func (k *KVService) Set(key string, value []byte) error

func (*KVService) SetSecret

func (k *KVService) SetSecret(secretName, value string) error

SetSecret will store secret in azure key vault

func (*KVService) Test

func (k *KVService) Test(key string) error

type OAuthGrantType

type OAuthGrantType int

OAuthGrantType specifies which grant type to use.

const (
	// OAuthGrantTypeServicePrincipal for client credentials flow
	OAuthGrantTypeServicePrincipal OAuthGrantType = iota
	// OAuthGrantTypeDeviceFlow for device-auth flow
	OAuthGrantTypeDeviceFlow
)

func AuthGrantType

func AuthGrantType() OAuthGrantType

type Options

type Options struct {
	VaultBaseUrl string
	AuthConfig   *AzureAuthConfig
	// TODO: should make it auto generated
	SecretPrefix string // prefix to use in secret name for azure key vault
}

func NewOptions

func NewOptions() *Options

func (*Options) AddFlags

func (o *Options) AddFlags(fs *pflag.FlagSet)

func (*Options) Apply

func (o *Options) Apply() error

func (*Options) Validate

func (o *Options) Validate() []error

Jump to

Keyboard shortcuts

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