Conversation
Prefixes our encrypted_attributes with library specific attr_encrypted so we are not clashing with the Rails 7.0 definition of encrypted_attributes
b7310b2 to
ee35c84
Compare
Prefix encrypt and decrypt methods with attr_encrypted so we don't clash with rails 7
ee35c84 to
4f33ddb
Compare
|
Can you add rails 6 and 7 to the test matrix? |
|
I think we'll need a smarter matrix. Rails 7 isn't compatible with ruby <3.1. |
@xjunior Also might be a good time to migrate to GitHub Actions? |
|
Also, it seems that |
|
Hi @movermeyer, is there any workaround that you suggest we could try here? |
|
For what it's worth, this at least appears to work. |
|
True, we could probably look at this patch to fix the |
From what I can see >= 2.7 is fine: |
|
I was working with @mvastola but have been a bit busy. The idea was to cut a new major release for this breaking change and let rails 7 users upgrade. There is some discussion around how much we should maintain previous versions of this library for older Ruby and ActiveRecord versions. Fwiw we are using this exact patch on a fork at my company to get onto Rails 7, then figuring out how to migrate the data and move to native Rails encryption. |
Hi @joshbranham! First, thanks for your awesome work 👍 Do you have any idea when this could be released, to upgrade to Rails 7? Thanks |
|
The current blocker is I haven't had much luck understanding why those tests exist, and if anyone is using |
… with Rails 7 Prefix 'attr_encrypted' to encrypt and decrypt methods to avoid clash with Rails 7 Adopted from PR: attr-encrypted#425
… with Rails 7 Prefix 'attr_encrypted' to encrypt and decrypt methods to avoid clash with Rails 7 Adopted from PR: #425
* Add (failable) tests to Travis for RoR 6/6.1/7 * Restrict set_attribute_was patch to Rails versions >= 5.2, < 6 Signed-off-by: Josh Branham <josh.php@gmail.com> * Don't use Gem requirement comparison with frozen Gem::Version * Disallow failures for RoR 6.0+ tests on travis As those should be passing or otherwise dealt with by the time this is merged * Use #write_cast_value to register the original value before change for Rails >= 5.2 Use #write_cast_value instead of #set_attribute_was patch * Prefix 'attr_encrypted' to encrypted_attributes method to avoid clash with Rails 7 Prefix 'attr_encrypted' to encrypt and decrypt methods to avoid clash with Rails 7 Adopted from PR: attr-encrypted#425 * Hardcoding sqlite3 gem version to 1.5.4 since newer sqlite3 versions removed native gem support for Ruby 2.6 * Release 4.0.0 * Drop gem signing (attr-encrypted#436) * Drop support for DataMapper (attr-encrypted#439) This project has been dead since 2018 * Update README.md (attr-encrypted#441) * Start testing ruby 3 (attr-encrypted#440) * Start testing ruby 3 * Exclude older AR and newer Ruby combos * Add Ruby 3.0.6 as well * Exclude 3.0.6 and AR 5.x * Use ActiveRecord.deprecator when available (attr-encrypted#437) Rails 7.1 will deprecate using the singleton ActiveSupport::Deprecation instance. This directly uses the one from ActiveRecord. Co-authored-by: Josh Branham <josh.php@gmail.com> * Use Github Actions for CI (attr-encrypted#442) * Use Github Actions for CI * Add back old Rails versions * Only test Rails 5 on Ruby 2.7 --------- Co-authored-by: Josh Branham <josh.php@gmail.com> * Fix minitest guard for rails 4 breaking specs (attr-encrypted#448) Co-authored-by: Josh Branham <joshbranham@sophie-mba.local> * Add Josh and Mike to authors (attr-encrypted#447) * Add Josh and Mike to authors Signed-off-by: Josh Branham <josh.php@gmail.com> * Update attr_encrypted.gemspec Signed-off-by: Josh Branham <josh.php@gmail.com> --------- Signed-off-by: Josh Branham <josh.php@gmail.com> * Add GitHub Actions badge to README (attr-encrypted#449) * Update README.md Signed-off-by: Josh Branham <josh.php@gmail.com> * Update README.md Signed-off-by: Josh Branham <josh.php@gmail.com> --------- Signed-off-by: Josh Branham <josh.php@gmail.com> * Deprecate testing with travis (attr-encrypted#450) * Add rails7.1 and Ruby3.3 to CI matrix (attr-encrypted#453) * Release v4.1.0 (attr-encrypted#455) * Fix SystemStackError when extending the reload method with Module#prepend (attr-encrypted#457) For example, when using the master branch of activerecord-multi-tenant, if activerecord-multi-tenant and attr_encrypted are listed in the Gemfile in that order, calling the reload method raises a SystemStackError. This happens because activerecord-multi-tenant extends Active Record’s reload method using prepend, while attr_encrypted extends it using an alias method. Here’s an example of how extending the same method with both prepend and alias methods in that order can result in a SystemStackError ``` class Hello def hello 'hello' end end Hello.prepend(Module.new do def hello super end end) Hello.class_eval do alias orig_hello hello def hello "#{orig_hello} world" end end Hello.new.hello #=> SystemStackError ``` However, reversing the order works: ``` class Hello def hello 'hello' end end Hello.class_eval do alias orig_hello hello def hello "#{orig_hello} world" end end Hello.prepend(Module.new do def hello super end end) Hello.new.hello #=> "hello world" ``` This issue can be resolved by standardizing the method extension to use prepend to avoid conflicts. * Release 4.1.1 (attr-encrypted#458) * Add Rails7.2, 8.0 and Ruby 3.4 to CI matrix Also updated actions/checkout to the latest v4. * Fix CI failures for Rails 6.0 to 7.0. The CI failures for Rails 6.0 to 7.0 are caused by changes introduced in concurrent-ruby v1.3.5. ref: [Rails 7.0.8 fails to create an app with most recent concurrent-ruby version · Issue #54260 · rails/rails](rails/rails#54260) Update concurrent-ruby to a version below 1.3.5 to fix the tests. * Set the sqlite3 version to 2.1.0 or higher for Rails 8.0. To run CI with Rails 8.0, sqlite3 version 2.1.0 or higher is required. * Remove the unused dm-sqlite-adapter dm-sqlite-adapter is a SQLite adapter for DataMapper. https://github.com/datamapper/dm-sqlite-adapter Since support for DataMapper was dropped in version 4.1.0, this gem is no longer needed as a dependency. * Set required_ruby_version >= 2.7.0 (attr-encrypted#464) * Release 4.2.0 * Release 4.2.0 (attr-encrypted#465) * Prevent attr_encrypted from making queries on load (attr-encrypted#468) `#attribute_instance_methods_as_symbols` can trigger a query when the schema cache is not loaded. We only need the results of this method if `attribute_instance_methods_as_symbols_available?` is true so we move this inside the check. Signed-off-by: Bojan Marjanovic <marjanovic93@gmail.com> * Reduce gem size by excluding test files (attr-encrypted#470) Co-authored-by: Yuri Zubov <yuri.zubov@cleverlabs.io> --------- Signed-off-by: Josh Branham <josh.php@gmail.com> Signed-off-by: Bojan Marjanovic <marjanovic93@gmail.com> Co-authored-by: Mike Vastola <mike@vasto.la> Co-authored-by: Josh Branham <josh.php@gmail.com> Co-authored-by: Josh Branham <jbranham@salsify.com> Co-authored-by: Vimal V Nair <vimalvnair999@gmail.com> Co-authored-by: Matt Larraz <mlarraz@users.noreply.github.com> Co-authored-by: Étienne Barrié <etienne.barrie@gmail.com> Co-authored-by: Josh Branham <joshbranham@sophie-mba.local> Co-authored-by: Shinichi Maeshima <netwillnet@gmail.com> Co-authored-by: Josh Branham <jbranham@redhat.com> Co-authored-by: Bojan Marjanovic <marjanovic93@gmail.com> Co-authored-by: Yuri Zubov <yury.zubau@gmail.com> Co-authored-by: Yuri Zubov <yuri.zubov@cleverlabs.io> Co-authored-by: Claude <noreply@anthropic.com>
What are you trying to accomplish?
Fixes #423.
Rails 7 introduced Active Record Encryption, which has names that collide with the names that
attr_encryptedis using.What approach did you choose and why?
I took over @ryosk7, @kineca, and @armiiller's closed PR, rebased it on latest
master, and recreated it here.It's a simple rename of class variables and methods, adding a
attr_encrypted_prefix to each.IMO, it's a perfectly cromulent rename.
What should reviewers focus on?
This is a breaking change, since anyone relying on these names will have to update their code.
The impact of these changes
attr_encryptedwill work once again on Rails 7