-
Notifications
You must be signed in to change notification settings - Fork 19
(feat) Support for creating users on cluster init #82
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| /* | ||
| Copyright 2025 Valkey Contributors. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| package v1alpha1 | ||
|
|
||
| // An UserAclSpec contains user, authorization, and permissions-related configurations | ||
| type UserAclSpec struct { | ||
|
|
||
| // Username | ||
| // +kubebuilder:required:message=A username is required | ||
| Name string `json:"name"` | ||
|
|
||
| // If the user is enabled or not | ||
| // +kubebuilder:default=true | ||
| Enabled bool `json:"enabled,omitempty"` | ||
|
|
||
| // Reference information to a Secret containing user passwords | ||
| // +optional | ||
| PasswordSecret PasswordSecretSpec `json:"passwordSecret,omitempty"` | ||
|
|
||
| // Do not apply a password to this user | ||
| // +kubebuilder:default=false | ||
| NoPassword bool `json:"nopass,omitempty"` | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think passwordEnabled or enabledPassword would be good naming here instead of NoPassword. Also i am not sure this is general use case of having nopass attached to user. if they really want to acheieve this they can always use rawacl.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might not be general or recommended, but if Valkey exposes it as an option it might be useful to abstract it away. https://valkey.io/topics/acl/#configure-acls-with-the-acl-command This boolean is used in the PR in a few places. If we were to remove NoPassword here, would we change those conditions to be
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the idea was since the ACL keyword is |
||
| // Valkey command categories, commands, and subcommands restrictions for this user | ||
| // +optional | ||
| Commands CommandsAclSpec `json:"commands,omitempty"` | ||
|
|
||
| // Key restrictions | ||
| // +optional | ||
| Keys KeysAclSpec `json:"keys,omitempty"` | ||
|
|
||
| // Channel restrictions | ||
| // +optional | ||
| Channels ChannelsAclSpec `json:"channels,omitempty"` | ||
|
|
||
| // Raw ACL for (additional) permissions. Appended to anything generated. | ||
| // +optional | ||
| RawAcl string `json:"permissions,omitempty"` | ||
| } | ||
|
|
||
| type PasswordSecretSpec struct { | ||
|
|
||
| // Name of the referencing Secret; Defaults to clustername-users | ||
| // +optional | ||
| Name string `json:"name,omitempty"` | ||
|
|
||
| // An array of keys inside the referencing Secret to find passwords; defaults to username | ||
| // Valkey supports multiple passwords per user for rotation | ||
| // +optional | ||
| Keys []string `json:"keys,omitempty"` | ||
| } | ||
|
|
||
| type CommandsAclSpec struct { | ||
|
|
||
| // Command categories (@all, @read, @write, @admin, etc.) | ||
| // Individual commands (get, set, ping, etc.) | ||
| // Subcommands (client|setname, config|get, etc.) | ||
|
|
||
| // Allowed commands for this user | ||
| // +kubebuilder:validation:Items:Pattern=^[@a-z|]+$} | ||
| Allow []string `json:"allow,omitempty"` | ||
|
|
||
| // Denied commands for this user | ||
| // +kubebuilder:validation:Items:Pattern=^[@a-z|]+$} | ||
| Deny []string `json:"deny,omitempty"` | ||
| } | ||
|
|
||
| type KeysAclSpec struct { | ||
|
|
||
| // Keys on which this user can read, and write; maps to Valkey: ~pattern | ||
| // +optional | ||
| ReadWrite []string `json:"readWrite,omitempty"` | ||
|
|
||
| // Keys restricted to read-only; maps to Valkey: %R~pattern | ||
| // +optional | ||
| ReadOnly []string `json:"readOnly,omitempty"` | ||
|
|
||
| // Keys restricted to write-only; maps to Valkey: %W~pattern | ||
| // +optional | ||
| WriteOnly []string `json:"writeOnly,omitempty"` | ||
| } | ||
|
|
||
| type ChannelsAclSpec struct { | ||
|
|
||
| // Pub/Sub channel patterns - maps to Valkey: &pattern | ||
| // +optional | ||
| Patterns []string `json:"patterns,omitempty"` | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ rules: | |
| - "" | ||
| resources: | ||
| - configmaps | ||
| - secrets | ||
| - services | ||
| verbs: | ||
| - create | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The golangci-lint was only ran during github e2e tests, and it was frustrating for this to fail remotely. Simple change to check this locally first.