Sha256: 2fa9e41949b5a4e8e999db6c1572fbf7a48b0b8c470fc58dd4e83fc242e30dc5

Contents?: true

Size: 909 Bytes

Versions: 2

Compression:

Stored size: 909 Bytes

Contents

require_relative "secure_headers"

class Tynn
  # Public: Adds security measures against common attacks.
  #
  # Examples
  #
  #   require "tynn"
  #   require "tynn/protection"
  #
  #   Tynn.plugin(Tynn::Protection)
  #
  # If you are using SSL/TLS (HTTPS), it's recommended to set
  # the +:ssl+ option:
  #
  # Examples
  #
  #   require "tynn"
  #   require "tynn/protection"
  #
  #   Tynn.plugin(Tynn::Protection, ssl: true)
  #
  # By default, it includes the following security plugins:
  #
  # - Tynn::SecureHeaders
  #
  # If the +:ssl+ option is +true+, includes:
  #
  # - Tynn::SSL
  #
  module Protection
    # Internal: Configures security related plugins.
    def self.setup(app, ssl: false, hsts: {})
      app.plugin(Tynn::SecureHeaders)

      if ssl
        app.settings[:ssl] = true

        require_relative "ssl"

        app.plugin(Tynn::SSL, hsts: hsts)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tynn-1.4.0 lib/tynn/protection.rb
tynn-1.3.0 lib/tynn/protection.rb