Class: ConfigurationService::Factory::Context
- Inherits:
-
Object
- Object
- ConfigurationService::Factory::Context
- Defined in:
- lib/configuration_service/factory/context.rb,
lib/configuration_service/factory/context/symbolic_access_wrapper.rb
Overview
A factory context for static factory configuration
The typical use case for this class is in constructing a multi-identifier Client using a data structure acquired from a secure source that does not need to be scrubbed.
Direct Known Subclasses
Defined Under Namespace
Classes: SymbolicAccessWrapper
Instance Method Summary collapse
-
#decorators ⇒ Object
List of unique identities of decorators to compose into the service.
-
#identifier ⇒ Object
The unique identity of the configuration data.
-
#identifier? ⇒ Boolean
Whether the context includes an
identifier
. -
#initialize(source) ⇒ Context
constructor
Returns a new factory context.
-
#provider_config ⇒ Object
Configuration options for the service provider.
-
#provider_id ⇒ Object
The unique identity of the service provider.
-
#scrub! ⇒ Object
Deletes the internal copy of the
source
. -
#token ⇒ Object
Authorization token for the identified configuration data.
Constructor Details
#initialize(source) ⇒ Context
Returns a new factory context
The following keys are used by the ConfigurationService::Factory:
- identifier
-
the unique identity of the configuration data (see Client#initialize)
- token
-
authorization token for the identified configuration data (see Client#initialize)
- provider_id
-
the unique identity of the service provider (see ProviderRegistry)
- provider_config
-
configuration options for the service provider (see service provider documentation)
- decorators
-
list of decorators to compose into the service (see Decorator and #DecoratorRegistry)
36 37 38 |
# File 'lib/configuration_service/factory/context.rb', line 36 def initialize(source) @env = SymbolicAccessWrapper.new(source) end |
Instance Method Details
#decorators ⇒ Object
List of unique identities of decorators to compose into the service
86 87 88 |
# File 'lib/configuration_service/factory/context.rb', line 86 def decorators @env.include?(:decorators) ? @env[:decorators] : [] end |
#identifier ⇒ Object
The unique identity of the configuration data
43 44 45 |
# File 'lib/configuration_service/factory/context.rb', line 43 def identifier @env[:identifier] end |
#identifier? ⇒ Boolean
Whether the context includes an identifier
51 52 53 |
# File 'lib/configuration_service/factory/context.rb', line 51 def identifier? @env.include?(:identifier) end |
#provider_config ⇒ Object
Configuration options for the service provider
See service provider documentation.
76 77 78 |
# File 'lib/configuration_service/factory/context.rb', line 76 def provider_config @env[:provider_config] end |
#provider_id ⇒ Object
The unique identity of the service provider
67 68 69 |
# File 'lib/configuration_service/factory/context.rb', line 67 def provider_id @env[:provider_id] end |
#scrub! ⇒ Object
Deletes the internal copy of the source
Called by the ConfigurationService::Factory after the client is created, to prevent in-process compromise of the context (e.g. by an exception handler that dumps the environment in a web application).
The original source
remains untouched. It is assumed to be secure. However, subclasses such as EnvironmentContext should scrub sources as well.
Sources such as the process ENV
and (on JRuby) system properties should not be used with this class; instead, they should be accessed through EnvironmentContext. Temporary YAML file sources should be accessed through YamlFileContext.
Attempts to read context properties after scrubbing will raise a SecurityError
.
106 107 108 109 |
# File 'lib/configuration_service/factory/context.rb', line 106 def scrub! @env = Hash.new { raise SecurityError, "can't access scrubbed environment context" } nil end |
#token ⇒ Object
Authorization token for the identified configuration data
58 59 60 |
# File 'lib/configuration_service/factory/context.rb', line 58 def token @env[:token] end |