Skip to content

NIFI-8695: Adding context to sensitive property providers#5206

Closed
gresockj wants to merge 12 commits intoapache:mainfrom
gresockj:NIFI-8695
Closed

NIFI-8695: Adding context to sensitive property providers#5206
gresockj wants to merge 12 commits intoapache:mainfrom
gresockj:NIFI-8695

Conversation

@gresockj
Copy link
Contributor

@gresockj gresockj commented Jul 9, 2021

Description of PR

Adds a ProtectedPropertyContext argument to SensitivePropertyProvider.protect(...) and SensitivePropertyProvider.unprotect(...) in order to pave the way for sensitive property providers that require a context (e.g., using HashiCorp Vault's key-value Secrets engine). The ProtectedPropertyContext comprises a PropertyLocation enum, representing the name of the configuration file in which the property resides, and a propertyName.

In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:

For all changes:

  • Is there a JIRA ticket associated with this PR? Is it referenced
    in the commit message?

  • 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.

  • Has your PR been rebased against the latest commit within the target branch (typically main)?

  • 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:

  • Have you ensured that the full suite of tests is executed via mvn -Pcontrib-check clean install at the root nifi folder?
  • Have you written or updated unit tests to verify your changes?
  • 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?
  • 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.

@gresockj gresockj force-pushed the NIFI-8695 branch 4 times, most recently from 432c790 to 19381d2 Compare July 15, 2021 09:50
Copy link
Contributor

@exceptionfactory exceptionfactory left a comment

Choose a reason for hiding this comment

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

Thanks for putting together these changes @gresockj! The concept makes sense, and should be very helpful when it comes to additional Sensitive Property Provider implementations. As noted in specific comments, I'm wondering about the possibility of alternative approaches that could avoid hard-coding property file locations. Perhaps those are static enough that an enum is an acceptable approach, but it seems worth considering potential alternatives before going forward.

@emiliosetiadarma
Copy link
Contributor

Hey @gresockj ! I was wondering about potentially adding a protect(final String unprotectedValue) that calls protect(final String unprotectedValue, final ProtectedPropertyContext context) with default context for the SensitivePropertyProvider interface?

I was thinking this would eliminate the need to modify existing SPPs which don't require this information, and addition of SPPs which dynamically protect/unprotect data vs. encrypting/decrypting them at rest could simply be a matter of adding a new PropertyProtectionScheme?

@gresockj
Copy link
Contributor Author

Hey @gresockj ! I was wondering about potentially adding a protect(final String unprotectedValue) that calls protect(final String unprotectedValue, final ProtectedPropertyContext context) with default context for the SensitivePropertyProvider interface?

I was thinking this would eliminate the need to modify existing SPPs which don't require this information, and addition of SPPs which dynamically protect/unprotect data vs. encrypting/decrypting them at rest could simply be a matter of adding a new PropertyProtectionScheme?

I like your thought, @emiliosetiadarma. I think it will have to work the opposite way, with protect(final String unprotectedValue, final ProtectedPropertyContext context) that calls protect(final String unprotectedValue), since the calling code will always reference the 2-argument method. But the effect will be the same, allowing SPPs to only implement the version they need to, while still only providing one version of the methods in the interface.

@exceptionfactory
Copy link
Contributor

@gresockj I provided a few additional comments, and as expected, it looks like rebasing this PR against the main branch is necessary now that #5202 is merged.

Copy link
Contributor

@exceptionfactory exceptionfactory left a comment

Choose a reason for hiding this comment

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

Thanks for making the latest round of updates @gresockj. The current approach looks good, and provides the flexibility for SPP implementations to decide whether or not to use the PropertyContext parameter.

I noted a few minor documentation and test adjustments, but otherwise this looks good.

# With the following configuration, for example, any property named "Manager Password" located inside
# a block whose <identifier> starts with "ldap-" will be mapped to the context named "ldap/Manager Password",
# regardless of whether it resides in authorizers.xml or login-identity-providers.xml.
nifi.bootstrap.protection.context.mapping.ldap=ldap-.*
Copy link
Contributor

Choose a reason for hiding this comment

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

Although this example is helpful, it seems better to leave it commented out in the default configuration.

On further consideration, since none of the current SPP implementations support handling PropertyContexts, it seems better to remove this section completely. When the first SPP introduces leverages PropertyContexts, that seems like a better opportunity to update the project documentation and include one or two lines of comments in bootstrap.conf

Copy link
Contributor

@exceptionfactory exceptionfactory left a comment

Choose a reason for hiding this comment

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

Thanks for working through the feedback @gresockj, the latest revisions look good. +1 Merging.

@asfgit asfgit closed this in 2daac57 Jul 27, 2021
krisztina-zsihovszki pushed a commit to krisztina-zsihovszki/nifi that referenced this pull request Jun 28, 2022
This closes apache#5206

Signed-off-by: David Handermann <exceptionfactory@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants