Sha256: 6738d186918961e3bd43d4698558df14b24918a0190eea80ad57f40ce9d45ee7
Contents?: true
Size: 885 Bytes
Versions: 6
Compression:
Stored size: 885 Bytes
Contents
module SecureHeaders class XFOBuildError < StandardError; end class XFrameOptions < Header module Constants XFO_HEADER_NAME = "X-Frame-Options" DEFAULT_VALUE = 'SAMEORIGIN' VALID_XFO_HEADER = /\A(SAMEORIGIN\z|DENY\z|ALLOW-FROM[:\s])/i CONFIG_KEY = :x_frame_options end include Constants def initialize(config = nil) @config = config validate_config unless @config.nil? end def name XFO_HEADER_NAME end def value case @config when NilClass DEFAULT_VALUE when String @config else @config[:value] end end private def validate_config value = @config.is_a?(Hash) ? @config[:value] : @config unless value =~ VALID_XFO_HEADER raise XFOBuildError.new("Value must be SAMEORIGIN|DENY|ALLOW-FROM:") end end end end
Version data entries
6 entries across 6 versions & 1 rubygems