Skip to content
This repository was archived by the owner on Mar 15, 2024. It is now read-only.

Commit 4780e70

Browse files
authored
Merge pull request #22 from splunk/mw/ephemeral-creds
renamed roles parameter allowed_node_types to allowed_server_roles
2 parents 22f6aa8 + b04a394 commit 4780e70

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

backend_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ func TestBackend_RoleCRUD(t *testing.T) {
8787
}
8888

8989
testRoleConfig := roleConfig{
90-
Connection: "testconn",
91-
Roles: []string{"admin"},
92-
AllowedNodeTypes: []string{"*"},
93-
PasswordSpec: DefaultPasswordSpec(),
94-
UserPrefix: "my-custom-prefix",
90+
Connection: "testconn",
91+
Roles: []string{"admin"},
92+
AllowedServerRoles: []string{"*"},
93+
PasswordSpec: DefaultPasswordSpec(),
94+
UserPrefix: "my-custom-prefix",
9595
}
9696

9797
logicaltest.Test(t, logicaltest.TestCase{

path_creds_create.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,15 @@ func findNode(nodeFQDN string, hosts []splunk.ServerInfoEntry, roleConfig *roleC
129129
// check if node_fqdn is in either of HostFQDN or Host. User might not always the FQDN on the cli input
130130
if host.Content.HostFQDN == nodeFQDN || host.Content.Host == nodeFQDN {
131131
// Return true if the requested node type is allowed
132-
if strutil.StrListContains(roleConfig.AllowedNodeTypes, "*") {
132+
if strutil.StrListContains(roleConfig.AllowedServerRoles, "*") {
133133
return true, nil
134134
}
135135
for _, role := range host.Content.Roles {
136-
if strutil.StrListContainsGlob(roleConfig.AllowedNodeTypes, role) {
136+
if strutil.StrListContainsGlob(roleConfig.AllowedServerRoles, role) {
137137
return true, nil
138138
}
139139
}
140-
return false, fmt.Errorf("host %q does not have an allowed node type", nodeFQDN)
140+
return false, fmt.Errorf("host %q does not have any of the allowed server roles: %q", nodeFQDN, roleConfig.AllowedServerRoles)
141141
}
142142
}
143143
return false, fmt.Errorf("host %q not found", nodeFQDN)

path_roles.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func (b *backend) pathRoles() *framework.Path {
3535
Type: framework.TypeCommaStringSlice,
3636
Description: "Comma-separated string or list of Splunk roles.",
3737
},
38-
"allowed_node_types": &framework.FieldSchema{
38+
"allowed_server_roles": &framework.FieldSchema{
3939
Type: framework.TypeCommaStringSlice,
4040
Description: trimIndent(`
4141
Comma-separated string or array of node type (glob) patterns that are allowed
@@ -122,8 +122,8 @@ func (b *backend) rolesWriteHandler(ctx context.Context, req *logical.Request, d
122122
if maxTTLRaw, ok := getValue(data, req.Operation, "max_ttl"); ok {
123123
role.MaxTTL = time.Duration(maxTTLRaw.(int)) * time.Second
124124
}
125-
if allowed_node_types, ok := getValue(data, req.Operation, "allowed_node_types"); ok {
126-
role.AllowedNodeTypes = allowed_node_types.([]string)
125+
if allowedServerRoles, ok := getValue(data, req.Operation, "allowed_server_roles"); ok {
126+
role.AllowedServerRoles = allowedServerRoles.([]string)
127127
}
128128
role.PasswordSpec = DefaultPasswordSpec() // XXX make configurable
129129

role.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import (
1111
)
1212

1313
type roleConfig struct {
14-
Connection string `json:"connection" structs:"connection"`
15-
DefaultTTL time.Duration `json:"default_ttl" structs:"default_ttl"`
16-
MaxTTL time.Duration `json:"max_ttl" structs:"max_ttl"`
17-
AllowedNodeTypes []string `json:"allowed_node_types" structs:"allowed_node_types"`
18-
PasswordSpec *PasswordSpec `json:"password_spec" structs:"password_spec"`
14+
Connection string `json:"connection" structs:"connection"`
15+
DefaultTTL time.Duration `json:"default_ttl" structs:"default_ttl"`
16+
MaxTTL time.Duration `json:"max_ttl" structs:"max_ttl"`
17+
AllowedServerRoles []string `json:"allowed_server_roles" structs:"allowed_server_roles"`
18+
PasswordSpec *PasswordSpec `json:"password_spec" structs:"password_spec"`
1919

2020
// Splunk user attributes
2121
Roles []string `json:"roles" structs:"roles"`

0 commit comments

Comments
 (0)