Add some extra checks to tokenutil

This commit is contained in:
Jeff Mitchell 2019-06-29 14:48:17 -04:00
parent 2e71ed0be2
commit 9c90e2e840
1 changed files with 9 additions and 0 deletions

View File

@ -172,6 +172,15 @@ func (t *TokenParams) ParseTokenFields(req *logical.Request, d *framework.FieldD
t.TokenType = tokenType
}
if t.TokenType == "batch" {
if t.Period != 0 {
return errors.New("'token_type' cannot be 'batch' when set to generate periodic tokens")
}
if t.TokenNumUses != 0 {
return errors.New("'token_type' cannot be 'batch' when set to generate tokens with limited use count")
}
}
if ttlRaw, ok := d.GetOk("token_ttl"); ok {
t.TokenTTL = time.Duration(ttlRaw.(int)) * time.Second
}