2021-09-24 01:34:23 +08:00
|
|
|
* Fix migration compatibility to create SQLite references/belongs_to column as integer when migration version is 6.0.
|
|
|
|
|
|
|
|
Reference/belongs_to in migrations with version 6.0 were creating columns as
|
|
|
|
bigint instead of integer for the SQLite Adapter.
|
|
|
|
|
|
|
|
*Marcelo Lauxen*
|
|
|
|
|
2021-09-12 08:08:22 +08:00
|
|
|
* Add a deprecation warning when `prepared_statements` configuration is not
|
|
|
|
set for the mysql2 adapter.
|
|
|
|
|
|
|
|
*Thiago Araujo and Stefanni Brasil*
|
|
|
|
|
2021-12-17 21:25:48 +08:00
|
|
|
* Fix `QueryMethods#in_order_of` to handle empty order list.
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
Post.in_order_of(:id, []).to_a
|
|
|
|
```
|
|
|
|
|
|
|
|
Also more explicitly set the column as secondary order, so that any other
|
|
|
|
value is still ordered.
|
|
|
|
|
|
|
|
*Jean Boussier*
|
|
|
|
|
2021-12-17 18:38:50 +08:00
|
|
|
* Fix quoting of column aliases generated by calculation methods.
|
|
|
|
|
|
|
|
Since the alias is derived from the table name, we can't assume the result
|
|
|
|
is a valid identifier.
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
class Test < ActiveRecord::Base
|
|
|
|
self.table_name = '1abc'
|
|
|
|
end
|
|
|
|
Test.group(:id).count
|
|
|
|
# syntax error at or near "1" (ActiveRecord::StatementInvalid)
|
|
|
|
# LINE 1: SELECT COUNT(*) AS count_all, "1abc"."id" AS 1abc_id FROM "1...
|
|
|
|
```
|
|
|
|
|
|
|
|
*Jean Boussier*
|
|
|
|
|
2021-12-15 11:47:40 +08:00
|
|
|
* Add `authenticate_by` when using `has_secure_password`.
|
|
|
|
|
|
|
|
`authenticate_by` is intended to replace code like the following, which
|
|
|
|
returns early when a user with a matching email is not found:
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
User.find_by(email: "...")&.authenticate("...")
|
|
|
|
```
|
|
|
|
|
|
|
|
Such code is vulnerable to timing-based enumeration attacks, wherein an
|
|
|
|
attacker can determine if a user account with a given email exists. After
|
|
|
|
confirming that an account exists, the attacker can try passwords associated
|
|
|
|
with that email address from other leaked databases, in case the user
|
|
|
|
re-used a password across multiple sites (a common practice). Additionally,
|
|
|
|
knowing an account email address allows the attacker to attempt a targeted
|
|
|
|
phishing ("spear phishing") attack.
|
|
|
|
|
|
|
|
`authenticate_by` addresses the vulnerability by taking the same amount of
|
|
|
|
time regardless of whether a user with a matching email is found:
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
User.authenticate_by(email: "...", password: "...")
|
|
|
|
```
|
|
|
|
|
|
|
|
*Jonathan Hefner*
|
|
|
|
|
|
|
|
|
2021-12-07 23:52:30 +08:00
|
|
|
Please check [7-0-stable](https://github.com/rails/rails/blob/7-0-stable/activerecord/CHANGELOG.md) for previous changes.
|