Skip to content

feat: OPA authorizer for Airflow 3 #1127

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

Merged
merged 27 commits into from
May 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ All notable changes to this project will be documented in this file.
- hbase: add 2.6.2 and upgrade dependencies ([#1101])
- kafka: Add `4.0.0` ([#1117])
- Include `.tar.gz` snapshots of the product source code in container images ([#1126])
- airflow: OPA authorizer for Airflow 3.x ([#1127])

### Changed

Expand Down Expand Up @@ -147,6 +148,7 @@ All notable changes to this project will be documented in this file.
[#1124]: https://github.com/stackabletech/docker-images/pull/1124
[#1125]: https://github.com/stackabletech/docker-images/pull/1125
[#1126]: https://github.com/stackabletech/docker-images/pull/1126
[#1127]: https://github.com/stackabletech/docker-images/pull/1127
[#1128]: https://github.com/stackabletech/docker-images/pull/1128

## [25.3.0] - 2025-03-21
Expand Down
29 changes: 22 additions & 7 deletions airflow/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# syntax=docker/dockerfile:1.15.1@sha256:9857836c9ee4268391bb5b09f9f157f3c91bb15821bb77969642813b0d00518d
# check=error=true;skip=InvalidDefaultArgInFrom
# Disabled error checks:
# - SecretsUsedInArgOrEnv : OPA_AUTH_MANAGER is a false positive and breaks the build.
# check=error=true;skip=InvalidDefaultArgInFrom,SecretsUsedInArgOrEnv

ARG GIT_SYNC

Expand All @@ -9,17 +11,30 @@ FROM oci.stackable.tech/sdp/git-sync/git-sync:${GIT_SYNC} AS gitsync-image

FROM stackable/image/shared/statsd-exporter AS statsd_exporter-builder

FROM python:3.12-bookworm AS opa-auth-manager-builder
FROM stackable/image/vector AS opa-auth-manager-builder

COPY airflow/opa-auth-manager/ /tmp/opa-auth-manager
ARG OPA_AUTH_MANAGER
ARG PYTHON
ARG UV

COPY airflow/opa-auth-manager/${OPA_AUTH_MANAGER} /tmp/opa-auth-manager

WORKDIR /tmp/opa-auth-manager

RUN <<EOF
pip install --no-cache-dir poetry
poetry build
poetry install
poetry run pytest
microdnf update
microdnf install python${PYTHON}-pip
microdnf clean all

pip${PYTHON} install --no-cache-dir uv==${UV}

# This folder is required by the tests to set up an sqlite database
mkdir /root/airflow

# Warnings are disabled because they come from various third party testing libraries
# that we have no control over.
uv run pytest --disable-warnings
uv build
EOF

FROM stackable/image/vector AS airflow-build-image
Expand Down
12 changes: 0 additions & 12 deletions airflow/opa-auth-manager/README.md

This file was deleted.

12 changes: 12 additions & 0 deletions airflow/opa-auth-manager/airflow-2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Airflow 2 OPA auth manager

Auth manager for Airflow 2 which delegates the authorization to an Open Policy
Agent

[uv](https://docs.astral.sh/uv/) is used to build the project:

uv build

The unit tests can be run as follows:

uv run pytest
27 changes: 27 additions & 0 deletions airflow/opa-auth-manager/airflow-2/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[project]
name = "opa-auth-manager"
version = "0.1.0"
description = "Auth manager for Airflow which delegates the authorization to an Open Policy Agent"
authors = [
{ name = "Siegfried Weber", email="[email protected]"},
{ name = "Razvan Daniel Mihai", email="[email protected]"}
]
readme = "README.md"
requires-python = ">=3.9,<3.13"

dependencies = [
"requests~=2.32.3",
"cachetools~=5.5.0",
"overrides~=7.7.0"
]

[dependency-groups]
dev = [
"apache-airflow~=2.9.3",
"pylint~=3.3.1",
"pytest~=8.3.3"
]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
2 changes: 2 additions & 0 deletions airflow/opa-auth-manager/airflow-3/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.pytest_cache/
dist/
15 changes: 15 additions & 0 deletions airflow/opa-auth-manager/airflow-3/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Airflow 3 OPA auth manager

Auth manager for Airflow 3 which delegates the authorization to an Open Policy
Agent

[uv](https://docs.astral.sh/uv/) is used to build the project:

uv build

The unit tests can be run as follows:

# Create directory for an SQLite database used by the test suite
mkdir ~/airflow

uv run pytest
Empty file.
Loading