feat: share.keyRules, how long and varied a share key must be
Sharing refuses a key shorter than minLength characters (default 32, never under 16) or of fewer than minClasses kinds of lowercase, uppercase, digits and symbols (default 2, so random hex passes), saying so without showing it. Opening doesn't check. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
13 files changed
+156
-21
No files matched your search
@@ -90,6 +90,16 @@ type Share struct {
|
||||
// lazysecrets:// link, Key Vault URL or reference), for repos whose
|
||||
// .lazysecrets.yaml doesn't name one.
|
||||
Key string `yaml:"key"`
|
||||
// KeyRules are what a key's value must be to share with it.
|
||||
KeyRules KeyRules `yaml:"keyRules"`
|
||||
}
|
||||
|
||||
// KeyRules default to 32 characters of 2 kinds (share.DefaultRules).
|
||||
type KeyRules struct {
|
||||
MinLength int `yaml:"minLength"` // at least 16
|
||||
// MinClasses is how many kinds of character: lowercase, uppercase,
|
||||
// digits, symbols.
|
||||
MinClasses int `yaml:"minClasses"`
|
||||
}
|
||||
|
||||
type Providers struct {
|
||||
@@ -236,6 +246,12 @@ func (c Config) validate(path string) error {
|
||||
return fmt.Errorf("%s: share.key: %q is not a secret's lazysecrets:// link, Key Vault URL or reference", path, k)
|
||||
}
|
||||
}
|
||||
if n := c.Share.KeyRules.MinLength; n != 0 && n < 16 {
|
||||
return fmt.Errorf("%s: share.keyRules.minLength: %d is under 16", path, n)
|
||||
}
|
||||
if n := c.Share.KeyRules.MinClasses; n < 0 || n > 4 {
|
||||
return fmt.Errorf("%s: share.keyRules.minClasses: %d is not between 1 and 4", path, n)
|
||||
}
|
||||
for i, v := range c.Providers.Azure.Vaults {
|
||||
if !strings.HasPrefix(v, "https://") {
|
||||
return fmt.Errorf("%s: providers.azure.vaults[%d]: %q is not an https:// vault URL", path, i, v)
|
||||
|
||||
Reference in new issue
Block a user