mirror of
http://github.com/valkey-io/valkey
synced 2024-11-22 00:52:38 +00:00
6948dacaf6
This allows modules to register commands to existing ACL categories and blocks the creation of [sub]commands, datatypes and registering the configs outside of the OnLoad function. For allowing modules to register commands to existing ACL categories, This PR implements a new API int RM_SetCommandACLCategories() which takes a pointer to a RedisModuleCommand and a C string aclflags containing the set of space separated ACL categories. Example, 'write slow' marks the command as part of the write and slow ACL categories. The C string aclflags is tokenized by implementing a helper function categoryFlagsFromString(). Theses tokens are matched and the corresponding ACL categories flags are set by a helper function matchAclCategoriesFlags. The helper function categoryFlagsFromString() returns the corresponding categories_flags or returns -1 if some token not processed correctly. If the module contains commands which are registered to existing ACL categories, the number of [sub]commands are tracked by num_commands_with_acl_categories in struct RedisModule. Further, the allowed command bit-map of the existing users are recomputed from the command_rules list, by implementing a function called ACLRecomputeCommandBitsFromCommandRulesAllUsers() for the existing users to have access to the module commands on runtime. ## Breaking change This change requires that registering commands and subcommands only occur during a modules "OnLoad" function, in order to allow efficient recompilation of ACL bits. We also chose to block registering configs and types, since we believe it's only valid for those to be created during onLoad. We check for this onload flag in struct RedisModule to check if the call is made from the OnLoad function. Co-authored-by: Madelyn Olson <madelyneolson@gmail.com> |
||
---|---|---|
.. | ||
aclcheck.c | ||
auth.c | ||
basics.c | ||
blockedclient.c | ||
blockonbackground.c | ||
blockonkeys.c | ||
cmdintrospection.c | ||
commandfilter.c | ||
datatype2.c | ||
datatype.c | ||
defragtest.c | ||
eventloop.c | ||
fork.c | ||
getchannels.c | ||
getkeys.c | ||
hash.c | ||
hooks.c | ||
infotest.c | ||
keyspace_events.c | ||
keyspecs.c | ||
list.c | ||
Makefile | ||
mallocsize.c | ||
misc.c | ||
moduleauthtwo.c | ||
moduleconfigs.c | ||
moduleconfigstwo.c | ||
postnotifications.c | ||
propagate.c | ||
publish.c | ||
reply.c | ||
scan.c | ||
stream.c | ||
subcommands.c | ||
test_lazyfree.c | ||
testrdb.c | ||
timer.c | ||
usercall.c | ||
zset.c |