You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Found while preparing the read-only work in #1265; it has to be settled before its kitchen and shopping packages (P3, P4).
Today
The server decides which module a request belongs to by its path (server/scopes.js: meals covers /meals and /recipes, shopping covers /shopping). Three routes write into the shopping list but are judged as meals, and one route goes the other way:
POST /meals/:id/to-shopping-list (server/routes/meals.js): inserts shopping_items and sets meal_ingredients.on_shopping_list.
POST /meals/week-to-shopping-list (server/routes/meals.js): the same for a whole week.
POST /recipes/:id/to-shopping-list (server/routes/recipes.js): inserts shopping_items.
POST /shopping/:listId/import-meal-plan (server/routes/shopping.js): judged as shopping, inserts shopping_items and sets meal_ingredients.on_shopping_list, which is meal-plan data.
None of them checks the other module. A member with meals: write and shopping: none can add items to a shopping list they cannot see, and a token scoped to meals can do the same. In the other direction, shopping: write with meals: read changes meal-plan flags.
Decision
The target module is checked as well: writing into a module needs write access to that module, for member permissions and for token scopes, whichever route the request comes through.
Proposal
The three to-shopping-list routes additionally require shopping: write; import-meal-plan additionally requires meals: write. A missing right answers 403 with the same shape as the path guard.
One test per route and per axis (member permission, token scope) that is red today.
Found while preparing the read-only work in #1265; it has to be settled before its kitchen and shopping packages (P3, P4).
Today
The server decides which module a request belongs to by its path (
server/scopes.js:mealscovers/mealsand/recipes,shoppingcovers/shopping). Three routes write into the shopping list but are judged asmeals, and one route goes the other way:POST /meals/:id/to-shopping-list(server/routes/meals.js): insertsshopping_itemsand setsmeal_ingredients.on_shopping_list.POST /meals/week-to-shopping-list(server/routes/meals.js): the same for a whole week.POST /recipes/:id/to-shopping-list(server/routes/recipes.js): insertsshopping_items.POST /shopping/:listId/import-meal-plan(server/routes/shopping.js): judged asshopping, insertsshopping_itemsand setsmeal_ingredients.on_shopping_list, which is meal-plan data.None of them checks the other module. A member with
meals: writeandshopping: nonecan add items to a shopping list they cannot see, and a token scoped tomealscan do the same. In the other direction,shopping: writewithmeals: readchanges meal-plan flags.Decision
The target module is checked as well: writing into a module needs write access to that module, for member permissions and for token scopes, whichever route the request comes through.
Proposal
to-shopping-listroutes additionally requireshopping: write;import-meal-planadditionally requiresmeals: write. A missing right answers403with the same shape as the path guard.