common

package
v0.0.0-...-5004fd2 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvKeyAzClientID                 = "AZURE_CLIENT_ID"
	EnvKeyAzTenantID                 = "AZURE_TENANT_ID"
	EnvKeyAzClientSecret             = "AZURE_CLIENT_SECRET"
	EnvKeyAzClientCertPath           = "AZURE_CLIENT_CERTIFICATE_PATH"
	EnvKeyUseManagedIdentity         = "USE_MANAGED_IDENTITY"
	EnvKeyAzKeyvaultResourceEndpoint = "AZURE_KEYVAULT_RESOURCEENDPOINT"
	EnvKeyAzSubscriptionID           = "AZURE_SUBSCRIPTION_ID"
	EnvKeyAzResourceGroupName        = "AZURE_RESOURCE_GROUP_NAME"
)
View Source
const (
	IdentityEnvVarPrefixService = "SERVICE_"
	IdentityEnvVarPrefixApp     = "APP_"
	IdentityEnvVarPrefixAgent   = "AGENT_"
)
View Source
const (
	NSRelNameDASPLink = "device-application-service-principal-link"
)

Variables

View Source
var (

	// root CA --1 ~ --f
	WellKnownID_RootCA     = uuid.MustParse("00000000-0000-0000-0000-000000000001")
	WellKnownID_TestRootCA = uuid.MustParse("00000000-0000-0000-0000-00000000000f")

	// intermediate CAs --10 ~ --ff
	WellKnownID_IntCAService  = uuid.MustParse("00000000-0000-0000-0000-000000000011")
	WellKnownID_IntCAIntranet = uuid.MustParse("00000000-0000-0000-0000-000000000012")
	WellKnownID_IntCAAadSp    = uuid.MustParse("00000000-0000-0000-0000-000000000013")
	WellKnownID_TestIntCA     = uuid.MustParse("00000000-0000-0000-0000-0000000000ff")
)
View Source
var (
	ErrStatus2xxCreated   = errors.New("created")            // 201
	ErrStatusBadRequest   = errors.New("invalid input")      // 400
	ErrStatusUnauthorized = errors.New("unauthorized")       // 401
	ErrStatusForbidden    = errors.New("forbidden")          // 403
	ErrStatusNotFound     = errors.New("resource not found") // 404
	ErrStatusConflict     = errors.New("resource conflict")  // 409
)
View Source
var (
	ErrMissingEnvVar = errors.New("missing env var")
	ErrInvalidEnvVar = errors.New("invalid env var")
)

Functions

func ExtractGraphODataErrorCode

func ExtractGraphODataErrorCode(err error) (errorCode *string, odErr *odataerrors.ODataError, ok bool)

func GetCanonicalCertificateTemplateID

func GetCanonicalCertificateTemplateID(namespaceID uuid.UUID, templateName WellKnownCertTemplateName) uuid.UUID

func GetCanonicalNamespaceRelationID

func GetCanonicalNamespaceRelationID(namespaceID uuid.UUID, relationName string) uuid.UUID

func IsAzCosmosNotFound

func IsAzCosmosNotFound(err error) (error, bool)

func IsAzNotFound deprecated

func IsAzNotFound(err error) bool

Deprecated: use WrapAzNotFoundErr instead

func IsEnvValueTrue

func IsEnvValueTrue(envValue string) bool

func IsGraphODataErrorNotFound deprecated

func IsGraphODataErrorNotFound(err error) bool

Deprecated: use WrapMsGraphNotFoundErr instead

func LookupEnvWithDefault

func LookupEnvWithDefault(envKey string, defaultValue string) string

func NewCommonConfig

func NewCommonConfig(envSvc EnvService, buildID string) (c commonConfig, err error)

func ToAzTokenCredentialRequestEditorFn

func ToAzTokenCredentialRequestEditorFn(cred azcore.TokenCredential, tokenOptions policy.TokenRequestOptions) func(ctx context.Context, req *http.Request) error

func ToSilenTokenRequestEditorFn

func ToSilenTokenRequestEditorFn(pubClient *public.Client, tokenScope string, account public.Account) func(ctx context.Context, req *http.Request) error

func WrapAzRsNotFoundErr

func WrapAzRsNotFoundErr(err error, resourceDescriptor string) error

func WrapMsGraphNotFoundErr

func WrapMsGraphNotFoundErr(err error, resourceDescriptor string) error

Types

type AzureAppConfidentialIdentity

type AzureAppConfidentialIdentity = auth.AzureAppConfidentialIdentity

type AzureCredentialServiceIdentity

type AzureCredentialServiceIdentity struct {
	// contains filtered or unexported fields
}

func (AzureCredentialServiceIdentity) ClientID

func (identity AzureCredentialServiceIdentity) ClientID() string

func (AzureCredentialServiceIdentity) TenantID

func (identity AzureCredentialServiceIdentity) TenantID() string

func (AzureCredentialServiceIdentity) TokenCredential

func (identity AzureCredentialServiceIdentity) TokenCredential() azcore.TokenCredential

TokenCredential implements AzureIdentity.

type AzureIdentity

type AzureIdentity = auth.AzureIdentity

func NewAzureIdentityFromEnv

func NewAzureIdentityFromEnv(envService EnvService, envVarPrefix string) (AzureIdentity, error)

type CommonServer

type CommonServer interface {
	ServiceIdentityProvider
	EnvService() EnvService
	BuildID() string
}

type ConfidentialAppIdentityProvider

type ConfidentialAppIdentityProvider interface {
	ConfidentialAppIdentity() AzureAppConfidentialIdentity
}

type EnvService

type EnvService interface {
	Export() []string
	Require(key string, prefixes ...string) (string, bool)
	RequireNonWhitespace(key string, prefixes ...string) (string, bool)
	RequireAbsPath(key string, prefixes ...string) (string, bool)
	Default(key string, value string, prefixes ...string) string
	Clone() EnvService
	SetValue(key string, value string)

	// convience method to create a error with key missing
	ErrMissing(key string) error
}

func NewEnvService

func NewEnvService() EnvService

type ServerContext

type ServerContext interface {
	ctx.Context
	ServiceIdentity() AzureIdentity
}

type ServiceIdentityProvider

type ServiceIdentityProvider interface {
	ServiceIdentity() AzureIdentity
}

type WellKnownCertTemplateName

type WellKnownCertTemplateName string
const (
	DefaultCertTemplateName_GlobalDefault                    WellKnownCertTemplateName = "default"
	DefaultCertTemplateName_ServicePrincipalClientCredential WellKnownCertTemplateName = "default-service-principal-client-credential"
)

type WellKnownID

type WellKnownID uuid.UUID

type WellKnownIdentifier

type WellKnownIdentifier int

Jump to

Keyboard shortcuts

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