Vai al contenuto principale

Storage Access Control with Ranger (Enterprise)

Table policies in Ranger protect data that is read through a SQL engine. Files in object storage are protected separately: an identity that holds storage keys can read every object its keys allow, whatever the table policies say. Ilum policy-sync closes that gap for Ceph RGW. Bucket and prefix permissions are written in Ranger, in a service of type ilum-objectstore, and policy-sync compiles them on a schedule into the IAM policies of the RGW accounts that own the buckets.

How it works​

  • A Ranger service of type ilum-objectstore holds policies on two resources: bucket e sentiero (a prefix inside the bucket, recursive or not), with the access types list, leggere, scrivere e cancellare.
  • Each storage identity is an IAM user of an RGW account (one per workspace and per engine catalog). Ranger groups are bound to an IAM group or an IAM user of the account that owns the bucket.
  • policy-sync runs as a Kubernetes CronJob. Each run downloads the policies from Ranger, compiles one IAM document per bound principal and bucket, compares it with what the account holds and writes the difference as inline group or user policies named <managedPrefix><bucket> (by default ilum-psync-<bucket>).
  • Every statement id names the Ranger policy and its version (rangerP12V3Read), so each permission in RGW traces back to the policy that granted it.

A policy change reaches RGW within one schedule interval (5 minutes by default) plus the run time.

Fabbisogno​

  • Ceph Squid (19.x) or later, for RGW accounts. Tentacle 20.2.4 or later is recommended for a new installation.
  • Apache Ranger 2.9 with a user that may download the service's policies.
  • Network access from the CronJob to Ranger and to the RGW endpoints.

Account model​

Accounts separate permissions: an identity of one account has no access to the buckets of another unless granted there. A layout that keeps sensitive data apart:

AccountHolds
acct-platformPlatform and application buckets
acct-domainsDomain buckets (finance, sales, ...)
acct-hrHR buckets and every identity allowed to read them
acct-publishedMasked derived tables

Every identity that may read HR raw objects is a user of acct-hr, so no cross-account grant is needed. A Ranger group bound only in another account gets nothing on an HR bucket, and the run reports it.

Setting up​

1. Create the accounts​

Accounts and their root users are created with radosgw-admin:

radosgw-admin account create --account-name=acct-domains [email protected]
radosgw-admin user create --uid=acct-domains-root --display-name="acct-domains root" \
--account-id=<account id> --account-root --gen-access-key --gen-secret

Store the root keys of each account in a Kubernetes Secret with the keys access-key e secret-key. Only policy-sync reads these Secrets.

2. Provision identities and buckets​

policy-sync provision creates the IAM users and groups, the group memberships and the buckets of a model, and sets a bucket guard that denies every request without TLS. It is idempotent and reports each step as created, changed or existing. Members a group has beyond the model are reported, never removed. Access keys are not created by this step.

accounts:
acct-domains:
Gli utenti: [ws-finance, svc-Trino]
Gruppi:
ws-finance: [ws-finance]
buckets:
finance: {requireTls: vero}
acct-hr:
Gli utenti: [ws-hr, svc-Trino-hr]
Gruppi:
ws-hr: [ws-hr]
buckets:
hr-raw: {requireTls: vero}
policy-sync provision --config config.yaml --model model.yaml

Issue an access key for each identity with radosgw-admin key create or the IAM CreateAccessKey call, and store it where the workspace or the engine catalog reads it.

avvertimento

RGW sets the aws:SecureTransport condition key only on connections it terminates with TLS itself; the guard therefore denies every request that reaches RGW over plain HTTP. When a load balancer or ingress terminates TLS in front of RGW, set rgw_trust_forwarded_https = true and make sure the proxy sends X-Forwarded-Proto: https, or the guard denies all requests to the guarded buckets. Check one request through the real path before guarding a bucket in use.

3. Register the service in Ranger​

policy-sync bootstrap registers the ilum-objectstore service definition and creates the service named in the configuration, with the policy-download user. It needs a Ranger administrator and is idempotent:

policy-sync bootstrap --config config.yaml --admin-user admin --admin-password-file ./ranger-admin-password

4. Install the chart​

Le ilum-policy-sync chart deploys the CronJob, its configuration and a NetworkPolicy that denies all ingress and allows egress only to DNS and, on the configured ports, to pods of the cluster. An RGW outside the cluster is added with networkPolicy.egressCidrs. The chart starts in mode: plan:

ranger:
URL: http (in inglese)://ilum-ranger:6080
servizio: objectstore
Auth: {nome utente: policy-sync, existingSecret: ranger-policy-sync}
targets:
- nome: acct-domains
Endpoint: https://rgw.example.internal
existingSecret: rgw-acct-domains
buckets: [finance]
principals:
GG-Finance-Eng: {group: ws-finance}
- nome: acct-hr
Endpoint: https://rgw.example.internal
existingSecret: rgw-acct-hr
buckets: [hr-raw]
principals:
GG-HR: {group: ws-hr}
svc-trino-hr: {utente: svc-Trino-hr}
networkPolicy:
egressCidrs: ["10.20.0.0/24"]
helm install ilum-policy-sync ilum/ilum-policy-sync -f policy-sync-values.yaml
kubectl logs -l app.kubernetes.io/instance=ilum-policy-sync --tail=1

Each run prints one JSON run record. Once the planned changes match the intent, set mode: apply.

Writing policies​

A policy names buckets (wildcards * e ? expand to the matching buckets of the targets) and paths. Access types compile to S3 actions as follows:

AccessS3 actionsRisorsa
lists3:ListBucket with an s3:prefix condition, and s3:GetBucketLocationThe bucket
leggeres3:GetObjectThe objects under the path
scriveres3:PutObject, s3:AbortMultipartUpload, s3:ListMultipartUploadPartse s3:ListBucketMultipartUploads on the bucketThe objects under the path
cancellares3:DeleteObjectThe objects under the path

compile.versionedBuckets adds s3:GetObjectVersion e s3:DeleteObjectVersion. A recursive path /curated covers curated/*; a non-recursive path names one object. Deny items compile to Deny statements, which win over every allow.

Un list deny on a path also denies listing the bucket root and every prefix above the path. A listing with a shorter prefix, or with none, returns the keys under the path as well, so a deny limited to the path itself could be bypassed. s3:ListBucketMultipartUploads is granted on the whole bucket with scrivere, because RGW does not evaluate s3:prefix for it; it lists the keys and ids of uploads in progress, not object data.

What is not supported​

Only group items have a storage identity. User and role items are reported and have no effect. A policy that uses any of the following is not applied at all and is reported as an error:

  • allow exceptions or deny exceptions;
  • conditions on the policy or on an item, and validity schedules;
  • excluded resources;
  • masking and row-filter policies, and additional resource sets;
  • unknown access types, malformed resources, and macros such as {USER} in a path.

Policies of a tag service linked to the ilum-objectstore service are not applied either; the run reports them as an error.

policy-sync validate --config config.yaml --policies <exported answer> reports these without contacting Ranger or RGW.

Safety​

  • policy-sync changes only policies whose name starts with compile.managedPrefix. Other inline policies of bound principals are reported as unmanaged and left alone.
  • A run that cannot read Ranger or an account changes nothing.
  • An empty answer from Ranger is refused unless safety.allowEmptySource is set: it usually means a broken source rather than an intent to revoke every grant. The same applies when no policy compiles to a document (for example, all are unsupported) and the run would delete every managed policy.
  • A run that would remove more statements than safety.maxRemovedStatements (50) is refused. After reviewing the plan, add --force A extraArgs for one run.
  • A run that would replace or delete a managed policy it cannot read is refused until it is reviewed and run with --force.
  • A document over compile.maxDocumentBytes (256 KiB) is not written; the stored one stays and the run reports an error.
  • Unknown keys in the configuration are rejected, so a misspelt option never falls back to a default.
  • Changes made by hand to a managed policy are drift: the next run reports and reverts them.

Monitoraggio​

Each run prints a run record with the policy-set version read, the findings, the planned changes and what was applied. The exit code is 0 when the run succeeded, 1 on a Ranger, RGW or apply failure, 2 on an invalid configuration, 3 when drift found differences and 4 when a safety rule refused the run.

Con metrics.pushgatewayUrl set, every run pushes:

MetricMeaning
policy_sync_last_run_timestamp_secondsEnd of the last run, successful or not
policy_sync_last_success_timestamp_secondsEnd of the last run that read Ranger and every account; alert on its age
policy_sync_last_run_failed1 when the last run failed or was refused
policy_sync_errorsErrors of the last run
policy_sync_unsupported_policiesPolicies or documents not applied in the last run
policy_sync_warningsWarnings of the last run, such as a user item or a group without a principal
policy_sync_drift_documents{change}Documents the last run created, updated or deleted (or would have, in plan mode)
policy_sync_unmanaged_policiesPolicies of bound principals without the managed prefix
policy_sync_source_versionPolicy-set version the last run read

Changes in RGW and how to undo them​

policy-sync changes no RGW configuration. It writes and deletes inline IAM policies of the bound groups and users, and provision creates users, groups, memberships, buckets and the TLS guard statement (ilumPolicySyncRequireTls) in bucket policies.

  • To stop all changes, set suspend: true o mode: plan.
  • To remove every grant policy-sync wrote, delete the inline policies whose name starts with the managed prefix, or run apply --allow-empty-source --force against an empty service.
  • To remove the TLS guard, set requireTls: false for the bucket and run provision again; other statements of the bucket policy are kept.

Risoluzione dei problemi​

  • group/<name> does not exist in target <account>: the principal bound in targets[].principals is missing in the account. Create it with provision.
  • Ranger answers 403: the download user is not in the service's policy.download.auth.users. Run bootstrap con --download-user.
  • AccessDenied with an empty message in aws-cli: RGW sends an empty <Message> on denial, which some aws-cli 2.x versions fail to parse. The denial itself is correct.