Class: SecureHeaders::StrictTransportSecurity
- Includes:
- Constants
- Defined in:
- lib/secure_headers/headers/strict_transport_security.rb
Defined Under Namespace
Modules: Constants
Constant Summary
Constants included from Constants
Constants::CONFIG_KEY, Constants::DEFAULT_VALUE, Constants::HSTS_HEADER_NAME, Constants::HSTS_MAX_AGE, Constants::MESSAGE, Constants::VALID_STS_HEADER
Instance Method Summary collapse
-
#initialize(config = nil) ⇒ StrictTransportSecurity
constructor
A new instance of StrictTransportSecurity.
- #name ⇒ Object
- #value ⇒ Object
Constructor Details
#initialize(config = nil) ⇒ StrictTransportSecurity
Returns a new instance of StrictTransportSecurity.
15 16 17 18 |
# File 'lib/secure_headers/headers/strict_transport_security.rb', line 15 def initialize(config = nil) @config = config validate_config unless @config.nil? end |
Instance Method Details
#name ⇒ Object
20 21 22 |
# File 'lib/secure_headers/headers/strict_transport_security.rb', line 20 def name return HSTS_HEADER_NAME end |
#value ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/secure_headers/headers/strict_transport_security.rb', line 24 def value case @config when String return @config when NilClass return DEFAULT_VALUE end max_age = @config.fetch(:max_age, HSTS_MAX_AGE) value = "max-age=" + max_age.to_s value += "; includeSubdomains" if @config[:include_subdomains] value += "; preload" if @config[:preload] value end |