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 2020/07/20 22:08:17 UTC

[GitHub] [nifi] thenatog opened a new pull request #4416: NIFI-7568 - Ensure Kerberos mappings are applied correctly

thenatog opened a new pull request #4416:
URL: https://github.com/apache/nifi/pull/4416


   Thank you for submitting a contribution to Apache NiFi.
   
   Please provide a short description of the PR here:
   
   #### Description of PR
   
   _Enables X functionality; fixes bug NIFI-YYYY._
   
   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?
   - [x] 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.

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



[GitHub] [nifi] asfgit closed pull request #4416: NIFI-7568 - Ensure Kerberos mappings are applied correctly

Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #4416:
URL: https://github.com/apache/nifi/pull/4416


   


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

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



[GitHub] [nifi] mcgilman commented on a change in pull request #4416: NIFI-7568 - Ensure Kerberos mappings are applied correctly

Posted by GitBox <gi...@apache.org>.
mcgilman commented on a change in pull request #4416:
URL: https://github.com/apache/nifi/pull/4416#discussion_r459640917



##########
File path: nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/impl/StandardKeyService.java
##########
@@ -118,11 +118,16 @@ public void deleteKey(String identity) {
             transaction = transactionBuilder.start();
 
             // delete the keys
-            DeleteKeysAction deleteKeys = new DeleteKeysAction(identity);
-            transaction.execute(deleteKeys);
-
-            // commit the transaction
-            transaction.commit();
+            DeleteKeyAction deleteKey = new DeleteKeyAction(keyId);
+            Integer rowsDeleted = transaction.execute(deleteKey);
+
+            // commit the transaction if we found one and only one matching keyId/user identity
+            if (rowsDeleted == 1) {

Review comment:
       I believe that the identity is marked as unique [1]. What condition resulted in deleting multiple rows?
   
   [1] https://github.com/apache/nifi/blob/main/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/KeyDataSourceFactoryBean.java#L47




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

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



[GitHub] [nifi] thenatog commented on a change in pull request #4416: NIFI-7568 - Ensure Kerberos mappings are applied correctly

Posted by GitBox <gi...@apache.org>.
thenatog commented on a change in pull request #4416:
URL: https://github.com/apache/nifi/pull/4416#discussion_r459659479



##########
File path: nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/impl/StandardKeyService.java
##########
@@ -118,11 +118,16 @@ public void deleteKey(String identity) {
             transaction = transactionBuilder.start();
 
             // delete the keys
-            DeleteKeysAction deleteKeys = new DeleteKeysAction(identity);
-            transaction.execute(deleteKeys);
-
-            // commit the transaction
-            transaction.commit();
+            DeleteKeyAction deleteKey = new DeleteKeyAction(keyId);
+            Integer rowsDeleted = transaction.execute(deleteKey);
+
+            // commit the transaction if we found one and only one matching keyId/user identity
+            if (rowsDeleted == 1) {

Review comment:
       I don't believe there was a specific condition I knew of, I just wasn't sure. I think the naming and possibly a comment had implied to me it was possible to delete multiple rows using the identity. Sounds like that's not an issue. As such, the method can remain as shown.




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

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



[GitHub] [nifi] alopresto commented on pull request #4416: NIFI-7568 - Ensure Kerberos mappings are applied correctly

Posted by GitBox <gi...@apache.org>.
alopresto commented on pull request #4416:
URL: https://github.com/apache/nifi/pull/4416#issuecomment-663714004


   Also a +1 on this. 


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

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



[GitHub] [nifi] thenatog commented on a change in pull request #4416: NIFI-7568 - Ensure Kerberos mappings are applied correctly

Posted by GitBox <gi...@apache.org>.
thenatog commented on a change in pull request #4416:
URL: https://github.com/apache/nifi/pull/4416#discussion_r459495155



##########
File path: nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/impl/StandardKeyService.java
##########
@@ -118,11 +118,20 @@ public void deleteKey(String identity) {
             transaction = transactionBuilder.start();
 
             // delete the keys
-            DeleteKeysAction deleteKeys = new DeleteKeysAction(identity);
-            transaction.execute(deleteKeys);
-
-            // commit the transaction
-            transaction.commit();
+            DeleteKeyAction deleteKey = new DeleteKeyAction(keyId);
+            Integer rowsDeleted = transaction.execute(deleteKey);
+
+            // commit the transaction if we found one and only one matching user identity
+
+            if (rowsDeleted == 0) {
+                rollback(transaction);
+                throw new AdministrationException("Unable to find user key for key ID " + keyId + " to remove token.");
+            } else if (rowsDeleted > 1) {

Review comment:
       Yeah this is true, keyId refers to the ID column, whereas previously the delete used the identity which theoretically could have been multiple rows. @mcgilman, was there any specific need for the DeleteKey(s) mechanism to delete multiple rows/identities? See changes to StandardKeyDao.java.




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

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



[GitHub] [nifi] thenatog commented on a change in pull request #4416: NIFI-7568 - Ensure Kerberos mappings are applied correctly

Posted by GitBox <gi...@apache.org>.
thenatog commented on a change in pull request #4416:
URL: https://github.com/apache/nifi/pull/4416#discussion_r459635228



##########
File path: nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/impl/StandardKeyService.java
##########
@@ -118,11 +118,16 @@ public void deleteKey(String identity) {
             transaction = transactionBuilder.start();
 
             // delete the keys
-            DeleteKeysAction deleteKeys = new DeleteKeysAction(identity);
-            transaction.execute(deleteKeys);
-
-            // commit the transaction
-            transaction.commit();
+            DeleteKeyAction deleteKey = new DeleteKeyAction(keyId);
+            Integer rowsDeleted = transaction.execute(deleteKey);
+
+            // commit the transaction if we found one and only one matching keyId/user identity
+            if (rowsDeleted == 1) {

Review comment:
       @mcgilman 
   
   This method previously deleted by 'identity', which could potentially delete multiple rows. I've changed it to delete by row/key ID. Could there be side effects for this?




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

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



[GitHub] [nifi] thenatog commented on pull request #4416: NIFI-7568 - Ensure Kerberos mappings are applied correctly

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


   Previous PR and comments here: https://github.com/apache/nifi/pull/4377. As Joe emailed, GitHub actions are failing at the moment but I've verified the full build with contrib-check on both Java 8 and Java 11.
   


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

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



[GitHub] [nifi] bbende commented on a change in pull request #4416: NIFI-7568 - Ensure Kerberos mappings are applied correctly

Posted by GitBox <gi...@apache.org>.
bbende commented on a change in pull request #4416:
URL: https://github.com/apache/nifi/pull/4416#discussion_r459480827



##########
File path: nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/impl/StandardKeyService.java
##########
@@ -118,11 +118,20 @@ public void deleteKey(String identity) {
             transaction = transactionBuilder.start();
 
             // delete the keys
-            DeleteKeysAction deleteKeys = new DeleteKeysAction(identity);
-            transaction.execute(deleteKeys);
-
-            // commit the transaction
-            transaction.commit();
+            DeleteKeyAction deleteKey = new DeleteKeyAction(keyId);
+            Integer rowsDeleted = transaction.execute(deleteKey);
+
+            // commit the transaction if we found one and only one matching user identity
+
+            if (rowsDeleted == 0) {
+                rollback(transaction);
+                throw new AdministrationException("Unable to find user key for key ID " + keyId + " to remove token.");
+            } else if (rowsDeleted > 1) {

Review comment:
       The key table has the following schema:
   ```
   CREATE TABLE KEY (
    ID INT NOT NULL PRIMARY KEY AUTO_INCREMENT, 
    IDENTITY VARCHAR2(4096) NOT NULL UNIQUE, 
    KEY VARCHAR2(100) NOT NULL"
   )
   ```
   Does `keyId` here refer to the `ID` column in this table?
   
   If so, then there could never be multiple rows with the same ID since that column is the primary key of the table.




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

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