Running the real Ranger plugin without Ranger Admin
Apache Ranger Admin is a fine piece of software and a terrible neighbour on a laptop. It wants a database, a Solr for audit, and about two gigabytes of heap, and the proof of concept I was building already had Trino, a Kyuubi server, three Spark engines, a catalog, Postgres and an object store sharing 7.5 GB of Docker memory (repository).
The requirement was clear: enforce the role model on the Kyuubi path with the Kyuubi Spark AuthZ plugin and Ranger "if it runs locally, otherwise a clearly labelled simulation plus the exact production configuration". So the question became: what, exactly, does the plugin need from Ranger Admin?
What the plugin actually asks of Ranger Admin
The Kyuubi Spark AuthZ extension bundles the Ranger plugin classes in a shaded jar. At engine start, RangerBasePlugin.init creates a PolicyRefresher thread that polls Ranger Admin. Reading the plugin's logs and the Ranger client code, the calls are few:
GET /service/plugins/policies/download/{serviceName}?lastKnownVersion=N&...— the full policy set for a service, or304 Not Modifiedwhen the version has not changed;GET /service/roles/download/{serviceName}— Ranger roles, which I do not use;GET /service/tags/download/...and user-store downloads, only if tag policies or user-store enrichers are enabled;POST /service/plugins/plugins/info— the plugin reporting its own status.
Everything else, the UI, usersync, audit storage, lives on the Admin side. The policy JSON the plugin consumes is Ranger's ServicePolicies document: a service name, a version, a list of policies (access, masking, row filter) and the service definition that tells the engine what resources (database, table, column) and access types exist.
A 120-line stub and one date format Jackson refuses
The stub is a Python http.server that answers those endpoints. It reads two files on every poll, so edits to policies.json are live within the poll interval: the policy list, in Ranger's own JSON model, and the Hive service definition, which I took from Kyuubi's own test resources (the plugin authorizes Spark SQL against Hive-type policies). It fills in the fields a real Admin would (ids, GUIDs, isEnabled, policyType) so the policies file stays readable, and returns 304 when lastKnownVersion matches so the engine logs look like a healthy deployment rather than a flood of downloads.
The one real obstacle was a date. The service definition exported by the Ranger UI carries timestamps like 20190401-20:14:36.000-+0800. The shaded Jackson inside the Kyuubi jar does not accept that format and the whole document failed to deserialize, which the plugin reported as "will continue to use last known version of policies (-1)" and then enforced nothing, because version -1 has zero policies. The stub now strips createTime and updateTime recursively; they carry no authorization meaning. That failure mode, by the way, is worth remembering on its own: a Ranger plugin that cannot parse its policies does not fail closed.
Two more things the logs taught me. The policy cache file is named sparkSql_<serviceName>.json, which tells you the plugin's service type string even though the service definition is Hive's. And kyuubi.session.user.sign.enabled=true breaks engine bootstrap with the AuthZ extension loaded, because the engine's initialisation SQL runs before any signed session exists.
What is real and what is simulated, in writing
This is the part that matters for anyone reading the proof of concept later. Real: the shaded kyuubi-spark-authz jar, the Ranger policy engine, column masking (MASK_SHOW_LAST_4, MASK_HASH, MASK_DATE_SHOW_YEAR), row filters, the Hive service definition, the policy JSON model, group resolution through Hadoop's UserGroupInformation, and the policy cache. Simulated: the Admin server and its UI, usersync, and audit storage (audit is switched off in ranger-spark-audit.xml with the Solr settings documented next to it).
The compose service is called ranger-admin-stub, the script's docstring says SIMULATION in capitals, the README table says it, and the architecture diagram draws it with a dashed border. If a reviewer could mistake it for Ranger Admin, I had failed the requirement.
Switching to production is one URL
The engine-side configuration is already the production one. ranger-spark-security.xml names the service lakehouse_hive, the cache directory and the poll interval; the only value that changes is ranger.plugin.spark.policy.rest.url, from http://ranger-admin-stub:6080 to the real Admin's HTTPS address. The policies import into Ranger Admin through its public API as a Hive-type service with the same name. Then you delete the stub service from the deployment, turn audit on, and point group mapping at LDAP instead of a static file.
I would still not use the stub beyond a POC. It has no authentication, it does not model roles or tags, and it is a place where someone could, one day, edit a JSON file instead of going through Ranger's approval flow. Its job was to let the real plugin run on a laptop and to make the production path a configuration change rather than a rewrite.
What I took from it
- Before simulating a dependency, read what the client actually calls. The Ranger plugin needs four endpoints, not a product.
- Simulate the server, never the enforcement. The value of the POC is that the masks and filters are the real code paths.
- A plugin that cannot load its policies may enforce nothing. Alert on
PolicyRefresherfailures in production; it is the most dangerous silent state in the stack. - Label simulations in every artefact a reader could reach: service name, docstring, README, diagram.