auth

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAuthHeader

func GetAuthHeader(creds *Credentials) string

GetAuthHeader returns the Authorization header value for the given credentials

func RemoveCredentials

func RemoveCredentials() error

RemoveCredentials removes stored credentials from all file-based stores

func SaveCredentials

func SaveCredentials(creds *Credentials, store CredentialStore) error

SaveCredentials persists credentials to the specified store

Types

type AuthMethod

type AuthMethod string

AuthMethod represents the authentication method to use

const (
	// DirectAPIKey uses a pre-computed API key hex digest sent as ApiKey header
	DirectAPIKey AuthMethod = "apikey"
	// SigV4 uses AWS Signature Version 4 for token exchange
	SigV4 AuthMethod = "sigv4"
)

func ValidateMethod

func ValidateMethod(method string) (AuthMethod, error)

ValidateMethod checks if the given string is a valid AuthMethod

type CredentialStore

type CredentialStore string

CredentialStore represents where credentials are persisted

const (
	StoreHome    CredentialStore = "home"    // ~/.vulnetix/credentials.json
	StoreProject CredentialStore = "project" // .vulnetix/credentials.json
	StoreKeyring CredentialStore = "keyring" // system keyring (stub)
)

func ValidateStore

func ValidateStore(store string) (CredentialStore, error)

ValidateStore checks if the given string is a valid CredentialStore

type Credentials

type Credentials struct {
	OrgID  string     `json:"org_id"`
	APIKey string     `json:"api_key,omitempty"` // hex digest for Direct API Key
	Secret string     `json:"secret,omitempty"`  // secret key for SigV4
	Method AuthMethod `json:"method"`
}

Credentials holds authentication credentials for the Vulnetix API

func CredentialStatus

func CredentialStatus() (string, *Credentials)

CredentialStatus returns a human-readable description of the current auth state

func LoadCredentials

func LoadCredentials() (*Credentials, error)

LoadCredentials loads credentials using the following precedence:

  1. Environment variables (VULNETIX_API_KEY + VULNETIX_ORG_ID for Direct, VVD_ORG + VVD_SECRET for SigV4)
  2. Project dotfile (.vulnetix/credentials.json)
  3. Home directory (~/.vulnetix/credentials.json)

Jump to

Keyboard shortcuts

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