[ 
https://issues.apache.org/jira/browse/NIFI-1884?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15289562#comment-15289562
 ] 

ASF GitHub Bot commented on NIFI-1884:
--------------------------------------

Github user bbende commented on the pull request:

    https://github.com/apache/nifi/pull/452#issuecomment-220121052
  
    @alopresto The intent was for the relationship to be bi-directional, 
meaning you could add a user to a group by adding/updating a User with a new 
group id in the set of groups, or by adding/updating a Group with a new user id 
in the set of users.
    
    The overall idea was to retrieve an object, make a copy of it with the 
desired changes, and then call update. So for the example scenarios...
    
    - You could do this two different ways, but one would be to create a new 
Group instance with name "Admins" and no users and call addGroup(), then create 
a new User instance with name "Bryan Bende" and a set of group ids containing 
the id of the "Admins" group and call addUser()
    
    -  Same as above to create the group and user and place the user in the 
group... then you would retrieve the User instance for "Andrew LoPresto", make 
a copy of that User instance with the name set to "Andy LoPrestro" and call 
updateUser(...)
    
    - Same as scenario 1 to create the group and users and place the users in 
the group, although to add both users to the group in one action you could 
retrieve the Group, make a copy of the Group and add both user ids to the set 
of users, and call updateGroup(). Removing "Bryan Bende" from "Admins" could be 
done by copying the Group without "Bryan Bende"s id in the set of users and 
calling updateGroup, or by copying the User for "Bryan Bende" without the id of 
the "Admin" group in the set of groups and calling updateUser().
    
    After thinking about all of these, it seems like it would nice to have 
builders that made it convenient for updating a User or Group... So something 
like...
    
    ```
    User user = authorizer.getUser(id);
    User updatedUser = new User.UserBuilder().fromUser(user).name("New 
Name").build();
    authorizer.updateUser(updatedUser);
    ```
    Also easily removing entries, so something like this for removing a user 
from a group:
    
    ```
    User user = authorizer.getUser(id);
    User updatedUser = new 
User.UserBuilder().fromUser(user).removeGroup(groupId).build();
    authorizer.updateUser(updatedUser);
    ```
    Thoughts?


> Add User & Group API
> --------------------
>
>                 Key: NIFI-1884
>                 URL: https://issues.apache.org/jira/browse/NIFI-1884
>             Project: Apache NiFi
>          Issue Type: Sub-task
>          Components: Core Framework
>            Reporter: Bryan Bende
>            Assignee: Bryan Bende
>            Priority: Minor
>             Fix For: 1.0.0
>
>
> Define the API for  managing users, groups, and policies.
> This is to advance the work described in this feature proposal:
>  https://cwiki.apache.org/confluence/display/NIFI/Support+Authorizer+API
> The parent JIRA for all authorization work is NIFI-1550.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to