Class: SecureHeaders::StrictTransportSecurity
- Inherits:
-
Object
- Object
- 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::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.
14 15 16 17 |
# File 'lib/secure_headers/headers/strict_transport_security.rb', line 14 def initialize(config = nil) @config = config validate_config unless @config.nil? end |
Instance Method Details
#name ⇒ Object
19 20 21 |
# File 'lib/secure_headers/headers/strict_transport_security.rb', line 19 def name return HSTS_HEADER_NAME end |
#value ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/secure_headers/headers/strict_transport_security.rb', line 23 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 value += "; includeSubdomains" if @config[:include_subdomains] value end |