Skip to content
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

NIFI-1733 Adding a Ranger implementation of NiFi's Authorizer API #574

Closed
wants to merge 3 commits into from

Conversation

bbende
Copy link
Contributor

@bbende bbende commented Jun 24, 2016

This PR adds an Authorizer implementation that uses Apache Ranger and also modifies the build so that Ranger related artifacts are only included when using -Pinclude-ranger, this way the normal build does not need to include anything related to Ranger, and those that want it can also easily build it themselves.

When using NiFi with Ranger you would declare an Authorizer like the following in authorizers.xml:

    <authorizer>
        <identifier>ranger-provider</identifier>
        <class>org.apache.nifi.ranger.authorization.RangerNiFiAuthorizer</class>
        <property name="Ranger Audit Config Path">src/test/resources/ranger/ranger-nifi-audit.xml</property>
        <property name="Ranger Security Config Path">src/test/resources/ranger/ranger-nifi-security.xml</property>
        <property name="Ranger Service Type">nifi</property>
        <property name="Ranger Application Id">nifi</property>
        <property name="Ranger Admin Identity">CN=ranger-admin, OU=Apache Ranger, O=Apache, L=Santa Monica, ST=CA, C=US</property>
        <property name="Ranger Kerberos Enabled">false</property>
    </authorizer>

For anyone interested in playing around with this, I created a Vagrant VM that can run a build of Ranger:
https://github.com/bbende/apache-ranger-vagrant

@bbende bbende force-pushed the NIFI-1733 branch 5 times, most recently from 8c845fd to 51a79e9 Compare July 13, 2016 15:45
@bbende bbende force-pushed the NIFI-1733 branch 4 times, most recently from e9b00b2 to 53f8e53 Compare July 19, 2016 16:39
@bbende bbende changed the title NIFI-1733 [REVIEW ONLY] Adding a Ranger implementation of NiFi's Authorizer API NIFI-1733 Adding a Ranger implementation of NiFi's Authorizer API Jul 19, 2016
@bbende bbende force-pushed the NIFI-1733 branch 2 times, most recently from 4da3418 to 2416d17 Compare July 20, 2016 18:55
@joewitt
Copy link
Contributor

joewitt commented Jul 21, 2016

@bbende really nice job on the licensing stuff and thanks for finding/fixing the lgpl findbugs annotations issue!

@YolandaMDavis
Copy link
Contributor

YolandaMDavis commented Jul 21, 2016

@bbende happy to take this on for review. Please update with the latest to resolve conflicts.

final String rangerKerberosEnabledValue = getConfigValue(configurationContext, RANGER_KERBEROS_ENABLED_PROP, Boolean.FALSE.toString());
rangerKerberosEnabled = rangerKerberosEnabledValue.equals(Boolean.TRUE.toString()) ? true : false;

if (rangerKerberosEnabled) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could not see testing coverage in this area, especially in the case where kerberos is enabled but no kerberos properties (keytab/principal) exist.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, working on some unit tests now for these scenarios

@YolandaMDavis
Copy link
Contributor

@bbende overall looks great ! I executed unit tests for coverage evaluation (hence my notes above) and did some integration testing with a remote Ranger server which also worked well.

In looking at the RangerBasePluginWithPolicies it appeared to me to be a convenience class for extracting resources and storing a copy of the resource value for lookup later. One thought I had was whether the RangerPolicyEngine could be interrogated (via methods on the RangerBasePlugin) to check for existing resources to avoid the copy?

@bbende
Copy link
Contributor Author

bbende commented Jul 25, 2016

@YolandaMDavis thanks for reviewing! Working on some changes based on your feedback.

Regarding the need for RangerBasePluginWithPolicies... unfortunately the PolicyEngine is a private member variable of RangerBasePlugin and there is no getter for it, so no way to access it. I think most other plugins would never need to, but for NiFi we need to know if the reason for denying access was because no policy exists for the resource, or because a specific policy exists that doesn't match the incoming request.

So the best I could come up with was to intercept when the policies are refreshed and store the resource ids so that when RangerAccessResult getIsAllowed() returns false we can then do a second check to see if there was even a policy for the given resource, and if not then return resource not found, rather than denied.

- Adding Authorizer implementation for Ranger
- Adding build profile and assembly that controls the inclusion of Ranger in the final assembly
- Add properties to specify ranger admin identity and a flag to indicate if ranger is using kerberos, plugin is updated to perform a UGI login if ranger is using kerberos
…rBasePluginWithPolicies, cleaning up code to use Java 8 features
@bbende
Copy link
Contributor Author

bbende commented Jul 25, 2016

@YolandaMDavis rebased against master to resolve conflicts and pushed a new commit that addresses your feedback

@YolandaMDavis
Copy link
Contributor

@bbende all looks good on this end. Thanks Bryan!

@asfgit asfgit closed this in c27763a Jul 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants