Fix IDs being lowercased in role grants (#839)
Fix IDs being lowercased in role grants Fixes #794
This commit is contained in:
1 parent
e6c98f1454
commit
b5d84495a3
3 files changed
+10
-6
No files matched your search
@@ -39,6 +39,10 @@ Canonical reference for changes, improvements, and bugfixes for Boundary.
|
||||
* cli: Ensure errors print to stderr when token is not found
|
||||
([Issue](https://github.com/hashicorp/boundary/issues/791))
|
||||
([PR](https://github.com/hashicorp/boundary/pull/799))
|
||||
* controller: Fix grant IDs being lowercased when being read back (and when
|
||||
being used for permission evaluation)
|
||||
([Issue](https://github.com/hashicorp/boundary/issues/794))
|
||||
([PR](https://github.com/hashicorp/boundary/pull/839))
|
||||
|
||||
## v0.1.2
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ func (g *Grant) unmarshalJSON(data []byte) error {
|
||||
if !ok {
|
||||
return fmt.Errorf("unable to interpret %q as string", "id")
|
||||
}
|
||||
g.id = strings.ToLower(id)
|
||||
g.id = id
|
||||
}
|
||||
if rawType, ok := raw["type"]; ok {
|
||||
typ, ok := rawType.(string)
|
||||
@@ -197,7 +197,7 @@ func (g *Grant) unmarshalText(grantString string) error {
|
||||
|
||||
switch kv[0] {
|
||||
case "id":
|
||||
g.id = strings.ToLower(kv[1])
|
||||
g.id = kv[1]
|
||||
|
||||
case "type":
|
||||
typeString := strings.ToLower(kv[1])
|
||||
@@ -272,7 +272,7 @@ func Parse(scopeId, grantString string, opt ...Option) (Grant, error) {
|
||||
// if so
|
||||
if grant.id != "" && strings.HasPrefix(grant.id, "{{") {
|
||||
id := strings.TrimSuffix(strings.TrimPrefix(grant.id, "{{"), "}}")
|
||||
id = strings.ToLower(strings.TrimSpace(id))
|
||||
id = strings.TrimSpace(id)
|
||||
switch id {
|
||||
case "user.id":
|
||||
if opts.withUserId != "" {
|
||||
|
||||
@@ -1423,7 +1423,7 @@ func checkEqualGrants(t *testing.T, expected []string, got *pb.Role) {
|
||||
require.NoError(err)
|
||||
assert.Equal(expected[i], got.GrantStrings[i])
|
||||
assert.Equal(expected[i], got.Grants[i].GetRaw())
|
||||
assert.Equal(parsed.CanonicalString(), got.Grants[i].GetCanonical())
|
||||
assert.Equal(v, got.Grants[i].GetCanonical())
|
||||
j := got.Grants[i].GetJson()
|
||||
require.NotNil(j)
|
||||
assert.Equal(parsed.Id(), j.GetId())
|
||||
@@ -1463,9 +1463,9 @@ func TestAddGrants(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "Add duplicate grant on role with grant",
|
||||
existing: []string{"id=1;actions=read"},
|
||||
existing: []string{"id=aA1;actions=read"},
|
||||
add: []string{"id=*;type=*;actions=delete", "id=*;type=*;actions=delete"},
|
||||
result: []string{"id=1;actions=read", "id=*;type=*;actions=delete"},
|
||||
result: []string{"id=aA1;actions=read", "id=*;type=*;actions=delete"},
|
||||
},
|
||||
{
|
||||
name: "Add grant matching existing grant",
|
||||
|
||||
Reference in new issue
Block a user