Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = errors.New("secret not found") ErrAccessDenied = errors.New("access denied") // nuh, uh, uh! ErrIDMismatch = errors.New("id mismatch") )
var ErrInvalidPattern = errors.New("invalid pattern")
Functions ¶
This section is empty.
Types ¶
type Envelope ¶
type Envelope struct {
ID ID `json:"-"`
Value []byte `json:"-"`
Provider string `json:"-"`
Version string `json:"-"`
Error string `json:"-"`
CreatedAt time.Time `json:"-"`
ResolvedAt time.Time `json:"-"`
ExpiresAt time.Time `json:"-"`
}
func EnvelopeErr ¶ added in v0.0.5
func (Envelope) MarshalJSON ¶ added in v0.0.6
type ErrInvalidID ¶ added in v0.0.6
type ErrInvalidID struct {
ID string
}
func (ErrInvalidID) Error ¶ added in v0.0.6
func (e ErrInvalidID) Error() string
type ID ¶
type ID interface {
// String formats the [IDNew] as a string
String() string
// Match the [IDNew] against a [PatternNew]
// It checks if a given identifier matches the pattern.
// - "*" matches a single component
// - "**" matches zero or more components
// - "/" is the separator
Match(pattern Pattern) bool
}
ID contains a secret identifier. Valid secret identifiers must match the format [A-Za-z0-9.-]+(/[A-Za-z0-9.-]+)+?.
For storage, we don't really differentiate much about the ID format but by convention we do simple, slash-separated management, providing a groupable access control system for management across plugins.
func MustParseID ¶ added in v0.0.6
MustParseID parses a string into a ID and behaves similar to ParseID, however, it panics when the id is invalid
type Pattern ¶
type Pattern interface {
// Match the [PatternNew] against an [IDNew]
Match(id ID) bool
// String formats the [Pattern] as a string
String() string
}
Pattern can be used to match secret identifiers. Valid patterns must follow the same validation rules as secret identifiers, with the exception that '*' can be used to match a single component, and '**' can be used to match zero or more components.
func MustParsePattern ¶ added in v0.0.6
MustParsePattern parses a string into a Pattern like with ParsePattern, however, it panics when a validation error occurs.
func ParsePattern ¶
ParsePattern parses a string into a Pattern Rules: - Components separated by '/' - Each component is non-empty - Only characters A-Z, a-z, 0-9, '.', '-', '_' or '*' - No leading, trailing, or double slashes - Asterisks rules:
- '*' cannot be mixed with other characters in the same component
- there can be no more than two '*' per component