|
21 | 21 |
|
22 | 22 | *Alex Ghiculescu*
|
23 | 23 |
|
| 24 | +* Model generator no longer needs a database connection to validate column types. |
| 25 | + |
| 26 | + *Mike Dalessio* |
| 27 | + |
| 28 | +* Allow signed ID verifiers to be configurable via `Rails.application.message_verifiers` |
| 29 | + |
| 30 | + Prior to this change, the primary way to configure signed ID verifiers was |
| 31 | + to set `signed_id_verifier` on each model class: |
| 32 | + |
| 33 | + ```ruby |
| 34 | + Post.signed_id_verifier = ActiveSupport::MessageVerifier.new(...) |
| 35 | + Comment.signed_id_verifier = ActiveSupport::MessageVerifier.new(...) |
| 36 | + ``` |
| 37 | + |
| 38 | + And if the developer did not set `signed_id_verifier`, a verifier would be |
| 39 | + instantiated with a secret derived from `secret_key_base` and the following |
| 40 | + options: |
| 41 | + |
| 42 | + ```ruby |
| 43 | + { digest: "SHA256", serializer: JSON, url_safe: true } |
| 44 | + ``` |
| 45 | + |
| 46 | + Thus it was cumbersome to rotate configuration for all verifiers. |
| 47 | + |
| 48 | + This change defines a new Rails config: [`config.active_record.use_legacy_signed_id_verifier`][]. |
| 49 | + The default value is `:generate_and_verify`, which preserves the previous |
| 50 | + behavior. However, when set to `:verify`, signed ID verifiers will use |
| 51 | + configuration from `Rails.application.message_verifiers` (specifically, |
| 52 | + `Rails.application.message_verifiers["active_record/signed_id"]`) to |
| 53 | + generate and verify signed IDs, but will also verify signed IDs using the |
| 54 | + older configuration. |
| 55 | + |
| 56 | + To avoid complication, the new behavior only applies when `signed_id_verifier_secret` |
| 57 | + is not set on a model class or any of its ancestors. Additionally, |
| 58 | + `signed_id_verifier_secret` is now deprecated. If you are currently setting |
| 59 | + `signed_id_verifier_secret` on a model class, you can set `signed_id_verifier` |
| 60 | + instead: |
| 61 | + |
| 62 | + ```ruby |
| 63 | + # BEFORE |
| 64 | + Post.signed_id_verifier_secret = "my secret" |
| 65 | +
|
| 66 | + # AFTER |
| 67 | + Post.signed_id_verifier = ActiveSupport::MessageVerifier.new("my secret", digest: "SHA256", serializer: JSON, url_safe: true) |
| 68 | + ``` |
| 69 | + |
| 70 | + To ease migration, `signed_id_verifier` has also been changed to behave as a |
| 71 | + `class_attribute` (i.e. inheritable), but _only when `signed_id_verifier_secret` |
| 72 | + is not set_: |
| 73 | + |
| 74 | + ```ruby |
| 75 | + # BEFORE |
| 76 | + ActiveRecord::Base.signed_id_verifier = ActiveSupport::MessageVerifier.new(...) |
| 77 | + Post.signed_id_verifier == ActiveRecord::Base.signed_id_verifier # => false |
| 78 | +
|
| 79 | + # AFTER |
| 80 | + ActiveRecord::Base.signed_id_verifier = ActiveSupport::MessageVerifier.new(...) |
| 81 | + Post.signed_id_verifier == ActiveRecord::Base.signed_id_verifier # => true |
| 82 | +
|
| 83 | + Post.signed_id_verifier_secret = "my secret" # => deprecation warning |
| 84 | + Post.signed_id_verifier == ActiveRecord::Base.signed_id_verifier # => false |
| 85 | + ``` |
| 86 | + |
| 87 | + Note, however, that it is recommended to eventually migrate from |
| 88 | + model-specific verifiers to a unified configuration managed by |
| 89 | + `Rails.application.message_verifiers`. `ActiveSupport::MessageVerifier#rotate` |
| 90 | + can facilitate that transition. For example: |
| 91 | + |
| 92 | + ```ruby |
| 93 | + # BEFORE |
| 94 | + # Generate and verify signed Post IDs using Post-specific configuration |
| 95 | + Post.signed_id_verifier = ActiveSupport::MessageVerifier.new("post secret", ...) |
| 96 | +
|
| 97 | + # AFTER |
| 98 | + # Generate and verify signed Post IDs using the unified configuration |
| 99 | + Post.signed_id_verifier = Post.signed_id_verifier.dup |
| 100 | + # Fall back to Post-specific configuration when verifying signed IDs |
| 101 | + Post.signed_id_verifier.rotate("post secret", ...) |
| 102 | + ``` |
| 103 | + |
| 104 | + [`config.active_record.use_legacy_signed_id_verifier`]: https://guides.rubyonrails.org/v8.1/configuring.html#config-active-record-use-legacy-signed-id-verifier |
| 105 | + |
| 106 | + *Ali Sepehri*, *Jonathan Hefner* |
| 107 | + |
24 | 108 | * Prepend `extra_flags` in postgres' `structure_load`
|
25 | 109 |
|
26 | 110 | When specifying `structure_load_flags` with a postgres adapter, the flags
|
|
0 commit comments