mirror of
https://github.com/hashicorp/vault.git
synced 2026-02-03 20:40:45 -05:00
Replace string contains to be case insensitive (#31045)
This commit is contained in:
parent
c4467ff9e5
commit
642b4f1817
4 changed files with 8 additions and 5 deletions
3
changelog/31045.txt
Normal file
3
changelog/31045.txt
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
```release-note:bug
|
||||
core: Fix string contains check in Identity APIs to be case-insensitive.
|
||||
```
|
||||
|
|
@ -349,7 +349,7 @@ func (i *IdentityStore) handleEntityUpdateCommon() framework.OperationFunc {
|
|||
entity.Policies = strutil.RemoveDuplicates(entityPoliciesRaw.([]string), false)
|
||||
}
|
||||
|
||||
if strutil.StrListContains(entity.Policies, "root") {
|
||||
if strutil.StrListContainsCaseInsensitive(entity.Policies, "root") {
|
||||
return logical.ErrorResponse("policies cannot contain root"), nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -265,7 +265,7 @@ func (i *IdentityStore) handleGroupUpdateCommon(ctx context.Context, req *logica
|
|||
group.Policies = strutil.RemoveDuplicatesStable(policiesRaw.([]string), true)
|
||||
}
|
||||
|
||||
if strutil.StrListContains(group.Policies, "root") {
|
||||
if strutil.StrListContainsCaseInsensitive(group.Policies, "root") {
|
||||
return logical.ErrorResponse("policies cannot contain root"), nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2993,10 +2993,10 @@ func (ts *TokenStore) handleCreateCommon(ctx context.Context, req *logical.Reque
|
|||
}
|
||||
}
|
||||
|
||||
if strutil.StrListContains(te.Policies, "root") {
|
||||
if strutil.StrListContainsCaseInsensitive(te.Policies, "root") {
|
||||
// Prevent attempts to create a root token without an actual root token as parent.
|
||||
// This is to thwart privilege escalation by tokens having 'sudo' privileges.
|
||||
if !strutil.StrListContains(parent.Policies, "root") {
|
||||
if !strutil.StrListContainsCaseInsensitive(parent.Policies, "root") {
|
||||
return logical.ErrorResponse("root tokens may not be created without parent token being root"), logical.ErrInvalidRequest
|
||||
}
|
||||
|
||||
|
|
@ -3151,7 +3151,7 @@ func (ts *TokenStore) handleCreateCommon(ctx context.Context, req *logical.Reque
|
|||
}
|
||||
|
||||
// Only calculate a TTL if you are A) periodic, B) have a TTL, C) do not have a TTL and are not a root token
|
||||
if periodToUse > 0 || te.TTL > 0 || (te.TTL == 0 && !strutil.StrListContains(te.Policies, "root")) {
|
||||
if periodToUse > 0 || te.TTL > 0 || (te.TTL == 0 && !strutil.StrListContainsCaseInsensitive(te.Policies, "root")) {
|
||||
ttl, warnings, err := framework.CalculateTTL(sysView, 0, te.TTL, periodToUse, backendMaxTTL, explicitMaxTTLToUse, time.Unix(te.CreationTime, 0))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
Loading…
Reference in a new issue