3948 Commits

Author SHA1 Message Date
Edouard CHIN
4f82235630 Use Omniauth.allowed_methods' as routing verbs for the auth path:
- ### Context

  Since version 2.0.0, Omniauth no longer recognizes `GET` request
  on the auth path (`/users/auth/<provider>`). `POST` is the only
  verb that is by default recognized in order to mitigate CSRF
  attack. 66110da85e/lib/omniauth/strategy.rb (L205)

  Ultimatelly, when a user try to access `GET /users/auth/facebook`,
  Devise [passthru action](6d32d2447c/app/controllers/devise/omniauth_callbacks_controller.rb (L6))
  will be called which just return a raw 404 page.

  ### Problem

  There is no problem per se and everything work. However the
  advantage of not matching GET request at the router layer allows
  to get that same 404 page stylized for "free" (Rails ending up
  rendering the 404 page of the app).

  I believe it's also more consistent and less surprising for users
  if this passthru action don't get called.

  ### Drawback

  An application can no longer override the `passthru` to perform
  the logic it wants (i.e. redirect the user).

  If this is a dealbreaker, feel free to close this PR :).
2023-06-09 23:46:12 +00:00
Rafael Mendonça França
8bb41ad98e Merge pull request #5601 from heartcombo/dependabot/github_actions/supercharge/mongodb-github-action-1.9.0
Bump supercharge/mongodb-github-action from 1.3.0 to 1.9.0
2023-06-09 19:43:28 -04:00
Rafael Mendonça França
e81ec9c436 Merge pull request #5595 from louim/bugfix/mailer-defaults-lambda-arity
Make sure Mailer defaults :from and :reply_to are handled correctly
2023-06-09 19:42:53 -04:00
Louis-Michel Couture
ed1c2a1adb Make sure Mailer defaults :from and :reply_to are handled correctly
Rails allow procs and lambda with either zero or more argument. Devise
however always tried to call instance_eval on those values, which does
always pass one argument: self.

There was a PR to fix this specific problem in Devise https://github.com/heartcombo/devise/pull/4627,
before the arity check was fixed in rails itself: https://github.com/rails/rails/pull/30391.

But even if the problem was fixed in Rails, Devise was still calling
the proc/lambas with instance_eval. That meant the fix added to Rails
did not apply to Devise.

The fix is to let Rails handle the :from and :reply_to defaults. We do
that by unsetting the headers instead of trying to replicate Rails handling
in Devise. This lets Rails handle it when setting up the mailer.
2023-06-09 23:30:51 +00:00
Rafael Mendonça França
9be24c0ae4 Merge pull request #5598 from soartec-lab/task/removed-older-deprecation-warning
Removed deprecations warning output for `Devise::Models::Authenticatable::BLACKLIST_FOR_SERIALIZATION`
2023-06-09 19:24:40 -04:00
Rafael Mendonça França
19d9dabc80 Merge pull request #5480 from glaucocustodio/patch-1
Use bundle add instead
2023-06-09 19:23:39 -04:00
dependabot[bot]
285dc5d2fc Bump supercharge/mongodb-github-action from 1.3.0 to 1.9.0
Bumps [supercharge/mongodb-github-action](https://github.com/supercharge/mongodb-github-action) from 1.3.0 to 1.9.0.
- [Release notes](https://github.com/supercharge/mongodb-github-action/releases)
- [Changelog](https://github.com/supercharge/mongodb-github-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/supercharge/mongodb-github-action/compare/1.3.0...1.9.0)

---
updated-dependencies:
- dependency-name: supercharge/mongodb-github-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-09 23:23:28 +00:00
Rafael Mendonça França
aeb24bf804 Merge pull request #5504 from petergoldstein/feature/add_dependabot_for_github_actions
Add Dependabot for GitHub Actions
2023-06-09 19:23:08 -04:00
Rafael Mendonça França
aca0b24118 Merge pull request #5494 from iainbeeston/br-has-no-closing-slash
Replaced `<br/>` with `<br>`
2023-06-09 19:22:46 -04:00
soartec-lab
e524a3d22d Removed deprecations warning output for Devise::Models::Authenticatable::BLACKLIST_FOR_SERIALIZATION 2023-06-09 23:20:47 +00:00
Iain Beeston
1a3d1ae350 Replaced <br/> with paragraph tags
In regular HTML `<br>` is a void element, so it

Many of the shared templates used by devise use `<br/>`
to separate lines, which is invalid html because `<br>`
doesn't need a closing tag or a closing slash. See the
WhatWG spec here:
https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-br-element

Also, the WhatWG spec uses `<p>` tags to separate
`<label>` and `<input>` tags rather than `<br>`, see
here:
https://html.spec.whatwg.org/multipage/input.html

To clean this up I've replaced `<br/>` with paragraph
tags throughout all of the templates.

This reverts b86c1c241b
2023-06-09 22:36:51 +00:00
Rafael Mendonça França
fc731a88bb Add devcontainer configuration
This will allow contributors to setup their environment using VS Code
container or Codebases.
2023-06-09 22:34:44 +00:00
Rafael Mendonça França
6d058bfde8 Fix tests after #5515 2023-06-09 22:34:19 +00:00
Rafael Mendonça França
ad172bd547 Merge pull request #5599 from etiennebarrie/rails-edge-deprecations
Fix Rails main deprecations
2023-06-09 18:16:49 -04:00
Rafael Mendonça França
1195c6f0d6 Merge pull request #5515 from okyanusoz/patch-1
Fix a grammatical error
2023-06-09 18:16:38 -04:00
Rafael Mendonça França
54a624a34b Merge pull request #5583 from etiennebarrie/deprecator
Use a dedicated ActiveSupport::Deprecation
2023-06-09 18:12:01 -04:00
Étienne Barrié
48e115334b Remove MigrationContext deprecation in 7.1
DEPRECATION WARNING: SchemaMigration no longer inherits from
ActiveRecord::Base. If you want to use the default connection, remove
this argument. If you want to use a specific connection, instantiate
MigrationContext with the connection's schema migration, for example
`MigrationContext.new(path, Dog.connection.schema_migration)`.
2023-06-08 11:49:34 +02:00
Étienne Barrié
c809adeeed Use show_exceptions = :none in Rails 7.1
DEPRECATION WARNING: Setting action_dispatch.show_exceptions to false is
deprecated. Set to :none instead.
2023-06-08 11:49:19 +02:00
Étienne Barrié
e1298c87d7 Add deprecator to the application's deprecators 2023-06-08 11:30:38 +02:00
Étienne Barrié
882dd70a9f Use a dedicated ActiveSupport::Deprecation
Rails 7.1 will deprecate using the singleton ActiveSupport::Deprecation
instance. This defines one for the gem and uses it.
2023-04-07 00:15:10 +02:00
Carlos Antonio da Silva
4b72064bfc Add missing changelog version [ci skip] 2023-04-03 09:25:06 -03:00
Carlos Antonio da Silva
8b0b849a67 Release v4.9.2 v4.9.2 2023-04-03 09:23:02 -03:00
Carlos Antonio da Silva
4f849f4fa9 Bring back `Devise.activerecord51? and deprecate it
Even though this is considered an internal / non-public / nodoc method,
it seems some libraries relied on it internally, causing some breakage.

Known libraries so far are `devise-security` and
`devise-pwned_password`.

Closes #5580
2023-04-03 09:21:56 -03:00
Carlos Antonio da Silva
3926e6d9eb Release v4.9.1 v4.9.1 2023-03-31 09:39:17 -03:00
Carlos Antonio da Silva
506eaf495d Merge pull request #5576 from heartcombo/ca-multiple-orms
Improve support for Devise in apps with multiple ORMs loaded
2023-03-30 17:54:30 -03:00
Carlos Antonio da Silva
8dbe5b2fe8 Merge pull request #5573 from heartcombo/ca/failure-app-respect-redirect
Respect redirect status code when recalling the action
2023-03-30 17:29:35 -03:00
Carlos Antonio da Silva
207ddc5127 Improve support for Devise in apps with multiple ORMs loaded
Devise is able to work with a specific ORM, either Active Record or
Mongoid, but nothing stops apps from using multiple ORMs within the same
application -- they just need to pick one to use with Devise. That's
generally determined by the require that is added to the Devise
initializer, that will load up either ORM's extensions so you can call
things like `devise` on your model to set it up.

However, some conditional logic in Devise, more specifically around
dirty tracking, was only considering having Active Record loaded up
after a certain version, to determine which methods to call in parts of
the implementation. In a previous change we refactored all that dirty
tracking code into this `OrmDirtyTracking` module to make it easier to
view all the methods that were being conditionally called, and now we're
repurposing this into a more generic `Orm` module (that's nodoc'ed by
default) so that upon including it, we can conditionally include the
proper dirty tracking extensions but also check whether the including
model is really Active Record or not, so we can trigger the correct
dirty tracking behavior for Mongoid as well if both are loaded on the
same app, whereas previously the Mongoid behavior would always use the
new Active Record behavior, but support may differ.

While we are also working to ensure the latest versions of Mongoid are
fully running with Devise, this should improve the situation by giving
apps with multiple ORMs loaded a chance to rely on some of these Devise
bits of functionality better now that weren't working properly before
without some monkey-patching on their end.

Closes #5539
Closes #4542
2023-03-23 19:16:23 -03:00
Carlos Antonio da Silva
367ea42762 Refactor dirty tracking conditionals for different versions (#5575)
We have an number of conditions due to how dirty tracking changed around
Rails 5.1, that implement methods using one or another method call. I
might need more of this for mongo upgrades based on an initial
investigation, plus this makes the code really hard to reason about
sometimes with these many conditionals.

While I want to drop support for older versions of Rails soon, this
centralization of dirty methods that are used by devise conditionally
simplifies the usage considerably across the board, moves the version
condition to a single place, and will make it easier to refactor later
once we drop older Rails version by simply removing the `devise_*`
versions of the methods, alongside the prefix on the method calls for
the most part, since those methods follow the naming of the newer Rails
versions.
2023-03-23 19:11:11 -03:00
Carlos Antonio da Silva
89a08357d6 Uses the responder redirect_status when recall returns a redirect
It appears some people use the recall functionality with a redirect
response, and Devise starting on version 4.9 was overriding that status
code to the configured `error_status` for better Turbo support, which
broke the redirect functionality / expectation.

While I don't think it's really great usage of the recall functionality,
or at least it was unexpected usage, it's been working like that
basically forever where recalling would use the status code of the
recalled action, so this at least keeps it more consistent with that
behavior by respecting redirects and keeping that response as a redirect
based on the configured status, which should also work with Turbo I
believe, and makes this less of a breaking change.

Closes #5570
Closes #5561 (it was closed previously, but related / closes with an
actual change now.)
2023-03-20 18:18:54 -03:00
Carlos Antonio da Silva
eed51179c7 Add explicit test for respecting the error_status responder config
While introducing this on turbo, looks like no specific test was added,
so this at least covers that a bit.

It needs some conditional checks since not all supported Rails +
Responders version work with the customization, so there's one test for
the hardcoded status version too, which can be removed in the future.
2023-03-20 17:58:48 -03:00
Peter Goldstein
11b6a99e88 Add Dependabot for GitHub Actions 2023-03-19 12:55:13 -04:00
Carlos Antonio da Silva
232c855c54 Fix tests with Rails main
Rails main / 7.1.0.alpha introduced a change to improve typography by
default, by converting all apostrophes to be single quotation marks.
https://github.com/rails/rails/pull/45463

The change caused all our text based matching to fail, this updates the
tests to ensure compatibility.

Model tests were changed to test against the error type & information
rather than the translated string, which I think is an improvement
overall that should make them a little less brittle. I thought of using
[of_kind?] but that isn't available on all Rails versions we currently
support, while `added?` is. The drawback is that `added?` require full
details like the `:confirmation` example which requires the related
attribute that is being confirmed, but that's a small price to pay.

Integration tests were changed to match on a regexp that accepts both
quotes. I could've used a simple `.` to match anything there, but
thought I'd just keep it specific for clarity on what it is really
expected to match there. Plus, since it's integration testing against a
rendered response body, it's better to match the actual text rather than
resort on other ways. (like using I18n directly, etc.)

[of_kind?] https://api.rubyonrails.org/classes/ActiveModel/Errors.html#method-i-of_kind-3F
2023-03-17 10:59:55 -03:00
Carlos Antonio da Silva
afec6655c7 Update bundle 2023-03-17 10:59:51 -03:00
Carlos Antonio da Silva
7d1dc56fdb Merge branch 'ca-replace-refute-assert-not'
Prefer `assert_not*` helpers.

Closes #5158
2023-03-02 19:15:18 -03:00
Carlos Antonio da Silva
890bd9e3b5 Replace usage of assert ! with actual assert_not helper 2023-03-02 18:41:44 -03:00
Carlos Antonio da Silva
1e63c640c0 Update a few other instances that were using refute methods
Prefer assert_not* in general.
2023-03-02 18:40:35 -03:00
tabakazu
8acbdd6d93 Replace matcher refute to assert_not 2023-03-02 18:38:04 -03:00
Carlos Antonio da Silva
400eaf7fbe Remove not used constant
It's only been almost ~10 years since we removed it's usage. :D
dff7891b97
2023-03-01 22:50:56 -03:00
Carlos Antonio da Silva
df8b79a53f Fix added tests for sign_in_after_reset_password per resource class
We can't just "swap" those model properties, as that sets instance vars
on the classes that get reverted to their "previous" value, which ends
up leaving the instance vars set as `nil`. However, our logic for those
model/class properties actually checks for `defined?` as a way to
override them, and delegates up to `Devise` global config if they are
not defined, so leaving instance vars back with `nil` values isn't
enough, we need to actually remove them.

This introduces a new test helper specifically for overriding those
model configs so that we can do proper cleanup.
2023-03-01 22:50:03 -03:00
Carlos Antonio da Silva
ef6c73b221 Merge branch 'feature/password-reset-configuration'
Closes #5429
2023-03-01 22:20:54 -03:00
Carlos Antonio da Silva
c7a719a979 Add changelog for #5429
[ci skip]
2023-03-01 22:20:37 -03:00
Matt Redmond
60c5774ff4 Delegate sign_in_after_reset_password to resource class
Allows resource class scopes to overrides the global configuration for sign in after reset password behaviour.
2023-03-01 22:18:16 -03:00
Peter Goldstein
90f46bac37 Monkeypatch webrat for Nokogiri compatibility
This is an attempt to address the Webrat / Nokogiri compatibility issue
[discussed here]. It monkeypatches Webrat to explicitly add the old
default arguments to the invocation of to_xpath.

Move monkey patch to its own file under test/support/webrat.
I really need to get rid of webrat.

Closes #5475

[discussed here] https://github.com/sparklemotion/nokogiri/issues/2469
2023-03-01 22:06:40 -03:00
Carlos Antonio da Silva
ee8f0f8e83 Fix frozen string in validatable, use multiline string instead. (#5563)
Expand tests to check for the actual validatable exception message

This was raising a `FrozenError` on Ruby < 3 where interpolated strings
were considered frozen. This [changed in Ruby 3], since such strings are
dynamic there's no point in freezing them by default.

The test wasn't catching this because `FrozenError` actually inherits
from `RuntimeError`:

>> FrozenError.ancestors
=> [FrozenError, RuntimeError, StandardError, Exception, Object ...]

So the exception check passed. Now we're also checking for the error
message to ensure it raised the exception we really expected there.

Closes #5465

[changed in Ruby 3] https://bugs.ruby-lang.org/issues/17104

Co-authored-by: Martin <martin@edv-beratung-meier.de>
2023-03-01 19:56:25 -03:00
Carlos Antonio da Silva
41e2db2120 It is not required to copy the views when customizing controllers
It is indeed recommended for consistency, but Rails will be able to find
the views under `devise/` due to inheritance still, so make that a bit
clearer in the readme docs about customizing controllers, explaining
that copying or moving the views is an optional step.

Closes #5526
[ci skip]
2023-02-20 10:26:59 -03:00
Carlos Antonio da Silva
7f419bf99a Release Devise v4.9.0 v4.9.0 2023-02-17 11:14:03 -03:00
Carlos Antonio da Silva
44f0fd741f Update copyright year [ci skip]
Closes #5556
2023-02-16 09:10:59 -03:00
Carlos Antonio da Silva
2d655ea46e Merge pull request #5554 from JunichiIto/fix-unhappy-markup
Remove p tag since p tags cannot contain other block elements
2023-02-14 08:58:23 -03:00
Junichi Ito
49ed129c40 Replce p tag with div since p tags cannot contain other block elements 2023-02-14 08:34:26 +09:00
Carlos Antonio da Silva
8e2e3f6fda Merge pull request #5548 from heartcombo/ca-turbo
Integrate with Hotwire/Turbo by configuring error and response statuses
2023-02-09 18:14:01 -03:00