Skip to content

Commit 2e50694

Browse files
razvanadwk67
andauthored
feat: OPA authorizer for Airflow 3 (#1127)
* patches I * patches I * wip: patch hbase to use listener endpoints * changed rendering * rework patch for UI * wip * removed wip deadwood * removed wip deadwood II * move extras to argument * re-org constraints * changelog * wip * wip * fix merge errors * split opa auth manager in two implementations * replace poetry with uv * tests: airflow 3 opa auth manager (and some reformatting) * cleanup print() call * update readme * update changelog --------- Co-authored-by: Andrew Kenworthy <[email protected]>
1 parent 3c39e31 commit 2e50694

21 files changed

+3950
-4227
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ All notable changes to this project will be documented in this file.
4747
- hbase: add 2.6.2 and upgrade dependencies ([#1101])
4848
- kafka: Add `4.0.0` ([#1117])
4949
- Include `.tar.gz` snapshots of the product source code in container images ([#1126])
50+
- airflow: OPA authorizer for Airflow 3.x ([#1127])
5051

5152
### Changed
5253

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

152154
## [25.3.0] - 2025-03-21

airflow/Dockerfile

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# syntax=docker/dockerfile:1.15.1@sha256:9857836c9ee4268391bb5b09f9f157f3c91bb15821bb77969642813b0d00518d
2-
# check=error=true;skip=InvalidDefaultArgInFrom
2+
# Disabled error checks:
3+
# - SecretsUsedInArgOrEnv : OPA_AUTH_MANAGER is a false positive and breaks the build.
4+
# check=error=true;skip=InvalidDefaultArgInFrom,SecretsUsedInArgOrEnv
35

46
ARG GIT_SYNC
57

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

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

12-
FROM python:3.12-bookworm AS opa-auth-manager-builder
14+
FROM stackable/image/vector AS opa-auth-manager-builder
1315

14-
COPY airflow/opa-auth-manager/ /tmp/opa-auth-manager
16+
ARG OPA_AUTH_MANAGER
17+
ARG PYTHON
18+
ARG UV
19+
20+
COPY airflow/opa-auth-manager/${OPA_AUTH_MANAGER} /tmp/opa-auth-manager
1521

1622
WORKDIR /tmp/opa-auth-manager
1723

1824
RUN <<EOF
19-
pip install --no-cache-dir poetry
20-
poetry build
21-
poetry install
22-
poetry run pytest
25+
microdnf update
26+
microdnf install python${PYTHON}-pip
27+
microdnf clean all
28+
29+
pip${PYTHON} install --no-cache-dir uv==${UV}
30+
31+
# This folder is required by the tests to set up an sqlite database
32+
mkdir /root/airflow
33+
34+
# Warnings are disabled because they come from various third party testing libraries
35+
# that we have no control over.
36+
uv run pytest --disable-warnings
37+
uv build
2338
EOF
2439

2540
FROM stackable/image/vector AS airflow-build-image

airflow/opa-auth-manager/README.md

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Airflow 2 OPA auth manager
2+
3+
Auth manager for Airflow 2 which delegates the authorization to an Open Policy
4+
Agent
5+
6+
[uv](https://docs.astral.sh/uv/) is used to build the project:
7+
8+
uv build
9+
10+
The unit tests can be run as follows:
11+
12+
uv run pytest
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[project]
2+
name = "opa-auth-manager"
3+
version = "0.1.0"
4+
description = "Auth manager for Airflow which delegates the authorization to an Open Policy Agent"
5+
authors = [
6+
{ name = "Siegfried Weber", email="[email protected]"},
7+
{ name = "Razvan Daniel Mihai", email="[email protected]"}
8+
]
9+
readme = "README.md"
10+
requires-python = ">=3.9,<3.13"
11+
12+
dependencies = [
13+
"requests~=2.32.3",
14+
"cachetools~=5.5.0",
15+
"overrides~=7.7.0"
16+
]
17+
18+
[dependency-groups]
19+
dev = [
20+
"apache-airflow~=2.9.3",
21+
"pylint~=3.3.1",
22+
"pytest~=8.3.3"
23+
]
24+
25+
[build-system]
26+
requires = ["hatchling"]
27+
build-backend = "hatchling.build"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.pytest_cache/
2+
dist/
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Airflow 3 OPA auth manager
2+
3+
Auth manager for Airflow 3 which delegates the authorization to an Open Policy
4+
Agent
5+
6+
[uv](https://docs.astral.sh/uv/) is used to build the project:
7+
8+
uv build
9+
10+
The unit tests can be run as follows:
11+
12+
# Create directory for an SQLite database used by the test suite
13+
mkdir ~/airflow
14+
15+
uv run pytest

airflow/opa-auth-manager/airflow-3/opa_auth_manager/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)