You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by ab...@apache.org on 2026/09/16 16:04:02 UTC

(ranger-tools) 01/01: RANGER-5732: add release Docker image for Ranger PDP

This is an automated email from the ASF dual-hosted git repository.

kumaab pushed a commit to branch ranger_5732
in repository https://gitbox.apache.org/repos/asf/ranger-tools.git

commit e3311cd94fa6af90fb8fbb583686028cc3a371fa
Author: Abhishek Kumar <ab...@apache.org>
AuthorDate: Wed Sep 16 08:00:46 2026 -0700

    RANGER-5732: add release Docker image for Ranger PDP
    
    Adds release/Dockerfile.ranger-pdp so the PDP can be published alongside
    ranger, ranger-db and ranger-solr by build-and-tag-ranger-image.yaml, which
    now builds, pushes and tags ranger-pdp as well.
    
    The image downloads the released ranger-<version>-pdp.tar.gz from the
    Apache mirrors, GPG-verifies and unpacks it in a single layer so the
    tarballs don't remain in the image. download-ranger.sh is parameterised by
    RANGER_SERVICE (default: admin) to fetch it.
    
    Configuration needs no compose file. On every start, render-pdp-site.py
    renders ranger-pdp-site.xml from the YAML at RANGER_PDP_SITE_YAML. By
    default that is the image's ranger-pdp-site-defaults.yaml, whose values
    reference environment variables as ${VAR:-default}; a user-supplied YAML
    (e.g. from a Kubernetes ConfigMap) replaces it entirely. A mounted
    ranger-pdp-site.xml is used as-is. python3-yaml is installed from the
    Ubuntu archive for the renderer.
    
    The PDP refuses to start without a usable inbound authentication handler,
    so the image always enables header-based authn (X-Forwarded-User by
    default), and the entrypoint fails fast with an actionable message when
    the effective config leaves no handler usable.
    
    release/README.md gains PDP build and run commands; usage and
    configuration details are in release/README-pdp.md.
---
 .github/workflows/build-and-tag-ranger-image.yaml |  11 +-
 release/.dockerignore                             |   4 +-
 release/Dockerfile.ranger-pdp                     |  64 ++++++++
 release/README-pdp.md                             | 119 +++++++++++++++
 release/README.md                                 |  13 +-
 release/scripts/download-ranger.sh                |   3 +-
 release/scripts/pdp/ranger-pdp-site-defaults.yaml |  76 ++++++++++
 release/scripts/pdp/ranger-pdp.sh                 | 146 ++++++++++++++++++
 release/scripts/pdp/render-pdp-site.py            | 177 ++++++++++++++++++++++
 9 files changed, 607 insertions(+), 6 deletions(-)

diff --git a/.github/workflows/build-and-tag-ranger-image.yaml b/.github/workflows/build-and-tag-ranger-image.yaml
index 2c59049..e1ed3d3 100644
--- a/.github/workflows/build-and-tag-ranger-image.yaml
+++ b/.github/workflows/build-and-tag-ranger-image.yaml
@@ -15,7 +15,7 @@
 
 name: build-and-tag-ranger-image
 
-# This workflow builds the following images: ranger, ranger-db, ranger-solr.
+# This workflow builds the following images: ranger, ranger-pdp, ranger-db, ranger-solr.
 # It also pushes the image to the GitHub Container Registry, tagging it based on the ranger version present in the release branch.
 # It pushes the images to DockerHub if an OAuth token is provided as input.
 
@@ -73,6 +73,12 @@ jobs:
             --platform linux/amd64,linux/arm64 \
             --tag ghcr.io/${{ github.repository_owner }}/ranger:${RANGER_VERSION} \
             --push .
+          docker buildx build \
+            --build-arg RANGER_VERSION=${RANGER_VERSION} \
+            --file Dockerfile.ranger-pdp \
+            --platform linux/amd64,linux/arm64 \
+            --tag ghcr.io/${{ github.repository_owner }}/ranger-pdp:${RANGER_VERSION} \
+            --push .
           docker buildx build \
             --file Dockerfile.ranger-postgres \
             --platform linux/amd64,linux/arm64 \
@@ -120,6 +126,7 @@ jobs:
       - name: Pull image
         run: |
           docker pull ghcr.io/${{ github.repository_owner }}/ranger:${RANGER_VERSION}
+          docker pull ghcr.io/${{ github.repository_owner }}/ranger-pdp:${RANGER_VERSION}
           docker pull ghcr.io/${{ github.repository_owner }}/ranger-db:${RANGER_VERSION}
           docker pull ghcr.io/${{ github.repository_owner }}/ranger-solr:${RANGER_VERSION}
 
@@ -141,7 +148,7 @@ jobs:
         run: |
           set -x
           for registry in $REGISTRIES; do
-            for service in ranger ranger-db ranger-solr; do
+            for service in ranger ranger-pdp ranger-db ranger-solr; do
               opts="$(echo "$RANGER_VERSION" | sed "s@^@--tag $registry/${{ github.repository_owner }}/$service:@g" | xargs echo)"
               if [[ -n "$opts" ]]; then
                 docker buildx imagetools create $opts ghcr.io/${{ github.repository_owner }}/$service:${RANGER_VERSION}
diff --git a/release/.dockerignore b/release/.dockerignore
index b423db3..632186c 100644
--- a/release/.dockerignore
+++ b/release/.dockerignore
@@ -1,4 +1,4 @@
 *
 !config
-!downloads/*
-!scripts/*
+!downloads/**
+!scripts/**
diff --git a/release/Dockerfile.ranger-pdp b/release/Dockerfile.ranger-pdp
new file mode 100644
index 0000000..f9ab782
--- /dev/null
+++ b/release/Dockerfile.ranger-pdp
@@ -0,0 +1,64 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+ARG RANGER_BASE_IMAGE=apache/ranger-base
+ARG RANGER_BASE_VERSION=20260806-2-8
+
+FROM ${RANGER_BASE_IMAGE}:${RANGER_BASE_VERSION} AS ranger-pdp
+
+ARG RANGER_VERSION
+
+# picked up by download-ranger.sh to fetch ranger-${RANGER_VERSION}-pdp.tar.gz
+ENV RANGER_SERVICE=pdp
+
+ENV RANGER_PDP_HOME=${RANGER_HOME}/pdp
+ENV RANGER_PDP_PORT=6500
+ENV RANGER_PDP_LOG_DIR=/var/log/ranger/pdp
+ENV RANGER_PDP_POLICY_CACHE_DIR=/var/ranger/cache/pdp
+
+# python3-yaml backs render-pdp-site.py; it is a system package, so the script runs on /usr/bin/python3
+RUN    apt-get update -q \
+    && DEBIAN_FRONTEND="noninteractive" apt-get install -y -q --no-install-recommends python3-yaml \
+    && apt-get clean \
+    && rm -rf /var/lib/apt/lists/*
+
+COPY ./scripts/download-ranger.sh                  ${RANGER_SCRIPTS}/
+COPY ./scripts/pdp/ranger-pdp.sh                   ${RANGER_SCRIPTS}/
+COPY ./scripts/pdp/render-pdp-site.py              ${RANGER_SCRIPTS}/
+COPY ./scripts/pdp/ranger-pdp-site-defaults.yaml   ${RANGER_SCRIPTS}/
+
+# Download, GPG-verify and unpack the released ranger-pdp.tar.gz in a single layer
+WORKDIR /home/ranger
+RUN    chmod +x ${RANGER_SCRIPTS}/download-ranger.sh \
+    && ${RANGER_SCRIPTS}/download-ranger.sh \
+    && tar xfz ${RANGER_DIST}/ranger-${RANGER_VERSION}-pdp.tar.gz --directory=${RANGER_HOME} \
+    && ln -s ${RANGER_HOME}/ranger-${RANGER_VERSION}-pdp ${RANGER_PDP_HOME} \
+    && rm -rf ${RANGER_DIST}/* \
+    && mkdir -p ${RANGER_PDP_LOG_DIR} ${RANGER_PDP_POLICY_CACHE_DIR} /var/run/ranger \
+    && ln -s ${RANGER_PDP_HOME}/ranger-pdp-services.sh /usr/bin/ranger-pdp-services.sh \
+    && chown -R ranger:ranger ${RANGER_HOME}/ranger-${RANGER_VERSION}-pdp ${RANGER_SCRIPTS}/ \
+                              /var/log/ranger /var/ranger /var/run/ranger \
+    && chmod 755 ${RANGER_SCRIPTS}/ranger-pdp.sh ${RANGER_SCRIPTS}/render-pdp-site.py
+WORKDIR /
+
+EXPOSE 6500
+
+HEALTHCHECK --interval=20s --timeout=10s --start-period=30s --retries=20 \
+    CMD /bin/bash -c 'scheme=http; [ "${RANGER_PDP_SSL_ENABLED:-false}" = "true" ] && scheme=https; curl -fsSk "${scheme}://localhost:${RANGER_PDP_PORT}/health/ready" >/dev/null'
+
+USER ranger
+
+ENTRYPOINT [ "/home/ranger/scripts/ranger-pdp.sh" ]
diff --git a/release/README-pdp.md b/release/README-pdp.md
new file mode 100644
index 0000000..b8e76d2
--- /dev/null
+++ b/release/README-pdp.md
@@ -0,0 +1,119 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+# Apache Ranger PDP Image
+
+Ranger PDP is a standalone policy decision point. It downloads policies from Ranger Admin and
+answers authorization requests over REST on port 6500.
+
+## Build
+
+Run from the `release` directory:
+
+```bash
+export RANGER_VERSION=2.9.0
+docker build --build-arg RANGER_VERSION=${RANGER_VERSION} -f Dockerfile.ranger-pdp -t ranger-pdp:latest .
+```
+
+## Run
+
+With Ranger Admin running as described in [README.md](README.md):
+
+```bash
+docker run -d \
+  -e RANGER_ADMIN_URL=http://ranger-admin.rangernw:6080 \
+  -e RANGER_ADMIN_PASSWORD=rangerR0cks! \
+  -e RANGER_PDP_DELEGATION_USERS=ranger \
+  --name ranger-pdp --hostname ranger-pdp.rangernw --network rangernw -p 6500:6500 ranger-pdp:latest
+```
+
+## Try It
+
+Check that the PDP is ready:
+
+```bash
+curl -s http://localhost:6500/health/ready
+```
+
+Ask for a decision. The `X-Forwarded-User` header identifies the caller; requests without it are rejected with `401`:
+
+```bash
+curl -s -X POST http://localhost:6500/authz/v1/authorize \
+  -H 'Content-Type: application/json' \
+  -H 'X-Forwarded-User: ranger' \
+  -d '{"requestId":"req-1",
+       "user":{"name":"analyst"},
+       "access":{"resource":{"name":"column:db1/tbl1/col1"},"permissions":["select"]},
+       "context":{"serviceName":"dev_hive","serviceType":"hive"}}'
+```
+
+A resource is named `<resourceType>:<value>`, where the value follows the service's resource
+hierarchy (`database/table/column` for hive). A caller may ask about *another* user only when it
+is listed in `RANGER_PDP_DELEGATION_USERS`; otherwise the request is rejected with `403`.
+
+The PDP also serves `/health/live`, and Prometheus metrics at `/metrics`.
+
+## Authentication
+
+The PDP refuses to start unless at least one inbound authentication handler is usable, so
+this image always configures **header-based authentication**. By default, the username is read
+from `X-Forwarded-User`; set `RANGER_PDP_AUTHN_HEADER_USERNAME` to change it, or
+`RANGER_PDP_AUTHN_HEADER_SPIFFE` to authenticate services by SPIFFE ID instead. Header authn
+trusts its input, so run the PDP behind a proxy or mesh that sets the header and strips any
+client-supplied copy. JWT and Kerberos can be enabled alongside it.
+
+## Configuration
+
+On every start the entrypoint renders `conf/ranger-pdp-site.xml` from a YAML file whose keys are
+`ranger-pdp-site.xml` property names:
+
+- By default it uses `ranger-pdp-site-defaults.yaml`, baked into the image
+  ([source](scripts/pdp/ranger-pdp-site-defaults.yaml)). Its values reference environment variables
+  as `${VAR:-default}`, so common settings can be changed with `docker run -e`; see that file for the
+  full list.
+- To drive the configuration yourself, set `RANGER_PDP_SITE_YAML` to your own YAML file. It replaces
+  the defaults entirely: keys it leaves out take the PDP's built-in defaults, and environment
+  variables apply only where your file references them.
+
+`${VAR}` references are expanded after the YAML is parsed, so environment values are used verbatim
+(use `$$` for a literal `$`). Lists are joined with commas, and properties that end up empty are left
+out so the PDP applies its built-in default.
+
+On Kubernetes, your YAML fits naturally in a ConfigMap, with secrets injected as environment variables:
+
+```yaml
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: ranger-pdp-config
+data:
+  ranger-pdp-site.yaml: |
+    ranger.authz.default.policy.rest.url: http://ranger-admin:6080
+    ranger.authz.default.policy.rest.client.password: "${RANGER_ADMIN_PASSWORD}"
+    ranger.authz.init.services: [dev_hive, dev_hdfs]
+    ranger.pdp.authn.header.username: X-Forwarded-User
+    ranger.pdp.http.connector.maxThreads: 400
+```
+
+Mount it at a path of its own (e.g. `/etc/ranger/pdp`) and set
+`RANGER_PDP_SITE_YAML=/etc/ranger/pdp/ranger-pdp-site.yaml`; the entrypoint writes into `conf/`, so
+don't mount the ConfigMap over that directory.
+
+To manage the XML yourself, mount a complete file at `/opt/ranger/pdp/conf/ranger-pdp-site.xml`;
+YAML and environment variables are then ignored, though the entrypoint still refuses to start the
+PDP if that file leaves no authentication handler usable.
+
diff --git a/release/README.md b/release/README.md
index b75c09e..bf49360 100644
--- a/release/README.md
+++ b/release/README.md
@@ -30,6 +30,7 @@ export RANGER_VERSION=2.9.0
 docker build -f Dockerfile.ranger-postgres -t ranger-db:latest .
 docker build -f Dockerfile.ranger-solr -t ranger-solr:latest .
 docker build --build-arg RANGER_VERSION=${RANGER_VERSION} -f Dockerfile.ranger -t ranger:latest .
+docker build --build-arg RANGER_VERSION=${RANGER_VERSION} -f Dockerfile.ranger-pdp -t ranger-pdp:latest .
 ```
 
 ### Run Containers
@@ -56,7 +57,17 @@ docker run -d \
   -e RANGER_DB_USER=rangeradmin \
   -e RANGER_DB_PASSWORD=rangerR0cks! \
   --name ranger-admin --hostname ranger-admin.rangernw --network rangernw -p 6080:6080 ranger:latest
+
+docker run -d \
+  -e RANGER_ADMIN_URL=http://ranger-admin.rangernw:6080 \
+  -e RANGER_ADMIN_PASSWORD=rangerR0cks! \
+  -e RANGER_PDP_DELEGATION_USERS=ranger \
+  --name ranger-pdp --hostname ranger-pdp.rangernw --network rangernw -p 6500:6500 ranger-pdp:latest
 ```
 ### Access Ranger Admin UI
 
-Once the containers are running, you can access the Ranger Admin UI by navigating to `http://localhost:6080` in your web browser. The default credentials are: `admin/rangerR0cks!`
\ No newline at end of file
+Once the containers are running, you can access the Ranger Admin UI by navigating to `http://localhost:6080` in your web browser. The default credentials are: `admin/rangerR0cks!`
+
+### Access Ranger PDP
+
+Ranger PDP serves authorization requests at `http://localhost:6500`. See [README-pdp.md](README-pdp.md) for usage and configuration.
diff --git a/release/scripts/download-ranger.sh b/release/scripts/download-ranger.sh
index 0fa20ad..af620dc 100644
--- a/release/scripts/download-ranger.sh
+++ b/release/scripts/download-ranger.sh
@@ -20,6 +20,7 @@ set -u -o pipefail
 : ${BASE_URL:="https://www.apache.org/dyn/closer.lua?action=download&filename="}
 : ${CHECKSUM_BASE_URL:="https://downloads.apache.org/"}
 : ${RANGER_VERSION:=2.8.0}
+: ${RANGER_SERVICE:=admin}
 
 download_if_not_exists() {
   local url="$1"
@@ -50,4 +51,4 @@ mkdir -p dist
 # source
 download_and_verify "ranger/${RANGER_VERSION}/apache-ranger-${RANGER_VERSION}.tar.gz"
 # binary
-download_and_verify "ranger/${RANGER_VERSION}/services/admin/ranger-${RANGER_VERSION}-admin.tar.gz"
+download_and_verify "ranger/${RANGER_VERSION}/services/${RANGER_SERVICE}/ranger-${RANGER_VERSION}-${RANGER_SERVICE}.tar.gz"
diff --git a/release/scripts/pdp/ranger-pdp-site-defaults.yaml b/release/scripts/pdp/ranger-pdp-site-defaults.yaml
new file mode 100644
index 0000000..65d2470
--- /dev/null
+++ b/release/scripts/pdp/ranger-pdp-site-defaults.yaml
@@ -0,0 +1,76 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Default ranger-pdp-site.xml properties for the apache/ranger-pdp image.
+#
+# Keys are ranger-pdp-site.xml property names. Values may reference environment variables
+# as ${VAR} or ${VAR:-default}; they are expanded after the YAML is parsed, so env values are
+# never re-interpreted as YAML. Properties whose value ends up empty are omitted, letting the
+# PDP fall back to its built-in default. Lists are joined with commas.
+#
+# To drive the configuration yourself, point RANGER_PDP_SITE_YAML at your own file in this format;
+# it replaces this file entirely.
+
+# server
+ranger.pdp.port: "${RANGER_PDP_PORT:-6500}"
+ranger.pdp.log.dir: "${RANGER_PDP_LOG_DIR:-/var/log/ranger/pdp}"
+ranger.pdp.http2.enabled: "${RANGER_PDP_HTTP2_ENABLED:-true}"
+
+# inbound authentication; header authn is always enabled by this image.
+# when neither username nor spiffe header is given, the username header defaults to X-Forwarded-User
+ranger.pdp.authn.types: "${RANGER_PDP_AUTHN_TYPES:-header}"
+ranger.pdp.authn.header.enabled: true
+ranger.pdp.authn.header.username: "${RANGER_PDP_AUTHN_HEADER_USERNAME:-}"
+ranger.pdp.authn.header.spiffe: "${RANGER_PDP_AUTHN_HEADER_SPIFFE:-}"
+
+ranger.pdp.authn.jwt.enabled: "${RANGER_PDP_AUTHN_JWT_ENABLED:-false}"
+ranger.pdp.authn.jwt.provider.url: "${RANGER_PDP_AUTHN_JWT_PROVIDER_URL:-}"
+ranger.pdp.authn.jwt.public.key: "${RANGER_PDP_AUTHN_JWT_PUBLIC_KEY:-}"
+ranger.pdp.authn.jwt.audiences: "${RANGER_PDP_AUTHN_JWT_AUDIENCES:-}"
+
+ranger.pdp.authn.kerberos.enabled: "${RANGER_PDP_AUTHN_KERBEROS_ENABLED:-false}"
+ranger.pdp.authn.kerberos.spnego.principal: "${RANGER_PDP_AUTHN_KERBEROS_SPNEGO_PRINCIPAL:-}"
+ranger.pdp.authn.kerberos.spnego.keytab: "${RANGER_PDP_AUTHN_KERBEROS_SPNEGO_KEYTAB:-}"
+ranger.pdp.authn.kerberos.name.rules: "${RANGER_PDP_AUTHN_KERBEROS_NAME_RULES:-DEFAULT}"
+
+# TLS for the PDP listener
+ranger.pdp.ssl.enabled: "${RANGER_PDP_SSL_ENABLED:-false}"
+ranger.pdp.ssl.keystore.file: "${RANGER_PDP_SSL_KEYSTORE_FILE:-}"
+ranger.pdp.ssl.keystore.password: "${RANGER_PDP_SSL_KEYSTORE_PASSWORD:-}"
+ranger.pdp.ssl.keystore.type: "${RANGER_PDP_SSL_KEYSTORE_TYPE:-JKS}"
+ranger.pdp.ssl.truststore.enabled: "${RANGER_PDP_SSL_TRUSTSTORE_ENABLED:-false}"
+ranger.pdp.ssl.truststore.file: "${RANGER_PDP_SSL_TRUSTSTORE_FILE:-}"
+ranger.pdp.ssl.truststore.password: "${RANGER_PDP_SSL_TRUSTSTORE_PASSWORD:-}"
+ranger.pdp.ssl.truststore.type: "${RANGER_PDP_SSL_TRUSTSTORE_TYPE:-JKS}"
+
+# users allowed to request decisions on behalf of other users, in all services
+"ranger.pdp.service.*.delegation.users": "${RANGER_PDP_DELEGATION_USERS:-}"
+
+# connection to Ranger Admin
+ranger.authz.app.type: ranger-pdp
+ranger.authz.init.services: "${RANGER_PDP_INIT_SERVICES:-}"
+ranger.authz.default.policy.rest.url: "${RANGER_ADMIN_URL:-http://ranger-admin.rangernw:6080}"
+ranger.authz.default.policy.rest.client.username: "${RANGER_ADMIN_USER:-admin}"
+ranger.authz.default.policy.rest.client.password: "${RANGER_ADMIN_PASSWORD:-}"
+ranger.authz.default.policy.pollIntervalMs: "${RANGER_PDP_POLICY_POLL_INTERVAL_MS:-30000}"
+ranger.authz.default.policy.cache.dir: "${RANGER_PDP_POLICY_CACHE_DIR:-/var/ranger/cache/pdp}"
+
+# audit
+ranger.authz.audit.is.enabled: "${RANGER_PDP_AUDIT_ENABLED:-true}"
+ranger.authz.audit.destination.auditserver: "${RANGER_PDP_AUDIT_SERVER_ENABLED:-false}"
+ranger.authz.audit.destination.auditserver.url: "${RANGER_PDP_AUDIT_SERVER_URL:-}"
+ranger.authz.audit.destination.solr: "${RANGER_PDP_AUDIT_SOLR_ENABLED:-false}"
+ranger.authz.audit.destination.solr.urls: "${RANGER_PDP_AUDIT_SOLR_URLS:-}"
diff --git a/release/scripts/pdp/ranger-pdp.sh b/release/scripts/pdp/ranger-pdp.sh
new file mode 100755
index 0000000..ea1aa36
--- /dev/null
+++ b/release/scripts/pdp/ranger-pdp.sh
@@ -0,0 +1,146 @@
+#!/usr/bin/env bash
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Entrypoint for the apache/ranger-pdp image. Renders conf/ranger-pdp-site.xml from
+# RANGER_PDP_SITE_YAML (default: the image's ranger-pdp-site-defaults.yaml), verifies at least
+# one authentication handler is usable, and runs the PDP server in the foreground.
+
+set -euo pipefail
+
+RANGER_PDP_HOME=${RANGER_PDP_HOME:-${RANGER_HOME}/pdp}
+RANGER_PDP_CONF_DIR=${RANGER_PDP_CONF_DIR:-${RANGER_PDP_HOME}/conf}
+RANGER_PDP_LOG_DIR=${RANGER_PDP_LOG_DIR:-/var/log/ranger/pdp}
+RANGER_PDP_SITE_YAML=${RANGER_PDP_SITE_YAML:-${RANGER_SCRIPTS}/ranger-pdp-site-defaults.yaml}
+
+PDP_SITE_XML=${RANGER_PDP_CONF_DIR}/ranger-pdp-site.xml
+PDP_LOGBACK_XML=${RANGER_PDP_CONF_DIR}/logback.xml
+
+# must match GENERATED_MARKER in render-pdp-site.py
+GENERATED_MARKER='generated by ranger-pdp.sh from YAML'
+
+export RANGER_PDP_CONF_DIR RANGER_PDP_LOG_DIR
+
+log()  { echo "ranger-pdp: $*"; }
+warn() { echo "ranger-pdp: WARN: $*" >&2; }
+die()  { echo "ranger-pdp: ERROR: $*" >&2; exit 1; }
+
+lower() { printf '%s' "${1-}" | tr '[:upper:]' '[:lower:]'; }
+
+is_true() { [ "$(lower "${1-}")" = "true" ]; }
+
+trim() { printf '%s' "${1-}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'; }
+
+xml_value() {
+    xmlstarlet sel -t -v "/configuration/property[name='$1']/value" -n "${PDP_SITE_XML}" 2>/dev/null | head -1
+}
+
+# ranger-pdp ships an empty conf/; seed logback from conf.dist unless one is mounted
+seed_conf_dir() {
+    mkdir -p "${RANGER_PDP_CONF_DIR}" "${RANGER_PDP_LOG_DIR}"
+
+    if [ ! -f "${PDP_LOGBACK_XML}" ] && ! cp "${RANGER_PDP_HOME}/conf.dist/logback.xml" "${PDP_LOGBACK_XML}" 2>/dev/null; then
+        warn "unable to seed ${PDP_LOGBACK_XML}; logback will fall back to its own defaults"
+    fi
+}
+
+# a file we rendered on a previous start is regenerated, so edits to the YAML take effect on restart
+is_user_site_xml() {
+    [ -f "${PDP_SITE_XML}" ] && ! grep -q "${GENERATED_MARKER}" "${PDP_SITE_XML}"
+}
+
+create_cache_dir() {
+    local cache_dir
+
+    cache_dir=$(xml_value ranger.authz.default.policy.cache.dir)
+
+    if [ -n "${cache_dir}" ] && ! mkdir -p "${cache_dir}" 2>/dev/null; then
+        warn "unable to create policy cache dir ${cache_dir}; mount it as a writable volume"
+    fi
+}
+
+# mirrors RangerPdpAuthNFilter.createHandler(): a handler counts only when listed in
+# ranger.pdp.authn.types, enabled, and configured. No usable handler => PDP fails to start.
+verify_authn() {
+    local types usable=() type
+
+    types=$(xml_value ranger.pdp.authn.types)
+    types=${types:-header,jwt,kerberos}
+
+    while IFS= read -r type; do
+        type=$(trim "$(lower "${type}")")
+
+        case "${type}" in
+            header)
+                if is_true "$(xml_value ranger.pdp.authn.header.enabled)" &&
+                   { [ -n "$(xml_value ranger.pdp.authn.header.username)" ] ||
+                     [ -n "$(xml_value ranger.pdp.authn.header.spiffe)" ]; }; then
+                    usable+=(header)
+                fi
+                ;;
+            jwt)
+                if is_true "$(xml_value ranger.pdp.authn.jwt.enabled)"; then
+                    usable+=(jwt)
+                fi
+                ;;
+            kerberos)
+                if is_true "$(xml_value ranger.pdp.authn.kerberos.enabled)"; then
+                    usable+=(kerberos)
+                fi
+                ;;
+            '') ;;
+            *) warn "unknown authentication type '${type}' in ranger.pdp.authn.types" ;;
+        esac
+    done < <(printf '%s\n' "${types}" | tr ',' '\n')
+
+    if [ ${#usable[@]} -eq 0 ]; then
+        die "no usable authentication handler in ${PDP_SITE_XML}; the PDP will not start. Enable header authn by setting ranger.pdp.authn.types to include 'header', ranger.pdp.authn.header.enabled=true and ranger.pdp.authn.header.username (or .spiffe)"
+    fi
+
+    log "authentication handlers: ${usable[*]}"
+}
+
+seed_conf_dir
+
+if is_user_site_xml; then
+    log "using mounted ${PDP_SITE_XML}; YAML and environment variables are ignored"
+else
+    /usr/bin/python3 "${RANGER_SCRIPTS}/render-pdp-site.py" \
+        --input  "${RANGER_PDP_SITE_YAML}" \
+        --output "${PDP_SITE_XML}" || die "failed to render ${PDP_SITE_XML}"
+fi
+
+verify_authn
+create_cache_dir
+
+admin_url=$(xml_value ranger.authz.default.policy.rest.url)
+
+if [ -z "${admin_url}" ]; then
+    warn "ranger.authz.default.policy.rest.url is not set; the PDP will use its built-in default Ranger Admin URL"
+fi
+
+if [ -z "$(xml_value ranger.authz.default.policy.rest.client.password)" ]; then
+    warn "no Ranger Admin password configured; policy download from ${admin_url:-Ranger Admin} will likely fail"
+fi
+
+pdp_port=$(xml_value ranger.pdp.port)
+
+log "starting Ranger PDP on port ${pdp_port:-6500}"
+
+cd "${RANGER_PDP_HOME}" || die "${RANGER_PDP_HOME} not found"
+
+exec ./ranger-pdp-services.sh run
diff --git a/release/scripts/pdp/render-pdp-site.py b/release/scripts/pdp/render-pdp-site.py
new file mode 100755
index 0000000..15d62d8
--- /dev/null
+++ b/release/scripts/pdp/render-pdp-site.py
@@ -0,0 +1,177 @@
+#!/usr/bin/python3
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Renders ranger-pdp-site.xml from a YAML file of property names and values, expanding
+# ${VAR} / ${VAR:-default} references from the environment.
+
+import argparse
+import os
+import re
+import sys
+
+from xml.sax.saxutils import escape
+
+import yaml
+
+GENERATED_MARKER = 'generated by ranger-pdp.sh from YAML'
+
+DEFAULT_HEADER_USERNAME = 'X-Forwarded-User'
+
+ENV_REF = re.compile(r'\$\$|\$\{([A-Za-z_][A-Za-z0-9_]*)(?::-([^}]*))?\}')
+
+
+def log(msg):
+    print(f'ranger-pdp: {msg}', file=sys.stderr)
+
+
+def die(msg):
+    log(f'ERROR: {msg}')
+    sys.exit(1)
+
+
+def load_yaml(path):
+    try:
+        with open(path) as f:
+            data = yaml.safe_load(f)
+    except (OSError, yaml.YAMLError) as e:
+        die(f'unable to read {path}: {e}')
+
+    if data is None:
+        return {}
+
+    if not isinstance(data, dict):
+        die(f'{path}: expected a mapping of property name to value')
+
+    for name, value in data.items():
+        if not isinstance(name, str):
+            die(f'{path}: property name {name!r} must be a string')
+
+        if isinstance(value, dict):
+            die(f'{path}: {name}: nested mappings are not supported; use the full property name as the key')
+
+    return data
+
+
+def expand_env(value):
+    # $$ escapes a literal $; like bash, ${VAR:-default} also applies the default when VAR is empty
+    def replace(m):
+        if m.group(0) == '$$':
+            return '$'
+
+        env_value = os.environ.get(m.group(1), '')
+
+        return env_value if env_value or m.group(2) is None else m.group(2)
+
+    return ENV_REF.sub(replace, value)
+
+
+def to_property_value(value):
+    if value is None:
+        return None
+
+    if isinstance(value, bool):
+        return 'true' if value else 'false'
+
+    if isinstance(value, list):
+        return ','.join(v for v in (to_property_value(item) for item in value) if v)
+
+    return expand_env(str(value)).strip()
+
+
+def enforce_header_authn(props):
+    # the PDP refuses to start without a usable authn handler; header authn is this image's baseline
+    # an absent key is expected in a user-supplied YAML; only a conflicting value deserves a warning
+    header_enabled = props.get('ranger.pdp.authn.header.enabled')
+
+    if header_enabled is None:
+        log('header authn is required by this image; setting ranger.pdp.authn.header.enabled=true')
+    elif header_enabled.lower() != 'true':
+        log(f"WARN: ranger.pdp.authn.header.enabled was '{header_enabled}'; enabling it since this image requires header authn")
+
+    props['ranger.pdp.authn.header.enabled'] = 'true'
+
+    if not props.get('ranger.pdp.authn.header.username') and not props.get('ranger.pdp.authn.header.spiffe'):
+        log(f'no header authn header name given; using ranger.pdp.authn.header.username={DEFAULT_HEADER_USERNAME}')
+
+        props['ranger.pdp.authn.header.username'] = DEFAULT_HEADER_USERNAME
+
+    configured_types = props.get('ranger.pdp.authn.types')
+    types            = []
+
+    for authn_type in (configured_types or '').split(','):
+        authn_type = authn_type.strip().lower()
+
+        if authn_type and authn_type not in types:
+            types.append(authn_type)
+
+    if 'header' not in types:
+        if configured_types is None:
+            log('setting ranger.pdp.authn.types=header')
+        else:
+            log(f"WARN: ranger.pdp.authn.types '{configured_types}' did not include 'header'; adding it since this image requires header authn")
+
+        types.insert(0, 'header')
+
+    props['ranger.pdp.authn.types'] = ','.join(types)
+
+
+def write_site_xml(props, path):
+    lines = [
+        '<?xml version="1.0" encoding="UTF-8"?>',
+        f'<!-- {GENERATED_MARKER}; regenerated on every start. Mount your own file to take over -->',
+        '<configuration>',
+    ]
+
+    for name, value in props.items():
+        lines += [
+            '  <property>',
+            f'    <name>{escape(name)}</name>',
+            f'    <value>{escape(value)}</value>',
+            '  </property>',
+        ]
+
+    lines.append('</configuration>')
+
+    with open(path, 'w') as f:
+        f.write('\n'.join(lines) + '\n')
+
+
+def main():
+    parser = argparse.ArgumentParser(description=__doc__)
+    parser.add_argument('--input', required=True, help='YAML file of ranger-pdp-site.xml properties')
+    parser.add_argument('--output', required=True, help='ranger-pdp-site.xml to write')
+    args = parser.parse_args()
+
+    log(f'rendering from {args.input}')
+
+    props = {}
+
+    for name, value in load_yaml(args.input).items():
+        value = to_property_value(value)
+
+        if value:
+            props[name] = value
+
+    enforce_header_authn(props)
+    write_site_xml(props, args.output)
+
+    log(f'generated {args.output}')
+
+
+if __name__ == '__main__':
+    main()