SECURITY: only allow picking of avatars created by self (#6417)

* SECURITY: only allow picking of avatars created by self

Also adds origin tracking to all uploads including de-duplicated uploads
This commit is contained in:
Sam
2018-09-20 15:33:10 +10:00
committed by Guo Xiang Tan
parent e0be5145cf
commit df45e82377
10 changed files with 196 additions and 11 deletions

View File

@ -0,0 +1,22 @@
class CreateUserUploads < ActiveRecord::Migration[5.2]
def up
create_table :user_uploads do |t|
t.integer :upload_id, null: false
t.integer :user_id, null: false
t.datetime :created_at, null: false
end
add_index :user_uploads, [:upload_id, :user_id], unique: true
execute <<~SQL
INSERT INTO user_uploads(upload_id, user_id, created_at)
SELECT id, user_id, COALESCE(created_at, current_timestamp)
FROM uploads
WHERE user_id IS NOT NULL
SQL
end
def down
drop_table :user_uploads
end
end