-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sanitize policy behavior across backends #3324
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
package ldap | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/hashicorp/vault/helper/policyutil" | ||
"github.com/hashicorp/vault/logical" | ||
"github.com/hashicorp/vault/logical/framework" | ||
|
@@ -31,7 +29,7 @@ func pathGroups(b *backend) *framework.Path { | |
}, | ||
|
||
"policies": &framework.FieldSchema{ | ||
Type: framework.TypeString, | ||
Type: framework.TypeCommaStringSlice, | ||
Description: "Comma-separated list of policies associated to the group.", | ||
}, | ||
}, | ||
|
@@ -86,7 +84,7 @@ func (b *backend) pathGroupRead( | |
|
||
return &logical.Response{ | ||
Data: map[string]interface{}{ | ||
"policies": strings.Join(group.Policies, ","), | ||
"policies": group.Policies, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same backwards compatibility concerns as above. |
||
}, | ||
}, nil | ||
} | ||
|
@@ -95,7 +93,7 @@ func (b *backend) pathGroupWrite( | |
req *logical.Request, d *framework.FieldData) (*logical.Response, error) { | ||
// Store it | ||
entry, err := logical.StorageEntryJSON("group/"+d.Get("name").(string), &GroupEntry{ | ||
Policies: policyutil.ParsePolicies(d.Get("policies").(string)), | ||
Policies: policyutil.ParsePolicies(d.Get("policies")), | ||
}) | ||
if err != nil { | ||
return nil, err | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,7 @@ func pathUsers(b *backend) *framework.Path { | |
}, | ||
|
||
"policies": &framework.FieldSchema{ | ||
Type: framework.TypeString, | ||
Type: framework.TypeCommaStringSlice, | ||
Description: "Comma-separated list of policies associated with the user.", | ||
}, | ||
}, | ||
|
@@ -93,7 +93,7 @@ func (b *backend) pathUserRead( | |
return &logical.Response{ | ||
Data: map[string]interface{}{ | ||
"groups": strings.Join(user.Groups, ","), | ||
"policies": strings.Join(user.Policies, ","), | ||
"policies": user.Policies, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same backwards compatibility concerns as above. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it breaks compatibility. I'm inclined to just make the change though rather than move to another field. (As I mentioned in chat, we'd definitely note this in CHANGES.) I don't think in most cases these lookup endpoints are used by non-humans (and humans can easily understand it either way), and for anyone trying to feed them from a read into a write, the writes now accept slices so that will still work. |
||
}, | ||
}, nil | ||
} | ||
|
@@ -102,7 +102,7 @@ func (b *backend) pathUserWrite( | |
req *logical.Request, d *framework.FieldData) (*logical.Response, error) { | ||
name := d.Get("name").(string) | ||
groups := strutil.RemoveDuplicates(strutil.ParseStringSlice(d.Get("groups").(string), ","), false) | ||
policies := policyutil.ParsePolicies(d.Get("policies").(string)) | ||
policies := policyutil.ParsePolicies(d.Get("policies")) | ||
for i, g := range groups { | ||
groups[i] = strings.TrimSpace(g) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any concern with the behavior change of the return here? I like this better but this does break compatibility.