This repository has been archived by the owner on Jul 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 103
NIFIREG-186: Adding Ranger authorizer #131
Closed
Closed
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
11e4734
NIFIREG-186: Adding Ranger authorizer
ijokarumawak 3f7eb37
Incorporated review comments
ijokarumawak 29239be
Added minimum docs to use Ranger extension.
ijokarumawak 349485d
Added LICENSE and NOTICE.
ijokarumawak 7057ff2
Remove javax.ws.rs package in jersey-bundle jar to avoid rs version c…
ijokarumawak 21424f1
Added example conf to audit to Kerberized Solr.
ijokarumawak 25d0940
Added Kerberos support.
ijokarumawak 2118d3d
Refactored project structures and updated L&N.
ijokarumawak File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
116 changes: 116 additions & 0 deletions
116
nifi-registry-extensions/nifi-registry-ranger-extension/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
<!-- | ||
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. | ||
--> | ||
# NiFi Registry Ranger extension | ||
|
||
This extension provides `org.apache.nifi.registry.ranger.RangerAuthorizer` class for NiFi Registry to authorize user requests by access policies defined at [Apache Ranger](https://ranger.apache.org/). | ||
|
||
## Prerequisites | ||
|
||
* Apache Ranger 1.2.0 or later is needed. | ||
|
||
## How to install | ||
|
||
### Enable Ranger extension at NiFi Registry build | ||
|
||
In order to enable Ranger extension when you build NiFi Registry, specify `include-ranger` profile with a maven install command: | ||
|
||
``` | ||
cd nifi-registry | ||
mvn clean install -Pinclude-ranger | ||
``` | ||
|
||
Then the extension will be installed at `${NIFI_REG_HOME}/ext/ranger` directory. | ||
|
||
### Add Ranger extension to existing NiFi Registry | ||
|
||
Alternatively, you can add Ranger extension to an existing NiFi Registry. | ||
To do so, build the extension with the following command: | ||
|
||
``` | ||
cd nifi-registry | ||
mvn clean install -f nifi-registry-extensions/nifi-registry-ranger-extension | ||
``` | ||
|
||
The extension zip will be created as `nifi-registry-extensions/nifi-registry-ranger-extension/target/nifi-registry-ranger-extension-xxx-bin.zip`. | ||
|
||
Unzip the file into arbitrary directory so that NiFi Registry can use, such as `${NIFI_REG_HOME}/ext/ranger`. | ||
For example: | ||
|
||
``` | ||
mkdir -p ${NIFI_REG_HOME}/ext/ranger | ||
unzip -d ${NIFI_REG_HOME}/ext/ranger nifi-registry-extensions/nifi-registry-ranger-extension/target/nifi-registry-ranger-extension-xxx-bin.zip | ||
``` | ||
|
||
## NiFi Registry Configuration | ||
|
||
In order to use this extension, following NiFi Registry files need to be configured. | ||
|
||
### nifi-registry.properties | ||
|
||
``` | ||
# Specify Ranger extension dir | ||
nifi.registry.extension.dir.ranger=./ext/ranger/lib | ||
# Specify Ranger authorizer identifier, which is defined at authorizers.xml | ||
nifi.registry.security.authorizer=ranger-authorizer | ||
``` | ||
|
||
### authorizers.xml | ||
|
||
Add following `authorizer` element: | ||
``` | ||
<authorizer> | ||
<identifier>ranger-authorizer</identifier> | ||
<class>org.apache.nifi.registry.ranger.RangerAuthorizer</class> | ||
<property name="Ranger Service Type">nifi-registry</property> | ||
|
||
<property name="User Group Provider">file-user-group-provider</property> | ||
|
||
<!-- Specify Ranger service name to use --> | ||
<property name="Ranger Application Id">nifi-registry-service-name</property> | ||
|
||
<!-- Specify configuration file paths for Ranger plugin --> | ||
<property name="Ranger Security Config Path">./ext/ranger/conf/ranger-nifi-registry-security.xml</property> | ||
<property name="Ranger Audit Config Path">./ext/ranger/conf/ranger-nifi-registry-audit.xml</property> | ||
|
||
<!-- | ||
Specify user identity that is used by Ranger to access NiFi Registry. | ||
This property is used by NiFi Registry for Ranger to get available NiFi Registry policy resource identifiers. | ||
The configured user can access NiFi Registry /policies/resources REST endpoint regardless of configured access policies. | ||
Ranger uses available policies for user input suggestion at Ranger policy editor UI. | ||
--> | ||
<property name="Ranger Admin Identity">ranger@NIFI</property> | ||
|
||
<!-- | ||
If set to true, NiFi Registry will use the principal and keytab defined at nifi-registry.properties to access Ranger: | ||
- nifi.registry.kerberos.service.principal | ||
- nifi.registry.kerberos.service.keytab.location | ||
--> | ||
<property name="Ranger Kerberos Enabled">false</property> | ||
|
||
</authorizer> | ||
``` | ||
|
||
## Ranger Configuration | ||
|
||
At Ranger side, add a NiFi Registry service. NiFi Registry service has following configuration properties: | ||
|
||
- NiFi Registry URL: Specify corresponding NiFi Registry URL that will be managed by this Ranger service. E.g. `https://nifi-registry.example.com:18443/nifi-registry-api/policies/resources` | ||
- Authentication Type: Should be `SSL`. Ranger authenticates itself to NiFi Registry by X.509 client certificate in the configured Keystore. | ||
- Keystore: Specify a Keystore filepath to use for X.509 client certificate. | ||
- Keystore Type: Specify the type of Keystore. E.g. `JKS` | ||
- Keystore Password: Specify the password of Keystore. | ||
- Truststore: Specify a Truststore filepath to verify NiFi Registry server certificate. | ||
- Truststore Type: Specify the type of Truststore. E.g. `JKS` | ||
- Truststore Password: Specify the password of Truststore. |
101 changes: 101 additions & 0 deletions
101
nifi-registry-extensions/nifi-registry-ranger-extension/conf/ranger-nifi-registry-audit.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<?xml version="1.0"?> | ||
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?> | ||
<!-- | ||
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. | ||
--> | ||
<configuration> | ||
<property> | ||
<name>xasecure.audit.is.enabled</name> | ||
<value>true</value> | ||
</property> | ||
|
||
<!-- DB audit provider configuration --> | ||
<property> | ||
<name>xasecure.audit.destination.db</name> | ||
<value>false</value> | ||
</property> | ||
|
||
<property> | ||
<name>xasecure.audit.destination.db.jdbc.driver</name> | ||
<value>com.mysql.jdbc.Driver</value> | ||
</property> | ||
|
||
<property> | ||
<name>xasecure.audit.destination.db.jdbc.url</name> | ||
<value>jdbc:mysql://localhost/ranger_audit</value> | ||
</property> | ||
|
||
<property> | ||
<name>xasecure.audit.destination.db.password</name> | ||
<value>rangerlogger</value> | ||
</property> | ||
|
||
<property> | ||
<name>xasecure.audit.destination.db.user</name> | ||
<value>rangerlogger</value> | ||
</property> | ||
|
||
<property> | ||
<name>xasecure.audit.destination.db.batch.filespool.dir</name> | ||
<value>/tmp/audit/db/spool</value> | ||
</property> | ||
|
||
|
||
<!-- HDFS audit provider configuration --> | ||
<property> | ||
<name>xasecure.audit.destination.hdfs</name> | ||
<value>false</value> | ||
</property> | ||
|
||
<property> | ||
<name>xasecure.audit.destination.hdfs.dir</name> | ||
<value>hdfs://localhost:8020/ranger/audit</value> | ||
</property> | ||
|
||
<property> | ||
<name>xasecure.audit.destination.hdfs.batch.filespool.dir</name> | ||
<value>/tmp/audit/hdfs/spool</value> | ||
</property> | ||
|
||
|
||
<!-- Log4j audit provider configuration --> | ||
<property> | ||
<name>xasecure.audit.destination.log4j</name> | ||
<value>false</value> | ||
</property> | ||
|
||
<property> | ||
<name>xasecure.audit.destination.log4j.logger</name> | ||
<value>ranger_audit_logger</value> | ||
</property> | ||
|
||
<!-- Solr audit provider configuration --> | ||
<property> | ||
<name>xasecure.audit.destination.solr</name> | ||
<value>true</value> | ||
</property> | ||
|
||
<property> | ||
<name>xasecure.audit.destination.solr.batch.filespool.dir</name> | ||
<value>/tmp/audit/solr/spool</value> | ||
</property> | ||
|
||
<property> | ||
<name>xasecure.audit.destination.solr.urls</name> | ||
<value>http://localhost:6083/solr/ranger_audits</value> | ||
</property> | ||
|
||
</configuration> |
83 changes: 83 additions & 0 deletions
83
...registry-extensions/nifi-registry-ranger-extension/conf/ranger-nifi-registry-security.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?xml version="1.0"?> | ||
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?> | ||
<!-- | ||
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. | ||
--> | ||
<configuration> | ||
<property> | ||
<name>ranger.plugin.nifi-registry.policy.rest.url</name> | ||
<value>http://localhost:6080</value> | ||
<description> | ||
URL to Ranger Admin | ||
</description> | ||
</property> | ||
|
||
<property> | ||
<name>ranger.plugin.nifi-registry.service.name</name> | ||
<value>nifi-registry-service-name</value> | ||
<description> | ||
Name of the Ranger service containing policies for this NiFi Registry instance | ||
</description> | ||
</property> | ||
|
||
<property> | ||
<name>ranger.plugin.nifi-registry.policy.source.impl</name> | ||
<value>org.apache.ranger.admin.client.RangerAdminRESTClient</value> | ||
<description> | ||
Class to retrieve policies from the source | ||
</description> | ||
</property> | ||
|
||
<property> | ||
<name>ranger.plugin.nifi-registry.policy.rest.ssl.config.file</name> | ||
<value>ranger-policymgr-ssl.xml</value> | ||
<description> | ||
Path to the file containing SSL details to contact Ranger Admin | ||
</description> | ||
</property> | ||
|
||
<property> | ||
<name>ranger.plugin.nifi-registry.policy.pollIntervalMs</name> | ||
<value>30000</value> | ||
<description> | ||
How often to poll for changes in policies? | ||
</description> | ||
</property> | ||
|
||
<property> | ||
<name>ranger.plugin.nifi-registry.policy.cache.dir</name> | ||
<value>/tmp</value> | ||
<description> | ||
Directory where Ranger policies are cached after successful retrieval from the source | ||
</description> | ||
</property> | ||
|
||
<property> | ||
<name>ranger.plugin.nifi-registry.policy.rest.client.connection.timeoutMs</name> | ||
<value>120000</value> | ||
<description> | ||
RangerRestClient Connection Timeout in Milli Seconds | ||
</description> | ||
</property> | ||
|
||
<property> | ||
<name>ranger.plugin.nifi-registry.policy.rest.client.read.timeoutMs</name> | ||
<value>30000</value> | ||
<description> | ||
RangerRestClient read Timeout in Milli Seconds | ||
</description> | ||
</property> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sentence may need to be updated once the improvement at Ranger project is committed.