Creating Ranger policies for additional catalogs

Grant catalog-create and catalog-list permissions on the Harmony Catalog Ranger service so you can create catalogs through the management API.

You must open Ranger Admin with a user that has Ranger Admin permission. If you do not see Harmony Catalog services or policies, ask a platform administrator to grant Ranger Admin. See Ranger users, groups, and administrators.

Ensure to have the following values before you create the policy:

  • Your exact Knox sign-in username (case-sensitive).
  • The Ranger service name for your Cloudera Harmony Catalog instance, for example udf_harmony_catalog_<blueprint-name>, where <blueprint-name> is the blueprint name for your deployment. Confirm the name in Ranger Admin on Cloudera Unified Data Fabric.
  1. In Ranger Admin, create a policy in the UI.
    1. Open Ranger from the Cloudera Unified Data Fabric engine landing page.
    2. Go to Access Manager > Resource Based Policies.
    3. Open the service udf_harmony_catalog_<blueprint-name> and click Add New Policy.
    4. Fill in the policy:
      • Policy Name: catalog-creators
      • root: *. Leave every other resource field (catalog, namespace, table) empty.
      • Allow Conditions → Select User: your Knox username. To grant the same permissions to others, add their usernames to this policy.
      • Permissions: select Catalog Create and Catalog List.
    5. Click Add.
  2. Alternatively, create the policy with the Ranger API.

    TOKEN is a Knox bearer token for a Ranger admin. RANGER_URL is the Ranger URL from the Cloudera Unified Data Fabric landing page.

    curl -sk -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
      -X POST "${RANGER_URL}/service/public/v2/api/policy" -d '{
        "isEnabled": true,
        "service": "udf_harmony_catalog_<blueprint-name>",
        "name": "catalog-creators",
        "isAuditEnabled": true,
        "resources": { "root": { "values": ["*"], "isExcludes": false, "isRecursive": false } },
        "policyItems": [{
          "users": ["<username>"],
          "accesses": [
            { "type": "catalog-create", "isAllowed": true },
            { "type": "catalog-list",   "isAllowed": true }
          ],
          "delegateAdmin": false
        }]
      }'

You can create and list catalogs on the Cloudera Harmony Catalog management API after the policy takes effect.

  • Wait about 30 to 60 seconds for the policy to take effect.
  • Set only root on this policy. Catalog creation is checked at the service root, so a policy that also sets a catalog does not allow creation.
  • This grant allows creating and listing catalogs only. It does not authorize namespaces or tables. If users will create namespaces or tables through the REST API, grant those permissions on the target catalog first—before they run those steps—not only catalog create and list.
  • If you get 403 Principal '<user>' is not authorized ... when creating a catalog, the policy is missing or your username does not match your Knox sign-in name.

To create catalogs after Ranger is configured, see Creating catalogs, namespaces, and tables on Cloudera Harmony Catalog.