Bug 1412209

Summary: Local user disappears from user-group with external group
Product: Red Hat Satellite Reporter: Jiri Vavra <jivavra>
Component: LDAPAssignee: Daniel Lobato Garcia <dlobatog>
Status: CLOSED ERRATA QA Contact: Sanket Jagtap <sjagtap>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.2.0CC: bbuckingham, dhlavacd, egolov, jcallaha, mhulan, sjagtap
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: foreman-1.15.6.9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-02-21 16:54:37 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
user group UI none

Description Jiri Vavra 2017-01-11 14:21:30 UTC
Description of problem:
When attaching local user to user-group where is already set external group from LDAP, the user disappears when clicked on Submit button. When used hammer, the user disappears after
# foreman-rake ldap:refresh_usergroups
No error shown in WebUI/hammer/production.log

Version-Release number of selected component (if applicable):
Satellite 6.2

How reproducible:
100%

Steps to Reproduce:
1. Set up LDAP authentication.
2. Create a user-group and in third tab "External groups" specify some external group. Submit.
3. Edit the user-group and add some local user.

Actual results:
In WebUI: local user is not saved. 
With hammer: user disappears later

~~~
# hammer user-group add-user --name 'Group Test' --user user_test
The user has been associated
# hammer user info --login user_test | grep -A1 'User groups'
User groups:
    Group Test
# sudo -u foreman /usr/sbin/foreman-rake ldap:refresh_usergroups
Successfully decrypted field for AuthSourceLdap LDAP-test
# hammer user info --login user_test | grep -A1 'User groups'
User groups:

~~~

Expected results:
- User can be added to group with External group
- OR local users are not available in list of users
- OR print error that it's not possible and write it to log

Additional info:
Workaround - create user-group with external group. Than create another "composite" user-group which will contain both local users and user-group with external group.

Comment 1 Marek Hulan 2017-01-11 16:14:35 UTC
The reason is likely that we don't check auth source of user when we refresh the user group. We should probably only manipulate users with auth source defined in external user group mapping.

Comment 2 Daniel Lobato Garcia 2017-01-12 22:41:29 UTC
It's expected - the moment you have external user groups in a user group, Satellite will only put users from the external user group there. 

A good workaround for this would be to display some message explaining this and block users from being added manually when you have external user groups. I would expect this for 6.3 though

Comment 4 Daniel Lobato Garcia 2017-10-30 09:50:35 UTC
Created redmine issue http://projects.theforeman.org/issues/21502 from this bug

Comment 5 Satellite Program 2017-11-14 13:16:05 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/21502 has been resolved.

Comment 6 Sanket Jagtap 2018-01-04 10:25:58 UTC
Build: Satellite 6.3.0 snap 30 

Created a Ldap Auth source 
Associated a user group with auth source 
Created a Internal user and associated it with created user group


hammer user list
hammer user info ---|-------|------------|------------------------------------|-------|---------------------|--------------
ID | LOGIN | NAME       | EMAIL                              | ADMIN | LAST LOGIN          | AUTHORIZED BY
---|-------|------------|------------------------------------|-------|---------------------|--------------
3  | admin | Admin User | root@ | yes   | 2018/01/04 10:15:42 | Internal     
7  | Ohno  | Oh no      | Ohno                      | no    | 2018/01/04 10:18:08 | Internal     
---|-------|------------|------------------------------------|-------|---------------------|--------------
[root@qe-capsule-feature-rhel6 ~]# hammer user info --id 7
Id:                    7
Login:                 Ohno
Name:                  Oh no
Email:                 Ohno
Admin:                 no
Last login:            2018/01/04 10:18:08
Authorized by:         Internal
Effective admin:       no
Locale:                default
Timezone:              
Description:           
Default organization:  
Default location:      
Roles:                 

User groups:           
 1) Usergroup: idm
    Roles:     
        Site manager
        Compliance viewer
        Compliance manager
Inherited User groups: 

Locations:             
    Default Location
Organizations:         
    Default Organization
Created at:            2018/01/04 10:16:53
Updated at:            2018/01/04 10:16:53
hammer> user-group info --id 1
Id:                    1
Name:                  idm
Admin:                 no
Users:                 
    Ohno
User groups:           

Inherited User groups: 
 1) Usergroup: 
    Roles:
External user groups:  
    foobargroup
Roles:                 
    Site manager
    Compliance viewer
    Compliance manager
Created at:            2017/12/26 13:58:04
Updated at:            2017/12/26 13:58:04

Comment 7 Sanket Jagtap 2018-01-04 10:26:55 UTC
Created attachment 1376782 [details]
user group UI

Comment 8 Satellite Program 2018-02-21 16:54:37 UTC
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA.
> > 
> > For information on the advisory, and where to find the updated files, follow the link below.
> > 
> > If the solution does not work for you, open a new bug report.
> > 
> > https://access.redhat.com/errata/RHSA-2018:0336