Skip to content

Commit 7b27aa5

Browse files
Rework authorization config (#884)
* switch NifiAuthorization to enum * extend NifiAuthorizationConfig with SingleUser and Standard cases * regenerate charts * use pvc for users.xml and authoriations.xml * document nifi ui login for ldap user * use standard authorization and initial admin for ldap test * cleanup * add docs * adapted changelog * Apply suggestions from code review Co-authored-by: Lukas Krug <[email protected]> * remove unused error * use storage config for filebased authorization PVC * fix repo name * Update rust/operator-binary/src/crd/mod.rs Co-authored-by: Lukas Krug <[email protected]> * consolidate crd name of filebased repo * document increasing filebased storage * fix precommit --------- Co-authored-by: Lukas Krug <[email protected]>
1 parent 90b7456 commit 7b27aa5

File tree

13 files changed

+525
-240
lines changed

13 files changed

+525
-240
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,19 @@ All notable changes to this project will be documented in this file.
99
- Support objectOverrides using `.spec.objectOverrides`.
1010
See [objectOverrides concepts page](https://docs.stackable.tech/home/nightly/concepts/overrides/#object-overrides) for details ([#885]).
1111

12+
### Changed
13+
14+
- BREAKING: Reworked authorization config to closer match the Apache NiFi internal authorizer interfaces ([#884]).
15+
1216
### Fixed
1317

1418
- Also listen on the loopback interface so that k8s port-forwards work ([#870]).
15-
- The operator now utilizes the `.spec.clusterConfig.authorization.opa.package` property instead of hard-coding the package name to `nifi` ([#881]).
19+
- The operator now utilizes the `.spec.clusterConfig.authorization.opa.package` property instead of hard-coding the package name to `nifi` ([#881]).
20+
- An `initialAdminUser` can now be provided for file-based authorization (e.g. LDAP) ([#884]).
1621

1722
[#870]: https://github.com/stackabletech/nifi-operator/pull/870
1823
[#881]: https://github.com/stackabletech/nifi-operator/pull/881
24+
[#884]: https://github.com/stackabletech/nifi-operator/pull/884
1925
[#885]: https://github.com/stackabletech/nifi-operator/pull/885
2026

2127
## [25.11.0] - 2025-11-07

deploy/helm/nifi-operator/crds/crds.yaml

Lines changed: 125 additions & 2 deletions
Large diffs are not rendered by default.

docs/modules/nifi/pages/usage_guide/resource-configuration.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
== Volume storage
55

66
By default, a NiFi Stacklet creates five different persistent volume claims for flow files, provenance, database, content and state directories.
7+
Depending on the NiFi cluster definition, another PVC for file-based authorization is added.
8+
79
You can find the default sizes of the PVCs in the {crd-docs}/nifi.stackable.tech/NifiCluster/v1alpha1/#spec-nodes-config-resources-storage[NifiCluster reference docs {external-link-icon}^], it is recommended that you configure these volume requests according to your needs.
810

911
Storage requests can be configured at role or group level, for one or more of the persistent volumes as follows:
@@ -16,6 +18,8 @@ nodes:
1618
config:
1719
resources:
1820
storage:
21+
filebasedRepo:
22+
capacity: 12Gi
1923
flowfileRepo:
2024
capacity: 12Gi
2125
provenanceRepo:

docs/modules/nifi/pages/usage_guide/security.adoc

Lines changed: 50 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
NiFi sets up TLS encryption for the http endpoints that serve the UI.
1616
By default, this interface is secured using certificates generated to work with the default SecretClass `tls`.
1717

18-
Nifi can be configured to use a different SecretClass as shown below:
18+
NiFi can be configured to use a different SecretClass as shown below:
1919

2020
[source, yaml]
2121
----
@@ -39,7 +39,7 @@ All authentication related parameters are configured under `spec.clusterConfig.a
3939
=== Single user
4040

4141
The `Single user` allows the creation of one admin user for NiFi.
42-
This is a rudimentary authentication method to quickly test and log in to the canvas.
42+
This is a rudimentary authentication method to quickly test and log into the canvas.
4343
However, due to it being a single user with all rights, this is not recommended in production.
4444

4545
[source, yaml]
@@ -171,27 +171,64 @@ stringData:
171171
[#authorization]
172172
== Authorization
173173

174-
The Stackable Operator for Apache NiFi supports {nifi-docs-authorization}[multiple authorization methods], the available authorization methods depend on the chosen authentication method. Using Open Policy Agent for authorization is independent of the authentication method.
174+
The Stackable Operator for Apache NiFi supports {nifi-docs-authorization}[multiple authorization methods].
175175

176176
[#authorization-single-user]
177177
=== Single user
178178

179179
With this authorization method, a single user has administrator capabilities.
180180

181-
[#authorization-ldap]
182-
=== LDAP
181+
[source,yaml]
182+
----
183+
apiVersion: nifi.stackable.tech/v1alpha1
184+
kind: NifiCluster
185+
metadata:
186+
name: test-nifi
187+
spec:
188+
clusterConfig:
189+
authorization:
190+
singleUser: {}
191+
----
183192

184-
The operator uses the {nifi-docs-fileusergroupprovider}[`FileUserGroupProvider`] and {nifi-docs-fileaccesspolicyprovider}[FileAccessPolicyProvider] to bind the LDAP user to the NiFi administrator group.
185-
This user is then able to create and modify groups and policies in the web interface.
186-
These changes local to the Pod running NiFi and are *not* persistent.
193+
[#authorization-standard]
194+
=== Standard
187195

188-
[#authorization-oidc]
189-
=== OIDC
196+
This refers to NiFis `StandardManagedAuthorizer`, using the `UserGroupProvider` and `AccessPolicyProvider` for authorization.
197+
The Stackable operator for Apache NiFi only supports the file-based `FileUserGroupProvider` and `FileAccessPolicyProvider` implementations.
190198

191-
With this authorization method, all authenticated users have administrator capabilities.
199+
[source,yaml]
200+
----
201+
apiVersion: nifi.stackable.tech/v1alpha1
202+
kind: NifiCluster
203+
metadata:
204+
name: test-nifi
205+
spec:
206+
clusterConfig:
207+
authorization:
208+
standard:
209+
accessPolicyProvider:
210+
fileBased:
211+
initialAdminUser: "cn=admin,ou=users,dc=example,dc=org"
212+
----
192213

193-
An admin user with an auto-generated password is created that can access the NiFi API.
194-
The password for this user is stored in a Kubernetes Secret called `<nifi-name>-oidc-admin-password`.
214+
This configuration provides an additional PVC to NiFi pods in order to read and persist the `users.xml` and `authorizations.xml` files.
215+
The default size is 16Mi and can be increased via the storage configuration on role or rolegroup level:
216+
217+
[source,yaml]
218+
----
219+
apiVersion: nifi.stackable.tech/v1alpha1
220+
kind: NifiCluster
221+
metadata:
222+
name: test-nifi
223+
spec:
224+
clusterConfig: { .. }
225+
nodes:
226+
config:
227+
resources:
228+
storage:
229+
filebasedRepo:
230+
capacity: 256Mi
231+
----
195232

196233
[#authorization-opa]
197234
=== Open Policy Agent (OPA)

rust/operator-binary/src/config/jvm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::{
99
crd::{NifiConfig, NifiConfigFragment, NifiNodeRoleConfig},
1010
security::{
1111
authentication::{STACKABLE_SERVER_TLS_DIR, STACKABLE_TLS_STORE_PASSWORD},
12-
authorization::NifiAuthorizationConfig,
12+
authorization::ResolvedNifiAuthorizationConfig,
1313
},
1414
};
1515

@@ -35,7 +35,7 @@ pub fn build_merged_jvm_config(
3535
merged_config: &NifiConfig,
3636
role: &Role<NifiConfigFragment, NifiNodeRoleConfig, JavaCommonConfig>,
3737
role_group: &str,
38-
authorization_config: Option<&NifiAuthorizationConfig>,
38+
authorization_config: Option<&ResolvedNifiAuthorizationConfig>,
3939
) -> Result<JvmArgumentOverrides, Error> {
4040
let heap_size = MemoryQuantity::try_from(
4141
merged_config

rust/operator-binary/src/config/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ pub mod jvm;
3737

3838
pub const NIFI_CONFIG_DIRECTORY: &str = "/stackable/nifi/conf";
3939
pub const NIFI_PYTHON_WORKING_DIRECTORY: &str = "/nifi-python-working-directory";
40+
pub const NIFI_PVC_STORAGE_DIRECTORY: &str = "/stackable/data";
4041

4142
pub const NIFI_BOOTSTRAP_CONF: &str = "bootstrap.conf";
4243
pub const NIFI_PROPERTIES: &str = "nifi.properties";
@@ -51,6 +52,8 @@ const STORAGE_CONTENT_ARCHIVE_UTILIZATION_FACTOR: f32 = 0.5;
5152

5253
#[derive(Debug, Display, EnumIter)]
5354
pub enum NifiRepository {
55+
#[strum(serialize = "filebased")]
56+
Filebased,
5457
#[strum(serialize = "flowfile")]
5558
Flowfile,
5659
#[strum(serialize = "database")]
@@ -69,7 +72,7 @@ impl NifiRepository {
6972
}
7073

7174
pub fn mount_path(&self) -> String {
72-
format!("/stackable/data/{}", self)
75+
format!("{NIFI_PVC_STORAGE_DIRECTORY}/{}", self)
7376
}
7477
}
7578

@@ -115,7 +118,7 @@ pub fn build_bootstrap_conf(
115118
overrides: BTreeMap<String, String>,
116119
role: &Role<NifiConfigFragment, NifiNodeRoleConfig, JavaCommonConfig>,
117120
role_group: &str,
118-
authorization_config: Option<&crate::security::authorization::NifiAuthorizationConfig>,
121+
authorization_config: Option<&crate::security::authorization::ResolvedNifiAuthorizationConfig>,
119122
) -> Result<String, Error> {
120123
let mut bootstrap = BTreeMap::new();
121124
// Java command to use when running NiFi

0 commit comments

Comments
 (0)