@@ -35,7 +35,7 @@ test_standard_scopes if {
3535 with input.scope as " profile"
3636}
3737
38- test_matrix_scopes if {
38+ test_matrix_unstable_scopes if {
3939 authorization_grant.allow with input.user as user
4040 with input.client as client
4141 with input.grant_type as " authorization_code"
@@ -52,7 +52,24 @@ test_matrix_scopes if {
5252 with input.scope as " urn:matrix:org.matrix.msc2967.client:api:*"
5353}
5454
55- test_device_scopes if {
55+ test_matrix_stable_scopes if {
56+ authorization_grant.allow with input.user as user
57+ with input.client as client
58+ with input.grant_type as " authorization_code"
59+ with input.scope as " urn:matrix:client:api:*"
60+
61+ authorization_grant.allow with input.user as user
62+ with input.client as client
63+ with input.grant_type as " urn:ietf:params:oauth:grant-type:device_code"
64+ with input.scope as " urn:matrix:client:api:*"
65+
66+ not authorization_grant.allow with input.user as user
67+ with input.client as client
68+ with input.grant_type as " client_credentials"
69+ with input.scope as " urn:matrix:client:api:*"
70+ }
71+
72+ test_unstable_device_scopes if {
5673 authorization_grant.allow with input.user as user
5774 with input.client as client
5875 with input.grant_type as " authorization_code"
@@ -87,6 +104,58 @@ test_device_scopes if {
87104 with input.scope as " urn:matrix:org.matrix.msc2967.client:device:AAbbCCdd01"
88105}
89106
107+ test_stable_device_scopes if {
108+ authorization_grant.allow with input.user as user
109+ with input.client as client
110+ with input.grant_type as " authorization_code"
111+ with input.scope as " urn:matrix:client:device:AAbbCCdd01"
112+
113+ authorization_grant.allow with input.user as user
114+ with input.client as client
115+ with input.grant_type as " authorization_code"
116+ with input.scope as " urn:matrix:client:device:AAbbCCdd01-asdasdsa1-2313"
117+
118+ # Too short
119+ not authorization_grant.allow with input.user as user
120+ with input.client as client
121+ with input.grant_type as " authorization_code"
122+ with input.scope as " urn:matrix:client:device:abcd"
123+
124+ # Multiple device scope
125+ not authorization_grant.allow with input.user as user
126+ with input.client as client
127+ with input.grant_type as " authorization_code"
128+ with input.scope as " urn:matrix:client:device:AAbbCCdd01 urn:matrix:client:device:AAbbCCdd02"
129+
130+ # Allowed with the device code grant
131+ authorization_grant.allow with input.user as user
132+ with input.client as client
133+ with input.grant_type as " urn:ietf:params:oauth:grant-type:device_code"
134+ with input.scope as " urn:matrix:client:device:AAbbCCdd01"
135+
136+ # Not authorization_grant.allowed for the client credentials grant
137+ not authorization_grant.allow with input.client as client
138+ with input.grant_type as " client_credentials"
139+ with input.scope as " urn:matrix:client:device:AAbbCCdd01"
140+ }
141+
142+ test_mix_stable_and_unstable_scopes if {
143+ not authorization_grant.allow with input.user as user
144+ with input.client as client
145+ with input.grant_type as " authorization_code"
146+ with input.scope as " urn:matrix:org.matrix.msc2967.client:api:* urn:matrix:client:device:AAbbCCdd01"
147+
148+ not authorization_grant.allow with input.user as user
149+ with input.client as client
150+ with input.grant_type as " authorization_code"
151+ with input.scope as " urn:matrix:client:api:* urn:matrix:org.matrix.msc2967.client:device:AAbbCCdd01"
152+
153+ not authorization_grant.allow with input.user as user
154+ with input.client as client
155+ with input.grant_type as " authorization_code"
156+ with input.scope as " urn:matrix:client:api:* urn:matrix:org.matrix.msc2967.client:api:*"
157+ }
158+
90159test_synapse_admin_scopes if {
91160 some grant_type in [" authorization_code" , " urn:ietf:params:oauth:grant-type:device_code" ]
92161
0 commit comments