Software /
code /
prosody
Annotate
spec/scansion/muc_subject_issue_667.scs @ 12642:9061f9621330
Switch to a new role-based authorization framework, removing is_admin()
We began moving away from simple "is this user an admin?" permission checks
before 0.12, with the introduction of mod_authz_internal and the ability to
dynamically change the roles of individual users.
The approach in 0.12 still had various limitations however, and apart from
the introduction of roles other than "admin" and the ability to pull that info
from storage, not much actually changed.
This new framework shakes things up a lot, though aims to maintain the same
functionality and behaviour on the surface for a default Prosody
configuration. That is, if you don't take advantage of any of the new
features, you shouldn't notice any change.
The biggest change visible to developers is that usermanager.is_admin() (and
the auth provider is_admin() method) have been removed. Gone. Completely.
Permission checks should now be performed using a new module API method:
module:may(action_name, context)
This method accepts an action name, followed by either a JID (string) or
(preferably) a table containing 'origin'/'session' and 'stanza' fields (e.g.
the standard object passed to most events). It will return true if the action
should be permitted, or false/nil otherwise.
Modules should no longer perform permission checks based on the role name.
E.g. a lot of code previously checked if the user's role was prosody:admin
before permitting some action. Since many roles might now exist with similar
permissions, and the permissions of prosody:admin may be redefined
dynamically, it is no longer suitable to use this method for permission
checks. Use module:may().
If you start an action name with ':' (recommended) then the current module's
name will automatically be used as a prefix.
To define a new permission, use the new module API:
module:default_permission(role_name, action_name)
module:default_permissions(role_name, { action_name[, action_name...] })
This grants the specified role permission to execute the named action(s) by
default. This may be overridden via other mechanisms external to your module.
The built-in roles that developers should use are:
- prosody:user (normal user)
- prosody:admin (host admin)
- prosody:operator (global admin)
The new prosody:operator role is intended for server-wide actions (such as
shutting down Prosody).
Finally, all usage of is_admin() in modules has been fixed by this commit.
Some of these changes were trickier than others, but no change is expected to
break existing deployments.
EXCEPT: mod_auth_ldap no longer supports the ldap_admin_filter option. It's
very possible nobody is using this, but if someone is then we can later update
it to pull roles from LDAP somehow.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 15 Jun 2022 12:15:01 +0100 |
parent | 9708:6507df6d2c55 |
child | 13414:d54364746a7c |
rev | line source |
---|---|
9685 | 1 # #667 MUC message with subject and body SHALL NOT be interpreted as a subject change |
2 | |
3 [Client] Romeo | |
4 password: password | |
5 jid: romeo@localhost | |
6 | |
7 ----- | |
8 | |
9 Romeo connects | |
10 | |
11 # and creates a room | |
12 Romeo sends: | |
13 <presence to="issue667@conference.localhost/Romeo"> | |
14 <x xmlns="http://jabber.org/protocol/muc"/> | |
15 </presence> | |
16 | |
17 Romeo receives: | |
18 <presence from="issue667@conference.localhost/Romeo"> | |
19 <x xmlns="http://jabber.org/protocol/muc#user"> | |
20 <status code="201"/> | |
21 <item affiliation="owner" role="moderator" jid="${Romeo's full JID}"/> | |
22 <status code="110"/> | |
23 </x> | |
24 </presence> | |
25 | |
9707
9171eddcce93
MUC: Add descriptive comments to #667 test
Kim Alvefur <zash@zash.se>
parents:
9706
diff
changeset
|
26 # the default (empty) subject |
9685 | 27 Romeo receives: |
28 <message type="groupchat" from="issue667@conference.localhost"> | |
29 <subject/> | |
30 </message> | |
31 | |
9707
9171eddcce93
MUC: Add descriptive comments to #667 test
Kim Alvefur <zash@zash.se>
parents:
9706
diff
changeset
|
32 # this should be treated as a normal message |
9685 | 33 Romeo sends: |
34 <message to="issue667@conference.localhost" type="groupchat"> | |
35 <subject>Greetings</subject> | |
36 <body>Hello everyone</body> | |
37 </message> | |
38 | |
39 Romeo receives: | |
40 <message type="groupchat" from="issue667@conference.localhost/Romeo"> | |
41 <subject>Greetings</subject> | |
42 <body>Hello everyone</body> | |
43 </message> | |
44 | |
9708
6507df6d2c55
MUC: Test that subject is still empty after sending a non-subject change message with a subject (#667)
Kim Alvefur <zash@zash.se>
parents:
9707
diff
changeset
|
45 # Resync |
6507df6d2c55
MUC: Test that subject is still empty after sending a non-subject change message with a subject (#667)
Kim Alvefur <zash@zash.se>
parents:
9707
diff
changeset
|
46 Romeo sends: |
6507df6d2c55
MUC: Test that subject is still empty after sending a non-subject change message with a subject (#667)
Kim Alvefur <zash@zash.se>
parents:
9707
diff
changeset
|
47 <presence to="issue667@conference.localhost/Romeo"> |
6507df6d2c55
MUC: Test that subject is still empty after sending a non-subject change message with a subject (#667)
Kim Alvefur <zash@zash.se>
parents:
9707
diff
changeset
|
48 <x xmlns="http://jabber.org/protocol/muc"/> |
6507df6d2c55
MUC: Test that subject is still empty after sending a non-subject change message with a subject (#667)
Kim Alvefur <zash@zash.se>
parents:
9707
diff
changeset
|
49 </presence> |
6507df6d2c55
MUC: Test that subject is still empty after sending a non-subject change message with a subject (#667)
Kim Alvefur <zash@zash.se>
parents:
9707
diff
changeset
|
50 |
6507df6d2c55
MUC: Test that subject is still empty after sending a non-subject change message with a subject (#667)
Kim Alvefur <zash@zash.se>
parents:
9707
diff
changeset
|
51 # Presences |
6507df6d2c55
MUC: Test that subject is still empty after sending a non-subject change message with a subject (#667)
Kim Alvefur <zash@zash.se>
parents:
9707
diff
changeset
|
52 Romeo receives: |
6507df6d2c55
MUC: Test that subject is still empty after sending a non-subject change message with a subject (#667)
Kim Alvefur <zash@zash.se>
parents:
9707
diff
changeset
|
53 <presence from="issue667@conference.localhost/Romeo"> |
6507df6d2c55
MUC: Test that subject is still empty after sending a non-subject change message with a subject (#667)
Kim Alvefur <zash@zash.se>
parents:
9707
diff
changeset
|
54 <x xmlns="http://jabber.org/protocol/muc#user"> |
6507df6d2c55
MUC: Test that subject is still empty after sending a non-subject change message with a subject (#667)
Kim Alvefur <zash@zash.se>
parents:
9707
diff
changeset
|
55 <item affiliation="owner" role="moderator" jid="${Romeo's full JID}"/> |
6507df6d2c55
MUC: Test that subject is still empty after sending a non-subject change message with a subject (#667)
Kim Alvefur <zash@zash.se>
parents:
9707
diff
changeset
|
56 <status code="110"/> |
6507df6d2c55
MUC: Test that subject is still empty after sending a non-subject change message with a subject (#667)
Kim Alvefur <zash@zash.se>
parents:
9707
diff
changeset
|
57 </x> |
6507df6d2c55
MUC: Test that subject is still empty after sending a non-subject change message with a subject (#667)
Kim Alvefur <zash@zash.se>
parents:
9707
diff
changeset
|
58 </presence> |
6507df6d2c55
MUC: Test that subject is still empty after sending a non-subject change message with a subject (#667)
Kim Alvefur <zash@zash.se>
parents:
9707
diff
changeset
|
59 |
6507df6d2c55
MUC: Test that subject is still empty after sending a non-subject change message with a subject (#667)
Kim Alvefur <zash@zash.se>
parents:
9707
diff
changeset
|
60 Romeo receives: |
6507df6d2c55
MUC: Test that subject is still empty after sending a non-subject change message with a subject (#667)
Kim Alvefur <zash@zash.se>
parents:
9707
diff
changeset
|
61 <message type="groupchat" from="issue667@conference.localhost/Romeo"> |
6507df6d2c55
MUC: Test that subject is still empty after sending a non-subject change message with a subject (#667)
Kim Alvefur <zash@zash.se>
parents:
9707
diff
changeset
|
62 <subject>Greetings</subject> |
6507df6d2c55
MUC: Test that subject is still empty after sending a non-subject change message with a subject (#667)
Kim Alvefur <zash@zash.se>
parents:
9707
diff
changeset
|
63 <body>Hello everyone</body> |
6507df6d2c55
MUC: Test that subject is still empty after sending a non-subject change message with a subject (#667)
Kim Alvefur <zash@zash.se>
parents:
9707
diff
changeset
|
64 </message> |
6507df6d2c55
MUC: Test that subject is still empty after sending a non-subject change message with a subject (#667)
Kim Alvefur <zash@zash.se>
parents:
9707
diff
changeset
|
65 |
6507df6d2c55
MUC: Test that subject is still empty after sending a non-subject change message with a subject (#667)
Kim Alvefur <zash@zash.se>
parents:
9707
diff
changeset
|
66 # the still empty subject |
6507df6d2c55
MUC: Test that subject is still empty after sending a non-subject change message with a subject (#667)
Kim Alvefur <zash@zash.se>
parents:
9707
diff
changeset
|
67 Romeo receives: |
6507df6d2c55
MUC: Test that subject is still empty after sending a non-subject change message with a subject (#667)
Kim Alvefur <zash@zash.se>
parents:
9707
diff
changeset
|
68 <message type="groupchat" from="issue667@conference.localhost"> |
6507df6d2c55
MUC: Test that subject is still empty after sending a non-subject change message with a subject (#667)
Kim Alvefur <zash@zash.se>
parents:
9707
diff
changeset
|
69 <subject/> |
6507df6d2c55
MUC: Test that subject is still empty after sending a non-subject change message with a subject (#667)
Kim Alvefur <zash@zash.se>
parents:
9707
diff
changeset
|
70 </message> |
6507df6d2c55
MUC: Test that subject is still empty after sending a non-subject change message with a subject (#667)
Kim Alvefur <zash@zash.se>
parents:
9707
diff
changeset
|
71 |
9707
9171eddcce93
MUC: Add descriptive comments to #667 test
Kim Alvefur <zash@zash.se>
parents:
9706
diff
changeset
|
72 # this is a subject change |
9685 | 73 Romeo sends: |
74 <message to="issue667@conference.localhost" type="groupchat"> | |
75 <subject>Something to talk about</subject> | |
76 </message> | |
77 | |
78 Romeo receives: | |
79 <message type="groupchat" from="issue667@conference.localhost/Romeo"> | |
80 <subject>Something to talk about</subject> | |
81 </message> | |
82 | |
9707
9171eddcce93
MUC: Add descriptive comments to #667 test
Kim Alvefur <zash@zash.se>
parents:
9706
diff
changeset
|
83 # a message without <subject> |
9685 | 84 Romeo sends: |
9706
d3c2c9248734
MUC: Add another message to #667 test
Kim Alvefur <zash@zash.se>
parents:
9685
diff
changeset
|
85 <message to="issue667@conference.localhost" type="groupchat"> |
d3c2c9248734
MUC: Add another message to #667 test
Kim Alvefur <zash@zash.se>
parents:
9685
diff
changeset
|
86 <body>Lorem ipsum dolor sit amet</body> |
d3c2c9248734
MUC: Add another message to #667 test
Kim Alvefur <zash@zash.se>
parents:
9685
diff
changeset
|
87 </message> |
d3c2c9248734
MUC: Add another message to #667 test
Kim Alvefur <zash@zash.se>
parents:
9685
diff
changeset
|
88 |
d3c2c9248734
MUC: Add another message to #667 test
Kim Alvefur <zash@zash.se>
parents:
9685
diff
changeset
|
89 Romeo receives: |
d3c2c9248734
MUC: Add another message to #667 test
Kim Alvefur <zash@zash.se>
parents:
9685
diff
changeset
|
90 <message type="groupchat" from="issue667@conference.localhost/Romeo"> |
d3c2c9248734
MUC: Add another message to #667 test
Kim Alvefur <zash@zash.se>
parents:
9685
diff
changeset
|
91 <body>Lorem ipsum dolor sit amet</body> |
d3c2c9248734
MUC: Add another message to #667 test
Kim Alvefur <zash@zash.se>
parents:
9685
diff
changeset
|
92 </message> |
d3c2c9248734
MUC: Add another message to #667 test
Kim Alvefur <zash@zash.se>
parents:
9685
diff
changeset
|
93 |
9707
9171eddcce93
MUC: Add descriptive comments to #667 test
Kim Alvefur <zash@zash.se>
parents:
9706
diff
changeset
|
94 # Resync |
9706
d3c2c9248734
MUC: Add another message to #667 test
Kim Alvefur <zash@zash.se>
parents:
9685
diff
changeset
|
95 Romeo sends: |
9685 | 96 <presence to="issue667@conference.localhost/Romeo"> |
97 <x xmlns="http://jabber.org/protocol/muc"/> | |
98 </presence> | |
99 | |
9707
9171eddcce93
MUC: Add descriptive comments to #667 test
Kim Alvefur <zash@zash.se>
parents:
9706
diff
changeset
|
100 # Presences |
9685 | 101 Romeo receives: |
102 <presence from="issue667@conference.localhost/Romeo"> | |
103 <x xmlns="http://jabber.org/protocol/muc#user"> | |
104 <item affiliation="owner" role="moderator" jid="${Romeo's full JID}"/> | |
105 <status code="110"/> | |
106 </x> | |
107 </presence> | |
108 | |
9707
9171eddcce93
MUC: Add descriptive comments to #667 test
Kim Alvefur <zash@zash.se>
parents:
9706
diff
changeset
|
109 # History |
9685 | 110 # These have delay tags but we ignore those for now |
111 Romeo receives: | |
112 <message type="groupchat" from="issue667@conference.localhost/Romeo"> | |
113 <subject>Greetings</subject> | |
114 <body>Hello everyone</body> | |
115 </message> | |
116 | |
117 Romeo receives: | |
118 <message type="groupchat" from="issue667@conference.localhost/Romeo"> | |
9706
d3c2c9248734
MUC: Add another message to #667 test
Kim Alvefur <zash@zash.se>
parents:
9685
diff
changeset
|
119 <body>Lorem ipsum dolor sit amet</body> |
d3c2c9248734
MUC: Add another message to #667 test
Kim Alvefur <zash@zash.se>
parents:
9685
diff
changeset
|
120 </message> |
d3c2c9248734
MUC: Add another message to #667 test
Kim Alvefur <zash@zash.se>
parents:
9685
diff
changeset
|
121 |
9707
9171eddcce93
MUC: Add descriptive comments to #667 test
Kim Alvefur <zash@zash.se>
parents:
9706
diff
changeset
|
122 # Finally, the topic |
9706
d3c2c9248734
MUC: Add another message to #667 test
Kim Alvefur <zash@zash.se>
parents:
9685
diff
changeset
|
123 Romeo receives: |
d3c2c9248734
MUC: Add another message to #667 test
Kim Alvefur <zash@zash.se>
parents:
9685
diff
changeset
|
124 <message type="groupchat" from="issue667@conference.localhost/Romeo"> |
9685 | 125 <subject>Something to talk about</subject> |
126 </message> | |
127 | |
128 Romeo disconnects | |
129 |