auth

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const DefaultCredentialsPath = "~/.mcpsmithy/credentials"

DefaultCredentialsPath is the credentials file location used when no explicit path is given. It deliberately lives outside any project directory: file_read is sandboxed to the project root, so a credentials file inside a project could be handed to the agent or picked up by a local source glob.

Variables

This section is empty.

Functions

func NetrcExists added in v0.2.0

func NetrcExists() bool

NetrcExists reports whether a netrc file is present in the user's home directory. Callers use it to warn that the deprecated credential source is being relied on.

Types

type Credential added in v0.2.0

type Credential struct {
	// Auth scheme prefixing the token, e.g. "Token". Defaults to "Bearer"
	// when the credential targets the Authorization header, and to no scheme
	// when it targets a custom header.
	Scheme string `yaml:"scheme,omitempty"`
	// Header to carry the credential. Defaults to "Authorization".
	// Set it for APIs that use their own header, e.g. "PRIVATE-TOKEN".
	Header string `yaml:"header,omitempty"`
	// Static API token. Mutually exclusive with username/password.
	Token string `yaml:"token,omitempty"`
	// Username for Basic auth. Mutually exclusive with token.
	Username string `yaml:"username,omitempty"`
	// Password for Basic auth.
	Password string `yaml:"password,omitempty"`
}

Credential is the auth material for a single host.

The fields present determine the header that gets sent:

token                     → Authorization: Bearer <token>
token + scheme            → Authorization: <scheme> <token>
token + header            → <header>: <token>
token + header + scheme   → <header>: <scheme> <token>
username + password       → Authorization: Basic base64(username:password)

type Store added in v0.2.0

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

Store resolves credentials by hostname. Hosts absent from the store fall back to ~/.netrc, which is deprecated but still honoured.

A nil *Store applies no credentials at all, which keeps callers that have no credential source (tests, or code paths that must not authenticate) simple.

func Load added in v0.2.0

func Load(path string) (*Store, error)

Load reads a credentials file and returns a Store.

A missing file is not an error: the returned Store is empty and every lookup falls back to ~/.netrc, matching the silent-miss behaviour netrc has always had. A file that exists but cannot be read, parsed, or validated is an error, because silently ignoring a malformed credentials file would look like an authentication bug at request time.

func (*Store) Apply added in v0.2.0

func (s *Store) Apply(req *http.Request)

Apply sets the auth header on req for the request's hostname. Hosts without an entry fall back to ~/.netrc. A nil Store is a no-op.

func (*Store) HasCredentials added in v0.2.0

func (s *Store) HasCredentials() bool

HasCredentials reports whether the store holds any entries. Callers use it to decide whether to warn that netrc is being relied on.

Jump to

Keyboard shortcuts

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