You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2022/04/18 16:32:13 UTC

[GitHub] [nifi] exceptionfactory opened a new pull request, #5972: NIFI-9883 Refactor Property Protection using Isolated ClassLoader

exceptionfactory opened a new pull request, #5972:
URL: https://github.com/apache/nifi/pull/5972

   #### Description of PR
   
   NIFI-9883 Refactors the process of loading Sensitive Property Providers to use an isolated `ClassLoader`.
   
   These changes impact the loading process for `nifi.properties`, `authorizers.xml`, and `login-identity-providers.xml`. The classes responsible for loading these configuration files include updates to set the current Thread context `ClassLoader` during the loading operation, and reset the previous `ClassLoader` after completion.
   
   The implementation moves runtime dependencies for Sensitive Property Provider implementations to a new `lib/properties` directory as part of the standard NiFi binary installation. A new `PropertyProtectionURLClassLoader` attempts to read the files located in `lib/properties`, making libraries available for runtime processing of encrypted properties.
   
   This approach reduces the size the `nifi-framework-nar` and several other NAR binaries through sharing JAR files located in `lib/properties`. These changes also avoid introducing unexpected runtime changes due to transitive dependencies required for Sensitive Property Provider implementations. Additional changes include streamlined unit tests for NiFi properties that reduce duplication of encryption property handling.
   
   In order to streamline the review of the contribution we ask you
   to ensure the following steps have been taken:
   
   ### For all changes:
   - [X] Is there a JIRA ticket associated with this PR? Is it referenced 
        in the commit message?
   
   - [X] Does your PR title start with **NIFI-XXXX** where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
   
   - [X] Has your PR been rebased against the latest commit within the target branch (typically `main`)?
   
   - [X] Is your initial contribution a single, squashed commit? _Additional commits in response to PR reviewer feedback should be made on this branch and pushed to allow change tracking. Do not `squash` or use `--force` when pushing to allow for clean monitoring of changes._
   
   ### For code changes:
   - [X] Have you ensured that the full suite of tests is executed via `mvn -Pcontrib-check clean install` at the root `nifi` folder?
   - [X] Have you written or updated unit tests to verify your changes?
   - [X] Have you verified that the full build is successful on JDK 8?
   - [ ] Have you verified that the full build is successful on JDK 11?
   - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
   - [ ] If applicable, have you updated the `LICENSE` file, including the main `LICENSE` file under `nifi-assembly`?
   - [ ] If applicable, have you updated the `NOTICE` file, including the main `NOTICE` file found under `nifi-assembly`?
   - [ ] If adding new Properties, have you added `.displayName` in addition to .name (programmatic access) for each of the new properties?
   
   ### For documentation related changes:
   - [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
   
   ### Note:
   Please ensure that once the PR is submitted, you check GitHub Actions CI for build issues and submit an update to your PR as soon as possible.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] exceptionfactory commented on pull request #5972: NIFI-9883 Refactor Property Protection using Isolated ClassLoader

Posted by GitBox <gi...@apache.org>.
exceptionfactory commented on PR #5972:
URL: https://github.com/apache/nifi/pull/5972#issuecomment-1101795848

   Thanks for catching that issue @thenatog! The problem is the result of having no Login Identity Providers configured, which makes sense when NiFi is deployed using Client Certificate authentication. It looks like the Factory Bean for the Login Identity Provider should retain the `Object` as the return type for the `getObject()` method in order to handle a `null` provider.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] bbende merged pull request #5972: NIFI-9883 Refactor Property Protection using Isolated ClassLoader

Posted by GitBox <gi...@apache.org>.
bbende merged PR #5972:
URL: https://github.com/apache/nifi/pull/5972


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] thenatog commented on pull request #5972: NIFI-9883 Refactor Property Protection using Isolated ClassLoader

Posted by GitBox <gi...@apache.org>.
thenatog commented on PR #5972:
URL: https://github.com/apache/nifi/pull/5972#issuecomment-1101974229

   I've tested this with the single user provider and encrypted nifi.properties and flow.xml.gz, and with a 3 node secure cluster using X509. Also tested with LDAP which uses the LDAP login identity provider though the config was not encrypted. Also tested with Google OIDC (not sure if this would have been affected..)
   
   I'll leave this open for now if we have further feedback from others.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] thenatog commented on pull request #5972: NIFI-9883 Refactor Property Protection using Isolated ClassLoader

Posted by GitBox <gi...@apache.org>.
thenatog commented on PR #5972:
URL: https://github.com/apache/nifi/pull/5972#issuecomment-1101593040

   Cool PR, will review


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] thenatog commented on pull request #5972: NIFI-9883 Refactor Property Protection using Isolated ClassLoader

Posted by GitBox <gi...@apache.org>.
thenatog commented on PR #5972:
URL: https://github.com/apache/nifi/pull/5972#issuecomment-1101792688

   I've noticed that I had an issue running a secure cluster and NiFi cannot start successfully with my existing configurations (appears related to identity providers):
   
   `2022-04-18 16:50:35,325 ERROR [main] o.s.web.context.ContextLoader Context initialization failed
   org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loginIdentityProvider' defined in org.apache.nifi.web.security.configuration.AuthenticationSecurityConfiguration: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.lang.Object]: Factory method 'loginIdentityProvider' threw exception; nested exception is java.lang.ClassCastException: org.springframework.beans.factory.support.NullBean cannot be cast to org.apache.nifi.authentication.LoginIdentityProvider
   	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658)
   	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:486)
   	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352)
   	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195)
   	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
   	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
   	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
   	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
   	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
   	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
   	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953)
   	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
   	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
   	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:401)
   	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:292)
   	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:103)
   	at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:1073)
   	at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:572)
   	at org.eclipse.jetty.server.handler.ContextHandler.contextInitialized(ContextHandler.java:1002)
   	at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:746)
   	at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:379)
   	at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1449)
   	at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1414)
   	at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:916)
   	at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:288)
   	at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:524)
   	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
   	at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:169)
   	at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:117)
   	at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:97)
   	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
   	at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:169)
   	at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:110)
   	at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:97)
   	at org.eclipse.jetty.server.handler.gzip.GzipHandler.doStart(GzipHandler.java:426)
   	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
   	at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:169)
   	at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:117)
   	at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:97)
   	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
   	at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:169)
   	at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:117)
   	at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:97)
   	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
   	at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:169)
   	at org.eclipse.jetty.server.Server.start(Server.java:423)
   	at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:110)
   	at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:97)
   	at org.eclipse.jetty.server.Server.doStart(Server.java:387)
   	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
   	at org.apache.nifi.web.server.JettyServer.start(JettyServer.java:1052)
   	at org.apache.nifi.NiFi.<init>(NiFi.java:170)
   	at org.apache.nifi.NiFi.<init>(NiFi.java:82)
   	at org.apache.nifi.NiFi.main(NiFi.java:330)
   Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.lang.Object]: Factory method 'loginIdentityProvider' threw exception; nested exception is java.lang.ClassCastException: org.springframework.beans.factory.support.NullBean cannot be cast to org.apache.nifi.authentication.LoginIdentityProvider
   	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
   	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)
   	... 53 common frames omitted
   Caused by: java.lang.ClassCastException: org.springframework.beans.factory.support.NullBean cannot be cast to org.apache.nifi.authentication.LoginIdentityProvider
   	at org.apache.nifi.web.security.spring.LoginIdentityProviderFactoryBean$$EnhancerBySpringCGLIB$$3e2a6f6e.getObject(<generated>)
   	at org.apache.nifi.web.security.configuration.AuthenticationSecurityConfiguration.loginIdentityProvider(AuthenticationSecurityConfiguration.java:70)
   	at org.apache.nifi.web.security.configuration.AuthenticationSecurityConfiguration$$EnhancerBySpringCGLIB$$a97fddc8.CGLIB$loginIdentityProvider$3(<generated>)
   	at org.apache.nifi.web.security.configuration.AuthenticationSecurityConfiguration$$EnhancerBySpringCGLIB$$a97fddc8$$FastClassBySpringCGLIB$$6dfd4e89.invoke(<generated>)
   	at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
   	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331)
   	at org.apache.nifi.web.security.configuration.AuthenticationSecurityConfiguration$$EnhancerBySpringCGLIB$$a97fddc8.loginIdentityProvider(<generated>)
   	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   	at java.lang.reflect.Method.invoke(Method.java:498)
   	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
   	... 54 common frames omitted`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org