Documentation
¶
Overview ¶
Package secret holds credential material in an opaque Secret type whose formatting and marshalling methods return only the redacted form. It imports nothing from TokenHound.
Index ¶
- func Split(n int) (pre, suf int)
- type Secret
- func (s Secret) Format(f fmt.State, verb rune)
- func (s Secret) GoString() string
- func (s Secret) IsZero() bool
- func (s Secret) Len() int
- func (s Secret) LogValue() slog.Value
- func (s Secret) MarshalJSON() ([]byte, error)
- func (s Secret) MarshalText() ([]byte, error)
- func (s Secret) Redacted() string
- func (s Secret) Reveal() string
- func (s Secret) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Secret ¶
type Secret struct {
// contains filtered or unexported fields
}
Secret holds key material. Every formatting, marshalling and logging method returns only the redacted form; Reveal returns the value and is allowed only where a request or a fingerprint needs it (forbidigo, AD-3).
The value sits behind an unexported pointer to a closure, so even reflection-based printing of a struct that holds a Secret in an unexported field (fmt prints such fields without calling their methods, and dereferences pointers for bad verbs such as %s) shows only addresses and the length.
func (Secret) MarshalJSON ¶
MarshalJSON marshals the redacted form as a JSON string.
func (Secret) MarshalText ¶
MarshalText returns the redacted form.
func (Secret) Redacted ¶
Redacted returns the display form: the first 6 runes, "...", the last 4 runes and the length, for example "sk-pro...a1b2 (51)". Keys of 12 to 19 runes show 4 and 2; shorter keys show at most half their runes in total.