Skip to content
Snippets Groups Projects
Commit fec9fb05 authored by Robert Speicher's avatar Robert Speicher Committed by Robert Speicher
Browse files

Merge branch 'security-10-4-todo-api-reveals-sensitive-information' into 'security-10-4'

Restrict Todo API mark_as_done endpoint to the user's todos only
parent 603fa7c1
No related branches found
No related tags found
No related merge requests found
---
title: Restrict Todo API mark_as_done endpoint to the user's todos only
merge_request:
author:
type: security
Loading
Loading
@@ -60,7 +60,7 @@ module API
end
post ':id/mark_as_done' do
TodoService.new.mark_todos_as_done_by_ids(params[:id], current_user)
todo = Todo.find(params[:id])
todo = current_user.todos.find(params[:id])
 
present todo, with: Entities::Todo, current_user: current_user
end
Loading
Loading
Loading
Loading
@@ -12,7 +12,7 @@ module API
end
delete ':id' do
TodoService.new.mark_todos_as_done_by_ids(params[:id], current_user)
todo = Todo.find(params[:id])
todo = current_user.todos.find(params[:id])
 
present todo, with: ::API::Entities::Todo, current_user: current_user
end
Loading
Loading
Loading
Loading
@@ -129,6 +129,12 @@ describe API::Todos do
 
post api("/todos/#{pending_1.id}/mark_as_done", john_doe)
end
it 'returns 404 if the todo does not belong to the current user' do
post api("/todos/#{pending_1.id}/mark_as_done", author_1)
expect(response.status).to eq(404)
end
end
end
 
Loading
Loading
Loading
Loading
@@ -38,6 +38,12 @@ describe API::V3::Todos do
 
delete v3_api("/todos/#{pending_1.id}", john_doe)
end
it 'returns 404 if the todo does not belong to the current user' do
delete v3_api("/todos/#{pending_1.id}", author_1)
expect(response.status).to eq(404)
end
end
end
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment