2016-06-01 3 views
0

나는 종이 클립을 사용하여 Aws s3 (이 안내서에 이어 : https://devcenter.heroku.com/articles/paperclip-s3)에 파일을 직접 업로드하고 있습니다.레일즈 Paperclip S3 첨부 파일의 URL 숨기기

아래와 같이 사용자는 "attachment.file.url"메소드를 사용하여 브라우저에서 파일을 볼 수 있습니다. 사용자에게 s3 URL을 표시하는 보안 취약점입니까? 그렇다면 먼저 앱에 파일을 스트리밍하거나 "download_file"컨트롤러 작업을하지 않고이 URL을 숨기는 방법이 있습니까?

production.rb

Rails.application.configure do 
    config.paperclip_defaults = { 
    storage: :s3, 
    s3_credentials: { 
     bucket: ENV.fetch('S3_BUCKET_NAME'), 
     access_key_id: ENV.fetch('AWS_ACCESS_KEY_ID'), 
     secret_access_key: ENV.fetch('AWS_SECRET_ACCESS_KEY'), 
     s3_region: ENV.fetch('AWS_REGION'), 
    } 
    } 
end 

attachment.rb

class Attachment < ActiveRecord::Base 
    belongs_to :upload, polymorphic: true 

    has_attached_file :file 
    validates_attachment :file, content_type: { content_type: ["image/jpeg", "image/gif", "image/png", "application/pdf", "application/vnd.ms-excel",  
      "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", 
      "application/msword", 
      "application/vnd.openxmlformats-officedocument.wordprocessingml.document", 
      "text/plain"] } 
end 

S3의 URL 어쨌든 개발 도구를 사용할 수있는 모든 사용자에게 표시됩니다

<h5>File Uploads</h5> 
    <ul> 
    <% @attachments.each do |attachment| %> 
     <li> 
     <%= link_to attachment.file_file_name, attachment.file.url, :target => '_blank' %> 
     </li> 
    <% end %> 
    </ul> 
    <%= link_to "Add Files", new_attachment_path(:upload_type => 'Team'), class: "btn btn-md" %> 

답변

0

보기 때문에 그것이 노출 보안 취약점이 아닙니다. 어떤 사람들은 그것이 나쁜 UX라고 주장 할 것이지만 그것은 다른 시간에 대한 토론입니다.