mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 03:27:54 +00:00
When using tokenutil, return []string not nil for empty slices (#7019)
This conveys type information instead of being a JSON null.
This commit is contained in:
@@ -172,7 +172,7 @@ func (b *backend) pathUserRead(ctx context.Context, req *logical.Request, d *fra
|
||||
data["max_ttl"] = int64(user.MaxTTL.Seconds())
|
||||
}
|
||||
if len(user.Policies) > 0 {
|
||||
data["policies"] = user.Policies
|
||||
data["policies"] = data["token_policies"]
|
||||
}
|
||||
if len(user.BoundCIDRs) > 0 {
|
||||
data["bound_cidrs"] = user.BoundCIDRs
|
||||
|
||||
@@ -212,6 +212,14 @@ func (t *TokenParams) PopulateTokenData(m map[string]interface{}) {
|
||||
m["token_type"] = t.TokenType.String()
|
||||
m["token_ttl"] = int64(t.TokenTTL.Seconds())
|
||||
m["token_num_uses"] = t.TokenNumUses
|
||||
|
||||
if len(t.TokenPolicies) == 0 {
|
||||
m["token_policies"] = []string{}
|
||||
}
|
||||
|
||||
if len(t.TokenBoundCIDRs) == 0 {
|
||||
m["token_bound_cidrs"] = []string{}
|
||||
}
|
||||
}
|
||||
|
||||
// PopulateTokenAuth populates Auth with parameters
|
||||
|
||||
Reference in New Issue
Block a user