Hello,

This is kind of tricky.
When a user has access to a system settings form (say, site-information), but has no permission to see the domain settings form, domain_settings module won't handle the form submission, and the variables will be set globally. Instead, I think that saved settings should stay in current domain.
I don't know if this should be filed as a security issue or not.
I'll provide below a patch on 2.x-dev version.

Regards,

David

Comments

David Stosik’s picture

Status: Active » Needs review
StatusFileSize
new5.4 KB

Here is my first patch.
When user as no domain settings permission, instead of not putting any domain_settings form at all, the form is altered the same way, using the same submit callback, but with a hidden domain_id form item, which is set to a default value (what it would be if displayed).
This way, if an administrator decides that, by default, system settings forms apply to "current domain", then the user will save settings only to current domain.

David Stosik’s picture

Title: When user has no domain settings permission submits system settings forms to all domains » When user has no domain settings permission, system settings forms are submitted to all domains

Fixed title

agentrickard’s picture

Category: bug » feature

The theory is that anyone who has no access to domain settings is *always* working on the default domain.
So this would be a feature / change request and not a bug (nor a security issue).

I'd like to hear what others think about this, since no one has mentioned just this issue before.

David Stosik’s picture

Well, the theory is...

But in practice, it happens that I can be a user with "administer site configuration" permission, but without "access domain settings form".
This way, the system settings forms I submit will affect all domains, including default domain, even if I'm currently working on another domain.

That's really not the expected behavior (in my point of view, which may be biased), and at least, if it's not a bug, it should be a usability issue...

agentrickard’s picture

Priority: Critical » Major

Does that user at least get the proper warning about the form?

agentrickard’s picture

I'm not suggesting this isn't desired behavior. But it is a pretty major *change* in behavior, so one request and patch isn't enough to change it.

pounard’s picture

Priority: Major » Critical

I think this cause serious data consistency problems. Some user modifies the configuration while browsing on a specific domain but the system changes the global site configuration instead: this doesn't make any sense.

Because a user cannot access a specific domain (let's say level 1 configuration), he can break without remorse the hosting site configuration (let's call it level 0): it's all backwards!

It sounds like "User A cannot remove content 1 on site A, but he can remove ALL content on site B that shares content with site A, the conclusion is he finally can remove the content 1", it is a real problem IMHO.

If the user cannot access the domain configuration, but he is actually browsing on the domain, it should never changes the hosting plateform configuration: he should, in the worst case scenario, have an empty form or an error message to warn him.

David Stosik’s picture

agentrickard : no warning at all, as Domain Settings just falls back to default behaviour if user has not access to domain settings form...

agentrickard’s picture

Right, the assumption has always been that you would never configure your site permissions in this way.

That is, anyone who can 'configure site information' is a super-user and should have domain permissions as well. Alternately, Domain Settings is not appropriate for your site.

I see three options:

1) Reject the change

2) Implement the change as a configuration option, so that the new behavior may be enabled, but is not on by default.

3) Implement the change so this behavior happens by default, but add some messaging in the UI that makes clear what is happening.

With Domain Conf, we issue a warning about domain-sensitive forms. That warning, however, is removed by Domain Settings (so maybe we should only do that if the user has proper permission).

David Stosik’s picture

I should add that my patch does not force to save settings only to current domain if user can't see "domain settings form". Instead, it uses the "Default form value when submitting system settings" set in admin/structure/domain/settings.

This, maybe, could be considered as a bug ? When the form is not displayed, should Domain Settings save settings to all domains (which is actually the case), or should it use this "Default form value when submitting system settings" (which I suggest with my patch) ?

agentrickard’s picture

Version: 7.x-2.x-dev » 7.x-3.x-dev

Bumping versions. In 7.x.3, we can simply commit this as a change.

David Stosik’s picture

StatusFileSize
new5.18 KB

3.x port.

agentrickard’s picture

How does this compare to #809128: Restrict settings form to users with domain access? Does it work when both are applied?

David Stosik’s picture

Indeed, the problems this other issue raises are interesting. I ported the associated patch 3.x then improved it a bit (see #809128: Restrict settings form to users with domain access).
I'm affraid both patches couldn't be applied one over the other, that's why I wrote a final patch, including modified patch in #12 and last patch in #809128: Restrict settings form to users with domain access (comment #9).

This "ultimate patch" is attached, and here is a summary of its effects :

  • DS form* only displays the domains that current user has access to (if current user has "administer domains" permission, then all domains are displayed).
  • DS form displays "All domains" option only if current user has "administer domains" permission.
  • DS form has a default value fallback system : if only one available value, then it's the default, if many values are available, and a default could not be determined using configuration, then current domain is default.
  • If current user has not "access domain settings form" permission, then the form is hidden, and the previously computed default value is used.

* DS form is Domain Settings form, abbreviated.

This prevents many flaws, such as saving settings to a domain I don't have access to, or saving to all domains while not having the permission. This also prevents from bypassing domain_settings module when having permission to access system settings form, but not the permission to "access domain settings form".

Regards,

David

agentrickard’s picture

Patch the checks the code logic, fixes a weight error, and correct some style issues.

Updated the @fixme in the previous patch to stop the alter if the user has no access to $default. Odd but probably proper.

David Stosik’s picture

I don't agree on this

  // If the user does not have access to this domain, stop now and allow the
  // normal form processing to occur.
  if (!isset($user_domains[$default])) {
    return;
   }

First because a user who has "administer domains" may not have current domain in its domains.
Next, I think that domain_settings should never disappear and let the form unaltered (which would mean letting the user save to all domains, without any check).

There are, indeed, ways to display a DS form where no suitable default is available. For example, when domain login is not restricted, users may possibly login on a domain they've not been assigned. But in such a case, is it normal, and secure, to let them save administration settings to all domains ? I think not.
Instead, I think that the user should be displayed the DS form, without any default selected. This way, he will have to confirm his choice by explicitly choosing a domain.

If user can't display the form (no "access domain settings form" permission) though, something must be done.
But failing to manage by-domain settings is not an acceptable solution. So what's about it ?

The last fall-back situation :

  • user has not the permission to see the DS form (and thus to select the target domain)
  • user has not been assigned the current domain, leading to failure to determine a default value
  • still, user has access to the settings form

What kind of solution :

  1. Throw "Access Denied" to user, although he should have access to the settings form ?
  2. Display the computed DS form, telling the user the proper domain where to save could not be defined ?
  3. Save to current domain, ignoring that current user is not assigned to current domain ? (After all, he's been granted login on this domain, and has access to the settings form.)
  • Adding to above propositions, a message could be logged, to tell the administrator that something may be wrong with the site's configuration...

None of these sound extremely good to me, but those solutions sound better than "do nothing and save globally" option to my ears. My preference goes in this order : 3, 1, 2.

Regards,

David

agentrickard’s picture

Status: Needs review » Needs work

Points:

-- The user with 'administer domains' gets $user_domains set to all domains earlier in the code. If that isn't set properly via array_keys(), then that code needs to be changed.

-- It would not save to all domains, just the primary domain (default behavior of the form, which is the current behavior without this patch).

-- We have a bigger problem with certain admin forms that are never affected by Domain Settings, since they don't use system_settings_form() at all (e.g. Date and Timezone handling). These will just lead to mass confusion.

I'm still very iffy on this patch. Domain Settings is a module for power users. If it causes problems for other classes of user, people simply shouldn't use it.

Of the options above, I think #3 is best.

And I'd still like to see some sort of warning message to the user.

David Stosik’s picture

Status: Needs work » Needs review
StatusFileSize
new6.79 KB

Answering to your points :
- That's true, I forgot about that. ^^'
- Well, saving to "primary domain" also means saving to all domains that have no specific setting yet.
- That's true, but is there anything doable for these ? I guess not...

Attached patch adds following improvements to previous patch :
- as a last fall-back, default to current domain, only if DS form is hidden (if DS form is displayed, it can have no default value, forcing user to chose one)
- when DS form is hidden, display a warning message telling the user wich domain the settings will be saved to.

Regards,

David

agentrickard’s picture

Excellent.

I'd still like to get some other opinions here.

David Stosik’s picture

No opinions on this one ?
Patch still applies on last dev version. ;)

twistor’s picture

I just ran into this today. My thought was that after turning off Domain Settings access to a user, the settings form would default to the current domain.

On a related note, it would also make sense if the DS form defaulted to the current domain, rather than the default. I have been bitten by this twice today already.

Patch test coming in a bit.

David Stosik’s picture

It's possible to default to the current domain if the form is displayed. There's a setting for this in Domain Access. ;)
And my patch allow to follow that default setting, even if form is not displayed.

labor b’s picture

Issue summary: View changes

+1 for David's solution

The form displays the settings of the current domain, but stores them for the primary domain. I consider myself a power user and it still confused me. Actually I didn't ever think about storing to the primary domain from some other domain without explicitly selecting this and no warning whatsoever.

bluegeek9’s picture

Component: - Domain Settings » Code
Status: Needs review » Closed (outdated)

Drupal 7 in End of Life and no longer supported. We encourage you to upgrade to a supported version of Drupal. For more information, see https://www.drupal.org/upgrade.

//www.flaticon.com/free-icons/thank-you Thank you for your contribution! Your continued support of this project makes other volunteer contributions more sustainable.
There are multiple ways to show appreciation for the work contributed to this project, including:
  • Triaging issues and adding more context to existing issues.
  • Writing documentation or patches for this project.