credentials

package
v0.9.13 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CredentialTypeTool          CredentialType = "tool"
	CredentialTypeModelProvider CredentialType = "modelProvider"
	ExistingCredential                         = "GPTSCRIPT_EXISTING_CREDENTIAL"
	CredentialExpiration                       = "GPTSCRIPT_CREDENTIAL_EXPIRATION"
)
View Source
const (
	DefaultCredentialContext = "default"
	AllCredentialContexts    = "*"
)

Variables

This section is empty.

Functions

func IsCredentialsNotFoundError

func IsCredentialsNotFoundError(err error) bool

func ParseCredentialOverrides

func ParseCredentialOverrides(overrides []string) (map[string]map[string]string, error)

ParseCredentialOverrides parses a string of credential overrides that the user provided as a command line arg. The format of credential overrides can be one of two things: cred1:ENV1,ENV2 (direct mapping of environment variables) cred1:ENV1=VALUE1,ENV2=VALUE2 (key-value pairs)

This function turns it into a map[string]map[string]string like this:

{
  "cred1": {
    "ENV1": "VALUE1",
    "ENV2": "VALUE2",
  }
}

Types

type Credential

type Credential struct {
	Context  string            `json:"context"`
	ToolName string            `json:"toolName"`
	Type     CredentialType    `json:"type"`
	Env      map[string]string `json:"env"`
	// If the CheckParam that is stored is different from the param on the tool,
	// then the credential will be re-authed as if it does not exist.
	CheckParam   string     `json:"checkParam"`
	Ephemeral    bool       `json:"ephemeral,omitempty"`
	ExpiresAt    *time.Time `json:"expiresAt"`
	RefreshToken string     `json:"refreshToken"`
}

func (Credential) IsExpired

func (c Credential) IsExpired() bool

type CredentialContextPin

type CredentialContextPin struct {
	// Contexts are searched first, in order, for this credential.
	Contexts []string `json:"contexts"`
	// Exclusive makes Contexts the credential's only home: it is resolved from
	// them alone, with no fallback, and a newly created one is stored in
	// Contexts[0]. Use it only for a context that belongs to whoever is
	// running, since that is where their answer to a prompt ends up.
	//
	// Without it the pin is lookup-only: Contexts take precedence, the run's
	// own contexts are searched after them, and a newly created credential is
	// stored where an unpinned one would be — never in the pin. That is the
	// right kind for a context shared between users, which a run must not be
	// able to write a user's secret into.
	Exclusive bool `json:"exclusive,omitempty"`
}

CredentialContextPin sends one credential name to its own contexts instead of the run's context list.

A single ordered list cannot express "this credential belongs to that context": Store writes every new credential to the FIRST context of its list, so a context put first to win lookups for one credential also receives every other credential the run creates. A pin scopes the context to the credential it is meant for.

type CredentialStore

type CredentialStore interface {
	Get(ctx context.Context, toolName string) (*Credential, bool, error)
	Add(ctx context.Context, cred Credential) error
	Refresh(ctx context.Context, cred Credential) error
	Remove(ctx context.Context, toolName string) error
	List(ctx context.Context) ([]Credential, error)
	RecreateAll(ctx context.Context) error
}

type CredentialType

type CredentialType string

type NoopStore

type NoopStore struct{}

func (NoopStore) Add

func (NoopStore) Get

func (NoopStore) List

func (s NoopStore) List(context.Context) ([]Credential, error)

func (NoopStore) RecreateAll

func (s NoopStore) RecreateAll(context.Context) error

func (NoopStore) Refresh

func (NoopStore) Remove

func (s NoopStore) Remove(context.Context, string) error

type ProgramLoaderRunner

type ProgramLoaderRunner interface {
	Load(ctx context.Context, toolName string) (prg types.Program, err error)
	Run(ctx context.Context, prg types.Program, input string) (output string, err error)
}

type Store

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

func (*Store) Add

func (s *Store) Add(_ context.Context, cred Credential) error

Add adds a new credential to the credential store. Any context set on the credential object will be overwritten with the first context of the credential store.

func (*Store) Get

func (s *Store) Get(_ context.Context, toolName string) (*Credential, bool, error)

func (*Store) List

func (s *Store) List(_ context.Context) ([]Credential, error)

func (*Store) RecreateAll

func (s *Store) RecreateAll(_ context.Context) error

func (*Store) Refresh

func (s *Store) Refresh(_ context.Context, cred Credential) error

Refresh updates an existing credential in the credential store.

func (*Store) Remove

func (s *Store) Remove(_ context.Context, toolName string) error

type StoreFactory

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

func NewFactory

func NewFactory(ctx context.Context, cfg *config.CLIConfig, overrides []string, plr ProgramLoaderRunner) (StoreFactory, error)

func (*StoreFactory) NewPinnedStore

func (s *StoreFactory) NewPinnedStore(credCtxs []string, pins map[string]CredentialContextPin) (CredentialStore, error)

NewPinnedStore returns a store that resolves credentials against credCtxs, as NewStore does, except for the names in pins, which resolve as their CredentialContextPin describes.

func (*StoreFactory) NewStore

func (s *StoreFactory) NewStore(credCtxs []string) (CredentialStore, error)

Jump to

Keyboard shortcuts

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