Commit ec60963
authored
Fix missing authorization check before REST project remix creation (#864)
## Status
- Closes
RaspberryPiFoundation/digital-editor-issues#1468
### Why
The REST project remix endpoint authenticated the caller but did not
verify that the caller could view the original project before cloning
it. That meant a user who knew a project
identifier could create a remix from a project they were not authorized
to read.
This now aligns the REST remix flow with the existing Scratch and
GraphQL remix authorization behavior.
### What Changed
- Added an explicit authorize! :show, project check before
Project::CreateRemix.call.
- Added regression coverage for:
- remixing another user’s private project
- a student remixing a teacher-only lesson project they cannot view
- The regression specs assert the request is forbidden, no remix is
created, and the clone operation is not called.
_Follow-up: consider enabling CanCanCan check_authorization at the API
controller layer so missing authorization becomes fail-closed by
default. This should be handled separately because it requires auditing
existing controllers and adding explicit skip_authorization_check for
intentionally public or non-CanCan endpoints._1 parent bb1347f commit ec60963
2 files changed
Lines changed: 45 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
171 | 214 | | |
172 | 215 | | |
173 | 216 | | |
| |||
0 commit comments