Validating that Address and Token are provided in path_config_access.go

This commit is contained in:
Nicolas Corrarello 2017-11-29 10:36:34 +00:00
parent aab72464d6
commit fc81d8a07c
No known key found for this signature in database
GPG key ID: 6FD0D0E272A30401

View file

@ -66,9 +66,17 @@ func (b *backend) pathConfigAccessRead(
func (b *backend) pathConfigAccessWrite(
req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
address := data.Get("address").(string)
if address == "" {
return logical.ErrorResponse("missing nomad server address"), nil
}
token := data.Get("token").(string)
if token == "" {
return logical.ErrorResponse("missing nomad management token"), nil
}
entry, err := logical.StorageEntryJSON("config/access", accessConfig{
Address: data.Get("address").(string),
Token: data.Get("token").(string),
Address: address,
Token: token,
})
if err != nil {
return nil, err