-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Passing user roles from query originator to other nodes #42537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
42153a8
fe1a932
9eb6207
c9e0cc6
872f073
2cf7aeb
63e4e30
0458879
cb9dd71
558c806
48005b8
57d06cf
65c233f
df2aab5
8cbf0c2
ed5cc7b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| version: '2.3' | ||
|
|
||
| services: | ||
| openldap: | ||
| image: osixia/openldap:1.4.0 | ||
| command: "--copy-service --loglevel debug" | ||
| environment: | ||
| LDAP_ORGANIZATION: "company" | ||
| LDAP_DOMAIN: "company.com" | ||
| LDAP_ADMIN_PASSWORD: "admin" | ||
| LDAP_TLS: "false" | ||
| volumes: | ||
| - ${LDAP_DIR}/../configs/ldap:/container/service/slapd/assets/config/bootstrap/ldif/custom | ||
| expose: | ||
| - "389" | ||
| - "636" | ||
| healthcheck: | ||
| test: ldapsearch -x -H ldap://localhost:$${LDAP_PORT:-389} -b "dc=company,dc=com" -D "cn=admin,dc=company,dc=com" -w admin | ||
| interval: 10s | ||
| timeout: 10s | ||
| retries: 3 | ||
| start_period: 300s | ||
| security_opt: | ||
| - label:disable |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -299,6 +299,7 @@ void ContextAccess::setUser(const UserPtr & user_) const | |
| current_roles = user->granted_roles.findGranted(params.current_roles); | ||
| current_roles_with_admin_option = user->granted_roles.findGrantedWithAdminOption(params.current_roles); | ||
| } | ||
| current_roles.insert(current_roles.end(), params.external_roles.begin(), params.external_roles.end()); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't feel right to add roles to |
||
|
|
||
| subscription_for_roles_changes.reset(); | ||
| enabled_roles = access_control->getEnabledRoles(current_roles, current_roles_with_admin_option); | ||
|
|
@@ -424,7 +425,6 @@ std::shared_ptr<const ContextAccess> ContextAccess::getFullAccess() | |
| return res; | ||
| } | ||
|
|
||
|
|
||
| SettingsChanges ContextAccess::getDefaultSettings() const | ||
| { | ||
| std::lock_guard lock{mutex}; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,7 +26,6 @@ namespace ErrorCodes | |
| extern const int BAD_ARGUMENTS; | ||
| } | ||
|
|
||
|
|
||
| LDAPAccessStorage::LDAPAccessStorage(const String & storage_name_, AccessControl & access_control_, const Poco::Util::AbstractConfiguration & config, const String & prefix) | ||
| : IAccessStorage(storage_name_), access_control(access_control_), memory_storage(storage_name_, access_control.getChangesNotifier(), false) | ||
| { | ||
|
|
@@ -320,6 +319,10 @@ std::set<String> LDAPAccessStorage::mapExternalRolesNoLock(const LDAPClient::Sea | |
| { | ||
| std::set<String> role_names; | ||
|
|
||
| // If this node can't access LDAP server (or has not privileges to fetch roles) and gets empty list of external roles | ||
| if (external_roles.size() == 0) | ||
| return role_names; | ||
|
|
||
| if (external_roles.size() != role_search_params.size()) | ||
| throw Exception(ErrorCodes::BAD_ARGUMENTS, "Unable to map external roles"); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if it gets a list of external roles from the initiator, but the configuration file is not the same here so |
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems it's more generic to always use current roles instead of external roles. I mean we could kind of pack
current_rolesandexternal_roleshere together. When we connect to another server and sendinitial_user, we can send it along withinitial_user's current roles. And then on another serverTCPHandlerwill get those roles and use them instead of user's default roles inContext::setUser(). AndLDAPAccessStorageon another server will also use the initial user's current roles to add them toUser::granted_roles. What do you think?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And that would also allow another server to understand changes in current roles. For example,
so another server would understand that current roles are
role1androle2even if the initial user has more granted roles.