Sha256: 1e5ce5a8d2b26e5035e1933ee02b7f3525e703730e961828eff3f87f0beaf67b

Contents?: true

Size: 834 Bytes

Versions: 6

Compression:

Stored size: 834 Bytes

Contents

class S3Secure::Policy
  class Document
    extend Memoist

    delegate :has?, to: :checker

    def initialize(bucket, bucket_policy, remove: false)
      @bucket, @bucket_policy, @remove = bucket, bucket_policy, remove # existing document policy
    end

    # Returns JSON text
    # Currently only support adding ForceSSLOnlyAccess document policy.
    def policy_document(sid)
      enforcer_class = "S3Secure::Policy::Document::#{sid}"
      enforcer_class += "Remove" if @remove
      enforcer_class = enforcer_class.constantize # IE: ForceSSLOnlyAccess or ForceSSLOnlyAccessRemove
      enforcer = enforcer_class.new(@bucket, @bucket_policy)
      policy = enforcer.policy_document
      JSON.pretty_generate(policy) if policy
    end

    def checker
      Checker.new(@bucket_policy)
    end
    memoize :checker
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
s3-secure-0.5.1 lib/s3_secure/policy/document.rb
s3-secure-0.5.0 lib/s3_secure/policy/document.rb
s3-secure-0.4.2 lib/s3_secure/policy/document.rb
s3-secure-0.4.1 lib/s3_secure/policy/document.rb
s3-secure-0.4.0 lib/s3_secure/policy/document.rb
s3-secure-0.3.0 lib/s3_secure/policy/document.rb