backport of commit dee7fd839e (#20527)

Co-authored-by: Pratyoy Mukhopadhyay <35388175+pmmukh@users.noreply.github.com>
This commit is contained in:
hc-github-team-secure-vault-core
2023-05-05 09:39:51 -04:00
committed by GitHub
parent 6a2297e216
commit a27080bf73
5 changed files with 32 additions and 24 deletions

View File

@@ -145,6 +145,7 @@ func (f *AuditFormatter) FormatRequest(ctx context.Context, w io.Writer, config
reqEntry.Auth.PolicyResults.GrantingPolicies = append(reqEntry.Auth.PolicyResults.GrantingPolicies, PolicyInfo{
Name: p.Name,
NamespaceId: p.NamespaceId,
NamespacePath: p.NamespacePath,
Type: p.Type,
})
}
@@ -354,6 +355,7 @@ func (f *AuditFormatter) FormatResponse(ctx context.Context, w io.Writer, config
respEntry.Auth.PolicyResults.GrantingPolicies = append(respEntry.Auth.PolicyResults.GrantingPolicies, PolicyInfo{
Name: p.Name,
NamespaceId: p.NamespaceId,
NamespacePath: p.NamespacePath,
Type: p.Type,
})
}
@@ -454,6 +456,7 @@ type AuditPolicyResults struct {
type PolicyInfo struct {
Name string `json:"name,omitempty"`
NamespaceId string `json:"namespace_id,omitempty"`
NamespacePath string `json:"namespace_path,omitempty"`
Type string `json:"type"`
}

View File

@@ -125,5 +125,6 @@ type PolicyResults struct {
type PolicyInfo struct {
Name string `json:"name"`
NamespaceId string `json:"namespace_id"`
NamespacePath string `json:"namespace_path"`
Type string `json:"type"`
}

View File

@@ -340,6 +340,7 @@ func (a *ACL) AllowOperation(ctx context.Context, req *logical.Request, capCheck
ret.GrantingPolicies = []logical.PolicyInfo{{
Name: "root",
NamespaceId: "root",
NamespacePath: "",
Type: "acl",
}}
return

View File

@@ -873,11 +873,13 @@ func TestACLGrantingPolicies(t *testing.T) {
policyInfo := logical.PolicyInfo{
Name: "granting_policy",
NamespaceId: "root",
NamespacePath: "",
Type: "acl",
}
mergedInfo := logical.PolicyInfo{
Name: "granting_policy_merged",
NamespaceId: "root",
NamespacePath: "",
Type: "acl",
}

View File

@@ -268,6 +268,7 @@ func addGrantingPoliciesToMap(m map[uint32][]logical.PolicyInfo, policy *Policy,
m[capability] = append(m[capability], logical.PolicyInfo{
Name: policy.Name,
NamespaceId: policy.namespace.ID,
NamespacePath: policy.namespace.Path,
Type: "acl",
})
}