-
-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🥔✨ Marketplace
: Encrypt and Store Square Access Token
#1731
Conversation
Marketplacae
: Encrypt and Store Square Access Token
Marketplacae
: Encrypt and Store Square Access TokenMarketplace
: Encrypt and Store Square Access Token
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! I did some digging and figured out why it was not working.
The TL/DR is that RankedModel
uses Furniture.select(:id, :room_id, :slot)
under the covers at some point; which retrieves only those three attributes.
By adding an if has_attribute?("secrets_ciphertext")
we skip setting the default in cass where the secrets are not loaded.
…ext` isn't loaded (#1734)
Thanks for the assist @zspencer. Whew. I'm now more well-read on Ranked model, too. It's gotta be this line in the gem: https://github.com/brendon/ranked-model/blob/f9145d42041ed7186a893315350f01f87d39c76b/lib/ranked-model/ranker.rb#L276. I haven't traced beyond that. |
# The `RankedModel` gem uses | ||
# [`ActiveRecord::QueryMethods.select`](https://api.rubyonrails.org/classes/ActiveRecord/QueryMethods.html#method-i-select) | ||
# to do some stuff (Validation?) under the covers while keeping memory usage light... Which is good! | ||
# But it also means that we don't have the ciphertext! | ||
# So we can't set the secrets in that case (nor would we want to) | ||
self.secrets ||= {} if has_attribute?("secrets_ciphertext") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zspencer Makes me think this will not be the last time we try to access data on models returned ranked queries with surprising results 🤣
Gizmo
: Stores encryptedsecrets
#1735Marketplace
:Seller
receivesOrder
in theirSquare
Point of Sale #1500I borrowed this pattern for storing encrypted data from
Utility
, and I think it works well for Furniture-level private keys as well. In order not to conflict with the more generalsettings
attribute, I opted forsecrets
.