Skip to content

Commit a58c1e6

Browse files
feat(airflow): Add OPA support to Airflow (#978)
* feat: Add initial OpaFabAuthManager * feat(airflow): Call OPA from FabAuthManager * feat(airflow): Add cache and configuration options for OPA and implement all is_authorized functions * fix(airflow): Fix call to OPA * test(airflow): Test OpaFabAuthManager configuration and caching * chore: Update changelog * feat(airflow): Add metric opa_cache_limit_reached * docs(airflow): Add a README to the opa-auth-manager * chore(airflow): Reformat Python code * docs(airflow): Fix markdown linter warning * chore(airflow): Fix Dockerfile linter warning * docs(airflow): Fix a typo
1 parent 70dc187 commit a58c1e6

File tree

10 files changed

+5178
-0
lines changed

10 files changed

+5178
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.
66

77
### Added
88

9+
- airflow: Add OPA support to Airflow ([#978]).
910
- nifi: Activate `include-hadoop` profile for NiFi version 2.* ([#958]).
1011
- nifi: Add NiFi hadoop Azure and GCP libraries ([#943]).
1112
- base: Add containerdebug tool ([#928], [#959]).
@@ -45,6 +46,7 @@ All notable changes to this project will be documented in this file.
4546
[#959]: https://github.com/stackabletech/docker-images/pull/959
4647
[#935]: https://github.com/stackabletech/docker-images/pull/935
4748
[#962]: https://github.com/stackabletech/docker-images/pull/962
49+
[#978]: https://github.com/stackabletech/docker-images/pull/978
4850
[#980]: https://github.com/stackabletech/docker-images/pull/980
4951
[#981]: https://github.com/stackabletech/docker-images/pull/981
5052
[#982]: https://github.com/stackabletech/docker-images/pull/982

airflow/Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,19 @@ FROM oci.stackable.tech/sdp/git-sync/git-sync:${GIT_SYNC} AS gitsync-image
99

1010
FROM stackable/image/statsd_exporter AS statsd_exporter-builder
1111

12+
FROM python:3.12-bookworm AS opa-auth-manager-builder
13+
14+
COPY airflow/opa-auth-manager/ /tmp/opa-auth-manager
15+
16+
WORKDIR /tmp/opa-auth-manager
17+
18+
RUN <<EOF
19+
pip install --no-cache-dir poetry
20+
poetry build
21+
poetry install
22+
poetry run pytest
23+
EOF
24+
1225
FROM stackable/image/vector AS airflow-build-image
1326

1427
ARG PRODUCT
@@ -17,6 +30,7 @@ ARG PYTHON
1730
ARG TARGETARCH
1831

1932
COPY airflow/constraints-${PRODUCT}-python${PYTHON}.txt /tmp/constraints.txt
33+
COPY --from=opa-auth-manager-builder /tmp/opa-auth-manager/dist/opa_auth_manager-0.1.0-py3-none-any.whl /tmp/
2034

2135
# The mysql provider is currently excluded.
2236
# Requires implementation of https://github.com/apache/airflow/blob/2.2.5/scripts/docker/install_mysql.sh
@@ -57,6 +71,8 @@ pip install --no-cache-dir s3fs==2024.9.0 cyclonedx-bom==5.0.0
5771
# Needed for OIDC
5872
pip install --no-cache-dir Flask_OIDC==2.2.0 Flask-OpenID==1.3.1
5973

74+
pip install --no-cache-dir /tmp/opa_auth_manager-0.1.0-py3-none-any.whl
75+
6076
# Create the SBOM for Airflow
6177
# Important: All `pip install` commands must be above this line, otherwise the SBOM will be incomplete
6278
cyclonedx-py environment --schema-version 1.5 --outfile /tmp/sbom.json

airflow/opa-auth-manager/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.pytest_cache/
2+
dist/

airflow/opa-auth-manager/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Airflow OPA auth manager
2+
3+
Auth manager for Airflow which delegates the authorization to an Open Policy
4+
Agent
5+
6+
[Poetry](https://python-poetry.org/) is used to build the project:
7+
8+
poetry build
9+
10+
The unit tests can be run as follows:
11+
12+
poetry run pytest

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

Whitespace-only changes.

0 commit comments

Comments
 (0)