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

CLI: add subcommand access for principals #1019

Merged
merged 2 commits into from
Feb 24, 2025
Merged

Conversation

MonkeyCanCode
Copy link
Contributor

This is one of the purposed CLI option in #989 (item 1). This new subcommand will display the entities relation a given principal has.

Here is a sample output for quickstart_user based on our example:

{
  "principal": "quickstart_user",
  "principal_roles": [
    {
      "name": "quickstart_user_role",
      "catalog_roles": [
        {
          "name": "quickstart_catalog_role",
          "catalog": "quickstart_catalog",
          "privileges": [
            {
              "type": "catalog",
              "privilege": "CATALOG_MANAGE_CONTENT"
            }
          ]
        }
      ]
    }
  ]
}

Here is another example for the same user but with additional access, principal roles, and catalogs:

{
  "principal": "quickstart_user",
  "principal_roles": [
    {
      "name": "demo_user_role",
      "catalog_roles": [
        {
          "name": "demo_catalog_role",
          "catalog": "demo_catalog",
          "privileges": [
            {
              "type": "catalog",
              "privilege": "CATALOG_MANAGE_CONTENT"
            },
            {
              "type": "namespace",
              "namespace": [
                "default"
              ],
              "privilege": "NAMESPACE_LIST"
            },
            {
              "type": "table",
              "namespace": [
                "default"
              ],
              "tableName": "test",
              "privilege": "TABLE_READ_PROPERTIES"
            },
            {
              "type": "table",
              "namespace": [
                "default"
              ],
              "tableName": "test",
              "privilege": "TABLE_READ_DATA"
            }
          ]
        }
      ]
    },
    {
      "name": "demo_user_empty_role",
      "catalog_roles": []
    },
    {
      "name": "quickstart_user_role",
      "catalog_roles": [
        {
          "name": "quickstart_catalog_role",
          "catalog": "quickstart_catalog",
          "privileges": [
            {
              "type": "catalog",
              "privilege": "CATALOG_MANAGE_CONTENT"
            }
          ]
        }
      ]
    }
  ]
}

Here is an sample output for a user with zero reference:

{
  "principal": "test",
  "principal_roles": []
}

'catalog_roles': []
}
# For each catalog role, get associated privileges
for catalog in self._get_catalogs(api):
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder how frequently duplicates will appear, and whether we could try to remove them

@MonkeyCanCode MonkeyCanCode merged commit 61a954c into apache:main Feb 24, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants