You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
OAuth users are automatically assigned with user role #14454
Is the setting Merge Roles from SSO = true by chance? thinking
Yes you're right. If I set Merge Roles from SSO = false, OAuth user just get the "user" role.
Maybe I'm not doing it the right way. I need a specific role ("guest") for users coming from OAtuh service. This role must not create channel, group or direct message.
Other users (LDAP auth) have the default role "user".
Ok, to sum up, "Default roles for authentication services" is set to "user". So, all my LDAP users inherit "user" role, that's what I want.
By adding an OAuth service with "roles/groups field name" set (OAuth send me "guest") :
"Merge role from SSO: false" : OAuth users have "user" role. Not good, I expect "guest" role
"Merge role from SSO: true" : OAuth users have "guest, user" roles for the first connection then only "guest" for the next connection. That's almost what I'm looking for excepted for the first connection, even with this PR
I don't figured out if there's some kind of bug or if I misunderstood the "Merge role from SSO" option. Maybe the solution will come from this PR to separate roles given for LDAP and OAuth ?
If you don't want to merge role from SSO = "Merge role from SSO: false", SSO users must only have the role defined by the SSO
If you do want to merge role from SSO = "Merge role from SSO: true", SSO users must have the role defined by the SSO and the default one set by "Default roles for authentication services"
Sure, but the option "Merge role from SSO: false" must override the "Default roles for authentication services" or I don't understand the point to keep this option.
I've just found that roles other than the ones coming from OAuth service are correctly removed for the second connection by this method updateRolesFromSSO() in oauth_helpers.js :
const toRemove = user.roles.filter((val) => !rolesFromSSO.includes(val));
// loop through roles that user has that sso doesnt have and remove
toRemove.forEach(function(role) {
removeUserFromRoles(user._id, role);
});
The problem is that this method is called before the user's creation instead of being called after user's creation.
I've just found that roles other than the ones coming from OAuth service are correctly removed for the second connection by this method updateRolesFromSSO() in oauth_helpers.js :
const toRemove = user.roles.filter((val) => !rolesFromSSO.includes(val));
// loop through roles that user has that sso doesnt have and remove
toRemove.forEach(function(role) {
removeUserFromRoles(user._id, role);
});
The problem is that this method is called before the user's creation instead of being called after user's creation.
Activity
magicbelette commentedon May 10, 2019
For the 2nd connection with OAuth service, user looses the "user" role. So it seems to be related to the user creation process.
MarcosSpessatto commentedon May 10, 2019
@magicbelette I think this PR should solve the problem.
magicbelette commentedon May 13, 2019
Unfortunately, new users still have "user" role after patching my instance.
MarcosSpessatto commentedon May 13, 2019
@magicbelette What OAuth service are you using?
magicbelette commentedon May 13, 2019
A custom one
MarcosSpessatto commentedon May 13, 2019
Is the setting
Merge Roles from SSO = trueby chance? 🤔magicbelette commentedon May 14, 2019
Yes you're right. If I set
Merge Roles from SSO = false, OAuth user just get the "user" role.Maybe I'm not doing it the right way. I need a specific role ("guest") for users coming from OAtuh service. This role must not create channel, group or direct message.
Other users (LDAP auth) have the default role "user".
Thx for your help
MarcosSpessatto commentedon May 14, 2019
@magicbelette Can we close this?
magicbelette commentedon May 14, 2019
Sorry but it isn't clear for me...
Main users are coming from LDAP with role "user", can I automatically assign a different role to OAuth users ?
MarcosSpessatto commentedon May 14, 2019
@magicbelette yes, if you need assign roles to users coming from Oauth services, you can set in this fields.

magicbelette commentedon May 14, 2019
Ok, to sum up, "Default roles for authentication services" is set to "user". So, all my LDAP users inherit "user" role, that's what I want.
By adding an OAuth service with "roles/groups field name" set (OAuth send me "guest") :
I don't figured out if there's some kind of bug or if I misunderstood the "Merge role from SSO" option. Maybe the solution will come from this PR to separate roles given for LDAP and OAuth ?
MarcosSpessatto commentedon May 14, 2019
Reading what you have detailed now, I think the PR that separate roles should solve your problem. What do you think?
magicbelette commentedon May 21, 2019
Unfortunately not, cause the PR that separate roles implies that all of my 90K users belongs to the same LDAP group.
I think that the problem is with this PR.
geekgonecrazy commentedon May 22, 2019
I think this might be key... this user role is getting set from here for all services, not just ldap
magicbelette commentedon May 28, 2019
Sure, but the option "Merge role from SSO: false" must override the "Default roles for authentication services" or I don't understand the point to keep this option.
magicbelette commentedon Jun 4, 2019
I've just found that roles other than the ones coming from OAuth service are correctly removed for the second connection by this method updateRolesFromSSO() in oauth_helpers.js :
The problem is that this method is called before the user's creation instead of being called after user's creation.
Any idea on how to (nicely) solve this ?
magicbelette commentedon Jun 11, 2019
Any idea @rodrigok ?