Module: Spree::SecretPreferences
- Extended by:
- ActiveSupport::Concern
- Included in:
- Integration, PaymentMethod
- Defined in:
- app/models/concerns/spree/secret_preferences.rb
Overview
Stores a model's :password preferences in a separate secret_preferences
text column, encrypted with Active Record encryption whenever keys are
configured, so the preferences column never holds a secret. Declarations
are unchanged: preference :secret_key, :password and
preferred_secret_key read and write the encrypted column.
Values written before encryption was enabled stay readable and are
encrypted on the next save, or at once by
spree:upgrade:encrypt_secret_preferences.
Defined Under Namespace
Classes: TextHashSerializer
Instance Method Summary collapse
-
#separated_secret_preferences ⇒ Hash{Symbol => Hash}?
Both columns as they should be stored, when
preferencesholds a secret — one assigned as part of a whole hash, or one the upgrade has not moved yet.
Instance Method Details
#separated_secret_preferences ⇒ Hash{Symbol => Hash}?
Both columns as they should be stored, when preferences holds a secret
— one assigned as part of a whole hash, or one the upgrade has not moved
yet. A secret found there is the newer value and wins.
43 44 45 46 47 48 |
# File 'app/models/concerns/spree/secret_preferences.rb', line 43 def separated_secret_preferences secrets = (preferences || {}).slice(*self.class.secret_preference_names) return if secrets.empty? { preferences: preferences.except(*secrets.keys), secret_preferences: (secret_preferences || {}).merge(secrets) } end |