Documentation
¶
Index ¶
- Constants
- Variables
- func ApiKey() string
- func ApiUrl() string
- func CloudAccessToken() string
- func CloudIdentityServiceAudience() string
- func CloudIdentityServiceBaseUrl() string
- func CloudIdentityServiceClientId() string
- func CloudIdentityServiceDeviceCodeUrl() string
- func CloudIdentityServiceTokenUrl() string
- func CloudRefreshToken() string
- func CommunityMode() bool
- func CommunityServicesApiUrl() string
- func ControlPlaneClientConnection(name string) (*grpc.ClientConn, error)
- func ControlTowerUrl() string
- func DataPlaneUrl() string
- func DefaultApiUrl() string
- func DefaultCommunityApiUrl() string
- func HasEntitlements(entitlementsFeatures ...v1.Feature) bool
- func InsightsApiV2Url() string
- func InsightsV2ClientConnection(name string) (*grpc.ClientConn, error)
- func InsightsV2CommunityClientConnection(name string) (*grpc.ClientConn, error)
- func IsAccessTokenExpired() (bool, error)
- func LoadEntitlements() error
- func MalwareAnalysisClientConnection(name string) (*grpc.ClientConn, error)
- func MalwareAnalysisCommunityClientConnection(name string) (*grpc.ClientConn, error)
- func PersistApiKey(key, domain string) error
- func PersistCloudTokens(accessToken, refreshToken, domain string) error
- func PersistTenantDomain(domain string) error
- func RefreshCloudSession() error
- func SetRuntimeApiKey(key string)
- func SetRuntimeCloudTenant(domain string)
- func SetRuntimeCommunityMode()
- func ShouldCheckAccessTokenExpiry() bool
- func SyncApiUrl() string
- func SyncClientConnection(name string) (*grpc.ClientConn, error)
- func TenantDomain() string
- func Verify() error
- type Config
- type Credentials
- type Option
- type Resolver
Constants ¶
KeychainBackendUnavailableMarker is the stable wrap prefix dry/keychain.New emits when no OS keyring backend is reachable (e.g. WSL without DBus, headless Linux without secret-service). We treat this as "no credentials in this layer" so the chain continues to the no-creds hint instead of stopping with a confusing backend error. Exported so tests can construct fixtures that match.
Variables ¶
var ErrIncompleteCredentials = errors.New("auth: credentials incomplete")
ErrIncompleteCredentials signals that a source held one half of a credential pair (API key XOR tenant). The user clearly intended to use that source; we stop the chain rather than falling through to layers that wouldn't help.
var ErrNoCredentials = errors.New("auth: no credentials configured")
ErrNoCredentials is returned when no source in the resolution chain has both an API key and a tenant identifier configured. Sources that hold no credentials report this sentinel so the layered resolver can fall through to the next source. Real backend failures (a keychain that errored out, a corrupt config file) propagate verbatim and stop the chain — they are not "no credentials", they are a broken source.
Functions ¶
func CloudAccessToken ¶ added in v1.8.0
func CloudAccessToken() string
func CloudIdentityServiceAudience ¶ added in v1.8.0
func CloudIdentityServiceAudience() string
func CloudIdentityServiceBaseUrl ¶ added in v1.8.0
func CloudIdentityServiceBaseUrl() string
func CloudIdentityServiceClientId ¶ added in v1.8.0
func CloudIdentityServiceClientId() string
func CloudIdentityServiceDeviceCodeUrl ¶ added in v1.8.0
func CloudIdentityServiceDeviceCodeUrl() string
func CloudIdentityServiceTokenUrl ¶ added in v1.8.0
func CloudIdentityServiceTokenUrl() string
func CloudRefreshToken ¶ added in v1.8.0
func CloudRefreshToken() string
func CommunityMode ¶ added in v1.0.0
func CommunityMode() bool
func CommunityServicesApiUrl ¶ added in v1.10.1
func CommunityServicesApiUrl() string
func ControlPlaneClientConnection ¶ added in v1.8.0
func ControlPlaneClientConnection(name string) (*grpc.ClientConn, error)
Create a gRPC client connection for the control plane based on available configuration
func ControlTowerUrl ¶ added in v1.8.0
func ControlTowerUrl() string
func DataPlaneUrl ¶ added in v1.8.9
func DataPlaneUrl() string
func DefaultApiUrl ¶
func DefaultApiUrl() string
func DefaultCommunityApiUrl ¶ added in v1.0.0
func DefaultCommunityApiUrl() string
func HasEntitlements ¶ added in v1.13.0
HasEntitlements checks if the current tenant has the specified entitlements This always depends on cached entitlements and never calls the API directly
func InsightsApiV2Url ¶ added in v1.8.3
func InsightsApiV2Url() string
func InsightsV2ClientConnection ¶ added in v1.8.3
func InsightsV2ClientConnection(name string) (*grpc.ClientConn, error)
func InsightsV2CommunityClientConnection ¶ added in v1.11.2
func InsightsV2CommunityClientConnection(name string) (*grpc.ClientConn, error)
func IsAccessTokenExpired ¶ added in v1.12.3
func LoadEntitlements ¶ added in v1.13.0
func LoadEntitlements() error
LoadEntitlements loads and caches entitlements for the current tenant If this fails, then no credential is available and the app should switch to community mode
func MalwareAnalysisClientConnection ¶ added in v1.8.9
func MalwareAnalysisClientConnection(name string) (*grpc.ClientConn, error)
func MalwareAnalysisCommunityClientConnection ¶ added in v1.10.1
func MalwareAnalysisCommunityClientConnection(name string) (*grpc.ClientConn, error)
func PersistApiKey ¶ added in v1.8.0
func PersistCloudTokens ¶ added in v1.8.0
func PersistTenantDomain ¶ added in v1.8.0
func RefreshCloudSession ¶ added in v1.12.3
func RefreshCloudSession() error
func SetRuntimeApiKey ¶ added in v1.8.0
func SetRuntimeApiKey(key string)
func SetRuntimeCloudTenant ¶ added in v1.8.0
func SetRuntimeCloudTenant(domain string)
func SetRuntimeCommunityMode ¶ added in v1.5.9
func SetRuntimeCommunityMode()
SetRuntimeCommunityMode sets the runtime mode to community without persisting it to the configuration file.
func ShouldCheckAccessTokenExpiry ¶ added in v1.12.3
func ShouldCheckAccessTokenExpiry() bool
func SyncApiUrl ¶ added in v1.8.0
func SyncApiUrl() string
func SyncClientConnection ¶ added in v1.8.0
func SyncClientConnection(name string) (*grpc.ClientConn, error)
func TenantDomain ¶ added in v1.8.0
func TenantDomain() string
Types ¶
type Config ¶
type Config struct {
ApiUrl string `yaml:"api_url"`
ApiKey string `yaml:"api_key"`
Community bool `yaml:"community"`
DataPlaneApiUrl string `yaml:"data_plane_api_url"`
ControlPlaneApiUrl string `yaml:"control_api_url"`
SyncApiUrl string `yaml:"sync_api_url"`
InsightsApiV2Url string `yaml:"insights_api_v2_url"`
CommunityServicesApiUrl string `yaml:"community_services_api_url"`
TenantDomain string `yaml:"tenant_domain"`
CloudAccessToken string `yaml:"cloud_access_token"`
CloudRefreshToken string `yaml:"cloud_refresh_token"`
CloudAccessTokenUpdatedAt time.Time `yaml:"cloud_access_token_updated_at"`
}
func DefaultConfig ¶ added in v1.8.0
func DefaultConfig() Config
type Credentials ¶ added in v1.17.0
Credentials carries the data-plane API key plus the tenant identifier the resolver chain produces. Field names mirror the existing helpers in auth.go so downstream code can adopt the resolver without adapter glue.
type Option ¶ added in v1.17.0
type Option func(*layeredResolver)
Option configures NewLayeredResolver. The only documented option today is WithSource which appends an extra layer; we keep Option as a functional option so future extensions slot in without changing the constructor's signature.
func WithSource ¶ added in v1.17.0
func WithSource(s source) Option
WithSource appends a custom source to the layered resolver. The source is consulted after the documented defaults in the order it was passed. Tests use this to inject deterministic stubs without reaching into package internals.
type Resolver ¶ added in v1.17.0
type Resolver interface {
Resolve(ctx context.Context) (Credentials, error)
}
Resolver discovers credentials at request time. Implementations must be safe to call concurrently when the underlying sources are.
func NewLayeredResolver ¶ added in v1.17.0
NewLayeredResolver returns a Resolver that walks credential sources in order:
- vet env vars + vet-auth.yml (via auth.ApiKey / auth.TenantDomain; covers SAFEDEP_API_KEY / SAFEDEP_TENANT_ID and their VET_ aliases).
- DRY keychain provider, constructed without an insecure file fallback.
A source that reports ErrNoCredentials triggers a fall-through; any other error stops the chain immediately. When every source is empty the resolver returns ErrNoCredentials so callers can branch on the sentinel.