GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — ACL patterns for Pub/Sub channels (#2750) · redis/jedis@dc6a891

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • main/java/redis/clients/jedis
      • BuilderFactory.java
      • commands
        • AccessControlLogBinaryCommands.java
        • AccessControlLogCommands.java
      • resps
        • AccessControlUser.java
    • test/java/redis/clients/jedis/commands/jedis
      • AccessControlListCommandsTest.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/main/java/redis/clients/jedis/BuilderFactory.java‎

Copy file name to clipboardExpand all lines: src/main/java/redis/clients/jedis/BuilderFactory.java
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,7 @@ public String toString() {
692692
* Create a AccessControlUser object from the ACL GETUSER < > result
693693
*/
694694
public static final Builder<AccessControlUser> ACCESS_CONTROL_USER = new Builder<AccessControlUser>() {
695+
@SuppressWarnings("unchecked")
695696
@Override
696697
public AccessControlUser build(Object data) {
697698
if (data == null) {
@@ -726,6 +727,14 @@ public AccessControlUser build(Object data) {
726727
accessControlUser.addKey(SafeEncoder.encode((byte[]) k));
727728
}
728729

730+
// before redis 6.2, no channels info
731+
if (objectList.size() > 9) {
732+
List<Object> channels = objectList.get(9);
733+
for (Object channel : channels) {
734+
accessControlUser.addChannel(SafeEncoder.encode((byte[]) channel));
735+
}
736+
}
737+
729738
return accessControlUser;
730739
}
731740

Collapse file

‎src/main/java/redis/clients/jedis/commands/AccessControlLogBinaryCommands.java‎

Copy file name to clipboardExpand all lines: src/main/java/redis/clients/jedis/commands/AccessControlLogBinaryCommands.java
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ public interface AccessControlLogBinaryCommands {
5353
*/
5454
List<byte[]> aclUsersBinary();
5555

56+
/**
57+
* The command returns all the rules defined for an existing ACL user.
58+
* @param name username
59+
* @return a list of ACL rule definitions for the user.
60+
*/
5661
AccessControlUser aclGetUser(byte[] name);
5762

5863
/**
Collapse file

‎src/main/java/redis/clients/jedis/commands/AccessControlLogCommands.java‎

Copy file name to clipboardExpand all lines: src/main/java/redis/clients/jedis/commands/AccessControlLogCommands.java
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ public interface AccessControlLogCommands {
5555
*/
5656
List<String> aclUsers();
5757

58+
/**
59+
* The command returns all the rules defined for an existing ACL user.
60+
* @param name username
61+
* @return a list of ACL rule definitions for the user.
62+
*/
5863
AccessControlUser aclGetUser(String name);
5964

6065
/**
Collapse file

‎src/main/java/redis/clients/jedis/resps/AccessControlUser.java‎

Copy file name to clipboardExpand all lines: src/main/java/redis/clients/jedis/resps/AccessControlUser.java
+10-1Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public class AccessControlUser {
88
private final List<String> flags = new ArrayList<>();
99
private final List<String> keys = new ArrayList<>();
1010
private final List<String> passwords = new ArrayList<>();
11+
private final List<String> channels = new ArrayList<>();
1112
private String commands;
1213

1314
public AccessControlUser() {
@@ -37,6 +38,14 @@ public List<String> getPassword() {
3738
return passwords;
3839
}
3940

41+
public void addChannel(String channel) {
42+
channels.add(channel);
43+
}
44+
45+
public List<String> getChannels() {
46+
return channels;
47+
}
48+
4049
public String getCommands() {
4150
return commands;
4251
}
@@ -48,6 +57,6 @@ public void setCommands(String commands) {
4857
@Override
4958
public String toString() {
5059
return "AccessControlUser{" + "flags=" + flags + ", keys=" + keys + ", passwords=" + passwords
51-
+ ", commands='" + commands + '\'' + '}';
60+
+ ", commands='" + commands + ", channels='" + channels + '\'' + '}';
5261
}
5362
}
Collapse file

‎src/test/java/redis/clients/jedis/commands/jedis/AccessControlListCommandsTest.java‎

Copy file name to clipboardExpand all lines: src/test/java/redis/clients/jedis/commands/jedis/AccessControlListCommandsTest.java
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,13 +454,15 @@ public void aclBinaryCommandsTest() {
454454
assertEquals(1L, jedis.aclDelUser(USER_ZZZ.getBytes()));
455455

456456
jedis.aclSetUser(USER_ZZZ.getBytes(), "reset".getBytes(), "+@all".getBytes(), "~*".getBytes(),
457-
"-@string".getBytes(), "+incr".getBytes(), "-debug".getBytes(), "+debug|digest".getBytes());
457+
"-@string".getBytes(), "+incr".getBytes(), "-debug".getBytes(), "+debug|digest".getBytes(),
458+
"resetchannels".getBytes(), "&testchannel:*".getBytes());
458459

459460
AccessControlUser userInfo = jedis.aclGetUser(USER_ZZZ.getBytes());
460461

461462
assertThat(userInfo.getCommands(), containsString("+@all"));
462463
assertThat(userInfo.getCommands(), containsString("-@string"));
463464
assertThat(userInfo.getCommands(), containsString("+debug|digest"));
465+
assertEquals("testchannel:*", userInfo.getChannels().get(0));
464466

465467
jedis.aclDelUser(USER_ZZZ.getBytes());
466468

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.