Skip to content
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

Backport of [VAULT-14649] Add ns path to granting_policies into release/1.13.x #20527

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions audit/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,10 @@ func (f *AuditFormatter) FormatRequest(ctx context.Context, w io.Writer, config

for _, p := range auth.PolicyResults.GrantingPolicies {
reqEntry.Auth.PolicyResults.GrantingPolicies = append(reqEntry.Auth.PolicyResults.GrantingPolicies, PolicyInfo{
Name: p.Name,
NamespaceId: p.NamespaceId,
Type: p.Type,
Name: p.Name,
NamespaceId: p.NamespaceId,
NamespacePath: p.NamespacePath,
Type: p.Type,
})
}
}
Expand Down Expand Up @@ -352,9 +353,10 @@ func (f *AuditFormatter) FormatResponse(ctx context.Context, w io.Writer, config

for _, p := range auth.PolicyResults.GrantingPolicies {
respEntry.Auth.PolicyResults.GrantingPolicies = append(respEntry.Auth.PolicyResults.GrantingPolicies, PolicyInfo{
Name: p.Name,
NamespaceId: p.NamespaceId,
Type: p.Type,
Name: p.Name,
NamespaceId: p.NamespaceId,
NamespacePath: p.NamespacePath,
Type: p.Type,
})
}
}
Expand Down Expand Up @@ -452,9 +454,10 @@ type AuditPolicyResults struct {
}

type PolicyInfo struct {
Name string `json:"name,omitempty"`
NamespaceId string `json:"namespace_id,omitempty"`
Type string `json:"type"`
Name string `json:"name,omitempty"`
NamespaceId string `json:"namespace_id,omitempty"`
NamespacePath string `json:"namespace_path,omitempty"`
Type string `json:"type"`
}

type AuditSecret struct {
Expand Down
7 changes: 4 additions & 3 deletions sdk/logical/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ type PolicyResults struct {
}

type PolicyInfo struct {
Name string `json:"name"`
NamespaceId string `json:"namespace_id"`
Type string `json:"type"`
Name string `json:"name"`
NamespaceId string `json:"namespace_id"`
NamespacePath string `json:"namespace_path"`
Type string `json:"type"`
}
7 changes: 4 additions & 3 deletions vault/acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,10 @@ func (a *ACL) AllowOperation(ctx context.Context, req *logical.Request, capCheck
ret.RootPrivs = true
ret.IsRoot = true
ret.GrantingPolicies = []logical.PolicyInfo{{
Name: "root",
NamespaceId: "root",
Type: "acl",
Name: "root",
NamespaceId: "root",
NamespacePath: "",
Type: "acl",
}}
return
}
Expand Down
14 changes: 8 additions & 6 deletions vault/acl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -871,14 +871,16 @@ func TestACLGrantingPolicies(t *testing.T) {
}

policyInfo := logical.PolicyInfo{
Name: "granting_policy",
NamespaceId: "root",
Type: "acl",
Name: "granting_policy",
NamespaceId: "root",
NamespacePath: "",
Type: "acl",
}
mergedInfo := logical.PolicyInfo{
Name: "granting_policy_merged",
NamespaceId: "root",
Type: "acl",
Name: "granting_policy_merged",
NamespaceId: "root",
NamespacePath: "",
Type: "acl",
}

tcases := []tcase{
Expand Down
7 changes: 4 additions & 3 deletions vault/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,10 @@ func addGrantingPoliciesToMap(m map[uint32][]logical.PolicyInfo, policy *Policy,
}

m[capability] = append(m[capability], logical.PolicyInfo{
Name: policy.Name,
NamespaceId: policy.namespace.ID,
Type: "acl",
Name: policy.Name,
NamespaceId: policy.namespace.ID,
NamespacePath: policy.namespace.Path,
Type: "acl",
})
}

Expand Down