Class: ActiveAdmin::Editor::Policy

Inherits:
Object
  • Object
show all
Defined in:
lib/active_admin/editor/policy.rb

Overview

Public: Class used to generate a new S3 policy document, which can be used to authorize a direct upload to an S3 bucket.

Examples

policy = Policy.new
# => #<ActiveAdmin::Editor::Policy:0x007fa9ec41f440>

policy.document
# => "eyJleHBpcmF0aW9uIjo...gwMDBdXX0="

policy.signature
# => "NakHRb4SaI8cpU5RtSVh25kj/sc="

Instance Method Summary collapse

Instance Method Details

#documentObject

Public: The base64 encoded policy document.



25
26
27
# File 'lib/active_admin/editor/policy.rb', line 25

def document
  @document ||= Base64.encode64(document_hash.to_json).gsub("\n", '')
end

#signatureObject

Public: The base64 encoded signature of the policy document. Signed with the s3 access secret.



31
32
33
# File 'lib/active_admin/editor/policy.rb', line 31

def signature
  @signature ||= Base64.encode64(digest).gsub("\n", '')
end

#to_jsonObject

Public: JSON representation of the policy.



36
37
38
# File 'lib/active_admin/editor/policy.rb', line 36

def to_json
  { :document => document, :signature => signature }.to_json
end