Skip to content
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

rpk/security/acl/list: support --format=json #17684

Merged
merged 1 commit into from
Apr 5, 2024

Conversation

rockwotj
Copy link
Contributor

@rockwotj rockwotj commented Apr 5, 2024

Example output:

$ ./linux-amd64/rpk security acl list --format=text
PRINCIPAL  HOST  RESOURCE-TYPE  RESOURCE-NAME  RESOURCE-PATTERN-TYPE  OPERATION  PERMISSION  ERROR
User:bar   *     TOPIC          foo            LITERAL                ALL        ALLOW
User:bar   *     GROUP          g              LITERAL                ALL        ALLOW

$ ./linux-amd64/rpk security acl list -f --format=text
FILTERS
=======
PRINCIPAL  HOST  RESOURCE-TYPE  RESOURCE-NAME  RESOURCE-PATTERN-TYPE  OPERATION  PERMISSION  ERROR
                 ANY                           ANY                    ANY        ANY

MATCHES
=======
PRINCIPAL  HOST  RESOURCE-TYPE  RESOURCE-NAME  RESOURCE-PATTERN-TYPE  OPERATION  PERMISSION  ERROR
User:bar   *     TOPIC          foo            LITERAL                ALL        ALLOW
User:bar   *     GROUP          g              LITERAL                ALL        ALLOW

$ ./linux-amd64/rpk security acl list --format=json | jq
{
  "matches": [
    {
      "principal": "User:bar",
      "host": "*",
      "resource_type": "TOPIC",
      "resource_name": "foo",
      "resource_pattern_type": "LITERAL",
      "operation": "ALL",
      "permission": "ALLOW"
    },
    {
      "principal": "User:bar",
      "host": "*",
      "resource_type": "GROUP",
      "resource_name": "g",
      "resource_pattern_type": "LITERAL",
      "operation": "ALL",
      "permission": "ALLOW"
    }
  ]
}

$ ./linux-amd64/rpk security acl list -f --format=json | jq
{
  "filters": [
    {
      "principal": "",
      "host": "",
      "resource_type": "ANY",
      "resource_name": "",
      "resource_pattern_type": "ANY",
      "operation": "ANY",
      "permission": "ANY",
      "message": ""
    }
  ],
  "matches": [
    {
      "principal": "User:bar",
      "host": "*",
      "resource_type": "TOPIC",
      "resource_name": "foo",
      "resource_pattern_type": "LITERAL",
      "operation": "ALL",
      "permission": "ALLOW"
    },
    {
      "principal": "User:bar",
      "host": "*",
      "resource_type": "GROUP",
      "resource_name": "g",
      "resource_pattern_type": "LITERAL",
      "operation": "ALL",
      "permission": "ALLOW"
    }
  ]
}

Fixes: #17679

Backports Required

  • none - not a bug fix
  • none - this is a backport
  • none - issue does not exist in previous branches
  • none - papercut/not impactful enough to backport
  • v23.3.x
  • v23.2.x

Release Notes

Features

  • rpk security acl list now supports --format=json

Example output:

```
$ ./linux-amd64/rpk security acl list --format=text
PRINCIPAL  HOST  RESOURCE-TYPE  RESOURCE-NAME  RESOURCE-PATTERN-TYPE  OPERATION  PERMISSION  ERROR
User:bar   *     TOPIC          foo            LITERAL                ALL        ALLOW
User:bar   *     GROUP          g              LITERAL                ALL        ALLOW

$ ./linux-amd64/rpk security acl list -f --format=text
FILTERS
=======
PRINCIPAL  HOST  RESOURCE-TYPE  RESOURCE-NAME  RESOURCE-PATTERN-TYPE  OPERATION  PERMISSION  ERROR
                 ANY                           ANY                    ANY        ANY

MATCHES
=======
PRINCIPAL  HOST  RESOURCE-TYPE  RESOURCE-NAME  RESOURCE-PATTERN-TYPE  OPERATION  PERMISSION  ERROR
User:bar   *     TOPIC          foo            LITERAL                ALL        ALLOW
User:bar   *     GROUP          g              LITERAL                ALL        ALLOW

$ ./linux-amd64/rpk security acl list --format=json | jq
{
  "matches": [
    {
      "principal": "User:bar",
      "host": "*",
      "resource_type": "TOPIC",
      "resource_name": "foo",
      "resource_pattern_type": "LITERAL",
      "operation": "ALL",
      "permission": "ALLOW"
    },
    {
      "principal": "User:bar",
      "host": "*",
      "resource_type": "GROUP",
      "resource_name": "g",
      "resource_pattern_type": "LITERAL",
      "operation": "ALL",
      "permission": "ALLOW"
    }
  ]
}

$ ./linux-amd64/rpk security acl list -f --format=json | jq
{
  "filters": [
    {
      "principal": "",
      "host": "",
      "resource_type": "ANY",
      "resource_name": "",
      "resource_pattern_type": "ANY",
      "operation": "ANY",
      "permission": "ANY",
      "message": ""
    }
  ],
  "matches": [
    {
      "principal": "User:bar",
      "host": "*",
      "resource_type": "TOPIC",
      "resource_name": "foo",
      "resource_pattern_type": "LITERAL",
      "operation": "ALL",
      "permission": "ALLOW"
    },
    {
      "principal": "User:bar",
      "host": "*",
      "resource_type": "GROUP",
      "resource_name": "g",
      "resource_pattern_type": "LITERAL",
      "operation": "ALL",
      "permission": "ALLOW"
    }
  ]
}

```

Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
Copy link
Contributor

@r-vasquez r-vasquez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THANKS! This is awesome :D

@vbotbuildovich
Copy link
Collaborator

@rockwotj rockwotj merged commit ab44f53 into redpanda-data:dev Apr 5, 2024
23 checks passed
@rockwotj rockwotj deleted the acl-list-format-json branch April 5, 2024 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Request to support output a json blob from rpk of rpk acl list
3 participants