Class: Stitches::Configuration
- Inherits:
-
Object
- Object
- Stitches::Configuration
- Defined in:
- lib/stitches/configuration.rb
Defined Under Namespace
Classes: NonNullInteger, NonNullString, UnsetString
Instance Attribute Summary collapse
-
#allowlist_regexp ⇒ Object
A RegExp that allows URLS around the mime type and api key requirements.
-
#disable_api_key_support ⇒ Object
Returns the value of attribute disable_api_key_support.
-
#disabled_key_leniency_error_log_threshold_in_seconds ⇒ Object
Returns the value of attribute disabled_key_leniency_error_log_threshold_in_seconds.
-
#disabled_key_leniency_in_seconds ⇒ Object
Returns the value of attribute disabled_key_leniency_in_seconds.
Instance Method Summary collapse
-
#calling_service_header ⇒ Object
The name of the HTTP header used to identify the calling service.
- #calling_service_header=(new_calling_service_header) ⇒ Object
-
#custom_http_auth_scheme ⇒ Object
The name of your custom http auth scheme.
- #custom_http_auth_scheme=(new_custom_http_auth_scheme) ⇒ Object
- #env_var_to_hold_api_client ⇒ Object
- #env_var_to_hold_api_client=(new_env_var_to_hold_api_client) ⇒ Object
-
#env_var_to_hold_api_client_primary_key ⇒ Object
The name of the environment variable that the ApiKey middleware should use to place the primary key of the authenticated ApiKey.
- #env_var_to_hold_api_client_primary_key=(new_env_var_to_hold_api_client_primary_key) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #max_cache_size ⇒ Object
- #max_cache_size=(new_max_cache_size) ⇒ Object
- #max_cache_ttl ⇒ Object
- #max_cache_ttl=(new_max_cache_ttl) ⇒ Object
-
#reset_to_defaults! ⇒ Object
Mainly for testing, this resets all configuration to the default value.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
6 7 8 |
# File 'lib/stitches/configuration.rb', line 6 def initialize reset_to_defaults! end |
Instance Attribute Details
#allowlist_regexp ⇒ Object
A RegExp that allows URLS around the mime type and api key requirements. nil means that ever request must have a proper mime type and api key.
28 29 30 |
# File 'lib/stitches/configuration.rb', line 28 def allowlist_regexp @allowlist_regexp end |
#disable_api_key_support ⇒ Object
Returns the value of attribute disable_api_key_support.
24 25 26 |
# File 'lib/stitches/configuration.rb', line 24 def disable_api_key_support @disable_api_key_support end |
#disabled_key_leniency_error_log_threshold_in_seconds ⇒ Object
Returns the value of attribute disabled_key_leniency_error_log_threshold_in_seconds.
24 25 26 |
# File 'lib/stitches/configuration.rb', line 24 def disabled_key_leniency_error_log_threshold_in_seconds @disabled_key_leniency_error_log_threshold_in_seconds end |
#disabled_key_leniency_in_seconds ⇒ Object
Returns the value of attribute disabled_key_leniency_in_seconds.
24 25 26 |
# File 'lib/stitches/configuration.rb', line 24 def disabled_key_leniency_in_seconds @disabled_key_leniency_in_seconds end |
Instance Method Details
#calling_service_header ⇒ Object
The name of the HTTP header used to identify the calling service. Clients send this header; servers read it via CallingServiceName.
67 68 69 |
# File 'lib/stitches/configuration.rb', line 67 def calling_service_header @calling_service_header.to_s end |
#calling_service_header=(new_calling_service_header) ⇒ Object
71 72 73 |
# File 'lib/stitches/configuration.rb', line 71 def calling_service_header=(new_calling_service_header) @calling_service_header = NonNullString.new("calling_service_header", new_calling_service_header) end |
#custom_http_auth_scheme ⇒ Object
The name of your custom http auth scheme. This must be set, and has no default
37 38 39 |
# File 'lib/stitches/configuration.rb', line 37 def custom_http_auth_scheme @custom_http_auth_scheme.to_s end |
#custom_http_auth_scheme=(new_custom_http_auth_scheme) ⇒ Object
41 42 43 |
# File 'lib/stitches/configuration.rb', line 41 def custom_http_auth_scheme=(new_custom_http_auth_scheme) @custom_http_auth_scheme = NonNullString.new("custom_http_auth_scheme",new_custom_http_auth_scheme) end |
#env_var_to_hold_api_client ⇒ Object
57 58 59 |
# File 'lib/stitches/configuration.rb', line 57 def env_var_to_hold_api_client @env_var_to_hold_api_client.to_s end |
#env_var_to_hold_api_client=(new_env_var_to_hold_api_client) ⇒ Object
61 62 63 |
# File 'lib/stitches/configuration.rb', line 61 def env_var_to_hold_api_client=(new_env_var_to_hold_api_client) @env_var_to_hold_api_client= NonNullString.new("env_var_to_hold_api_client",new_env_var_to_hold_api_client) end |
#env_var_to_hold_api_client_primary_key ⇒ Object
The name of the environment variable that the ApiKey middleware should use to place the primary key of the authenticated ApiKey. For example, if a user provides the api key 1234-1234-1234-1234, and that maps to the primary key 42 in your database, the environment will contain “42” in the key provided here.
49 50 51 |
# File 'lib/stitches/configuration.rb', line 49 def env_var_to_hold_api_client_primary_key @env_var_to_hold_api_client_primary_key.to_s end |
#env_var_to_hold_api_client_primary_key=(new_env_var_to_hold_api_client_primary_key) ⇒ Object
53 54 55 |
# File 'lib/stitches/configuration.rb', line 53 def env_var_to_hold_api_client_primary_key=(new_env_var_to_hold_api_client_primary_key) @env_var_to_hold_api_client_primary_key = NonNullString.new("env_var_to_hold_api_client_primary_key",new_env_var_to_hold_api_client_primary_key) end |
#max_cache_size ⇒ Object
83 84 85 |
# File 'lib/stitches/configuration.rb', line 83 def max_cache_size @max_cache_size.to_i end |
#max_cache_size=(new_max_cache_size) ⇒ Object
87 88 89 |
# File 'lib/stitches/configuration.rb', line 87 def max_cache_size=(new_max_cache_size) @max_cache_size = NonNullInteger.new("max_cache_size", new_max_cache_size) end |
#max_cache_ttl ⇒ Object
75 76 77 |
# File 'lib/stitches/configuration.rb', line 75 def max_cache_ttl @max_cache_ttl.to_i end |
#max_cache_ttl=(new_max_cache_ttl) ⇒ Object
79 80 81 |
# File 'lib/stitches/configuration.rb', line 79 def max_cache_ttl=(new_max_cache_ttl) @max_cache_ttl = NonNullInteger.new("max_cache_ttl", new_max_cache_ttl) end |
#reset_to_defaults! ⇒ Object
Mainly for testing, this resets all configuration to the default value
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/stitches/configuration.rb', line 11 def reset_to_defaults! @allowlist_regexp = nil @custom_http_auth_scheme = UnsetString.new("custom_http_auth_scheme") @env_var_to_hold_api_client_primary_key = NonNullString.new("env_var_to_hold_api_client_primary_key","STITCHES_API_CLIENT_ID") @env_var_to_hold_api_client= NonNullString.new("env_var_to_hold_api_client","STITCHES_API_CLIENT") @calling_service_header = NonNullString.new("calling_service_header", "X-StitchFix-Calling-Service") @max_cache_ttl = NonNullInteger.new("max_cache_ttl", 0) @max_cache_size = NonNullInteger.new("max_cache_size", 0) @disabled_key_leniency_in_seconds = ActiveSupport::Duration.days(3) @disabled_key_leniency_error_log_threshold_in_seconds = ActiveSupport::Duration.days(2) @disable_api_key_support = false end |