class S3Secure::Policy::Checker

Public Class Methods

new(bucket_policy) click to toggle source
# File lib/s3_secure/policy/checker.rb, line 3
def initialize(bucket_policy)
  @bucket_policy = bucket_policy # existing document policy
end

Public Instance Methods

has?(sid) click to toggle source
# File lib/s3_secure/policy/checker.rb, line 7
def has?(sid)
  return false if @bucket_policy.blank?

  policy_document = JSON.load(@bucket_policy)
  statements = policy_document["Statement"]
  !!statements.detect { |s| s["Sid"] == sid }
end