Skip to content

Commit

Permalink
yml: fix regression parsing policy definitions
Browse files Browse the repository at this point in the history
This commit fixes a regression introduced by
a229d68.

Identities assigned to a policy in the YAML
config file have been ignored in the following
case:
```
policy:
   - my-policy:
       allow:
         - /v1/key/create/*
       identity:
         - ${MY_CLIENT_IDENTITY}
```

Before, the config file parsing expected
`identities` - not `identity`. After a229d68
`identities` has been ignored. This commit
fixes this by reverting to the previous behavior
of only honoring `identities`.

Signed-off-by: Andreas Auernhammer <[email protected]>
  • Loading branch information
aead authored and harshavardhana committed Jan 6, 2022
1 parent 5a52d51 commit 2629439
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion internal/yml/server-config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type ServerConfig struct {
Policies map[string]struct {
Allow []string `yaml:"allow"` // Use 'string' type; We don't replace API allow patterns with env. vars
Deny []string `yaml:"deny"` // Use 'string' type; We don't replace API deny patterns with env. vars
Identities []Identity `yaml:"identity"`
Identities []Identity `yaml:"identities"`
} `yaml:"policy"`

Cache struct {
Expand Down
4 changes: 2 additions & 2 deletions internal/yml/server-config_v0.13.5.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,12 @@ func (c *serverConfigV0135) migrate() *ServerConfig {
type Policy struct {
Allow []string `yaml:"allow"`
Deny []string `yaml:"deny"`
Identities []Identity `yaml:"identity"`
Identities []Identity `yaml:"identities"`
}
config.Policies = make(map[string]struct {
Allow []string `yaml:"allow"`
Deny []string `yaml:"deny"`
Identities []Identity `yaml:"identity"`
Identities []Identity `yaml:"identities"`
}, len(c.Policies))
for name, policy := range c.Policies {
config.Policies[name] = Policy{
Expand Down
4 changes: 2 additions & 2 deletions internal/yml/server-config_v0.14.0.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,12 @@ func (c *serverConfigV0140) migrate() *ServerConfig {
type Policy struct {
Allow []string `yaml:"allow"`
Deny []string `yaml:"deny"`
Identities []Identity `yaml:"identity"`
Identities []Identity `yaml:"identities"`
}
config.Policies = make(map[string]struct {
Allow []string `yaml:"allow"`
Deny []string `yaml:"deny"`
Identities []Identity `yaml:"identity"`
Identities []Identity `yaml:"identities"`
}, len(c.Policies))
for name, policy := range c.Policies {
config.Policies[name] = Policy{
Expand Down
2 changes: 1 addition & 1 deletion internal/yml/server-config_v0.17.0.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type serverConfigV0170 struct {
Policies map[string]struct {
Allow []string `yaml:"allow"` // Use 'string' type; We don't replace API allow patterns with env. vars
Deny []string `yaml:"deny"` // Use 'string' type; We don't replace API deny patterns with env. vars
Identities []Identity `yaml:"identity"`
Identities []Identity `yaml:"identities"`
} `yaml:"policy"`

Cache struct {
Expand Down

0 comments on commit 2629439

Please sign in to comment.