Skip to content

Commit

Permalink
NAS-125067 / 24.04 / Always allow authenticated users to set webui pr…
Browse files Browse the repository at this point in the history
…efs (#12453)

The attributes dictionary contains webui preferences as determined
by the UI team. Users should be able to write to their own settings
regardless of privileges granted to them.
  • Loading branch information
anodos325 authored Nov 6, 2023
1 parent 0e98457 commit b49f704
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/middlewared/middlewared/plugins/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ async def me(self, app):

return {**user, 'attributes': attributes}

@no_authz_required
@accepts(
Str('key'),
Any('value'),
Expand Down
8 changes: 8 additions & 0 deletions tests/api2/test_account_privilege_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,11 @@ def test_readonly_can_not_call_method():
c.call("filesystem.mkdir", "/foo")

assert ve.value.errno == errno.EACCES


def test_limited_user_can_set_own_attributes():
with unprivileged_user_client(["READONLY"]) as c:
c.call("auth.set_attribute", "foo", "bar")
attrs = c.call("auth.me")["attributes"]
assert "foo" in attrs
assert attrs["foo"] == "bar"

0 comments on commit b49f704

Please sign in to comment.