Module: Tynn::Protection
- Defined in:
- lib/tynn/protection.rb
Overview
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
Class Method Summary collapse
-
.setup(app, ssl: false, hsts: {}) ⇒ Object
Internal: Configures security related plugins.
Class Method Details
.setup(app, ssl: false, hsts: {}) ⇒ Object
Internal: Configures security related plugins.
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/tynn/protection.rb', line 33 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 |