Sha256: 4a07289b568394abca2fb3f116eafa4a4a1214c1e39a9117fbd05170371e74ee

Contents?: true

Size: 835 Bytes

Versions: 3

Compression:

Stored size: 835 Bytes

Contents

module 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

3 entries across 3 versions & 1 rubygems

Version Path
s3-secure-0.7.0 lib/s3_secure/policy/document.rb
s3-secure-0.6.1 lib/s3_secure/policy/document.rb
s3-secure-0.6.0 lib/s3_secure/policy/document.rb