rodauth-rails 1.12.0 → 1.13.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1dac2131f831b908d4bfd7a3367b310bd04b4141202b16f5e98d80e769972e32
4
- data.tar.gz: 1742fb2bb8fb16c221a4f09d5a5f53bdc898475383f91311100571e4902c8700
3
+ metadata.gz: f56967000d0a2cc64e51a707783fc541d4ff37dbb3e68f1fc519ef02a0a83e65
4
+ data.tar.gz: dfe189f65d18781e42058e133f0e403ed769421fb8682e4a63078b1f7e39cb8a
5
5
  SHA512:
6
- metadata.gz: 53dc0c219dc640431b553c8e843cc728ee1aff0c57a759dfebb0254a9e885a193ab1c3dff8d6fba6ba8423abdc49e9d6e38c14125a48a82954c42942b4a16838
7
- data.tar.gz: 07ea61d890bb27ae8cbaed4c203366ddb07c152b5f76272e2acec9865e1c7ec72472aef8b20e2a112ad831ab3bc69602f443fc80ffcb0f6b1754f1b3d317cff4
6
+ metadata.gz: f582926f90ab796d491210e28705585e166047c3b3f093e27ad556fb5271041e5c0a34ce78a42d9ec84c5b074958938527b233b750ec944043611df6f1bf7112
7
+ data.tar.gz: 04e475c871440131db6c42c1eabcecc95a34e323cfdd2ce045f59b196439d404321ee27e64b857321df642e362168e146b15ed354a3710d3fff5160ad23f18d1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## 1.13.0 (2023-12-25) :christmas_tree:
2
+
3
+ * Add `#rodauth` method to controller test helpers (@janko)
4
+
5
+ * When session middleware is required by Rodauth but missing, point to Rails docs instead of Roda (@janko)
6
+
7
+ * Set `login_confirm_param` to `"email-confirm"` in default configuration for consistency (@janko)
8
+
9
+ * Set `convert_token_id_to_integer?` in default configuration to avoid DB queries on boot (@janko)
10
+
1
11
  ## 1.12.0 (2023-10-20)
2
12
 
3
13
  * Allow generating view template for `confirm_password` feature (igor-alexandrov)
data/README.md CHANGED
@@ -10,6 +10,7 @@ Provides Rails integration for the [Rodauth] authentication framework.
10
10
  * [Rails demo](https://github.com/janko/rodauth-demo-rails)
11
11
  * [JSON API guide](https://github.com/janko/rodauth-rails/wiki/JSON-API)
12
12
  * [OmniAuth guide](https://github.com/janko/rodauth-rails/wiki/OmniAuth)
13
+ * [JSON Request Documentation for Rodauth](https://documenter.getpostman.com/view/26686011/2s9YC7SWn9)
13
14
 
14
15
  🎥 Screencasts:
15
16
 
@@ -22,7 +23,7 @@ Provides Rails integration for the [Rodauth] authentication framework.
22
23
  * [Rodauth: A Refreshing Authentication Solution for Ruby](https://janko.io/rodauth-a-refreshing-authentication-solution-for-ruby/)
23
24
  * [Rails Authentication with Rodauth](https://janko.io/adding-authentication-in-rails-with-rodauth/)
24
25
  * [Multifactor Authentication in Rails with Rodauth](https://janko.io/adding-multifactor-authentication-in-rails-with-rodauth/)
25
- * [How to build an OIDC provider using rodauth-oauth on Rails](https://honeyryderchuck.gitlab.io/httpx/2021/03/15/oidc-provider-on-rails-using-rodauth-oauth.html)
26
+ * [How to build an OIDC provider using rodauth-oauth on Rails](https://honeyryderchuck.gitlab.io/2021/03/15/oidc-provider-on-rails-using-rodauth-oauth.html)
26
27
  * [What It Took to Build a Rails Integration for Rodauth](https://janko.io/what-it-took-to-build-a-rails-integration-for-rodauth/)
27
28
  * [Social Login in Rails with Rodauth](https://janko.io/social-login-in-rails-with-rodauth/)
28
29
  * [Passkey Authentication with Rodauth](https://janko.io/passkey-authentication-with-rodauth/)
@@ -281,7 +282,7 @@ class RodauthMain < Rodauth::Rails::Auth
281
282
  after_login { rails_cookies.permanent[:last_account_id] = account_id }
282
283
  end
283
284
  end
284
- ```
285
+ ```
285
286
 
286
287
  ## Views
287
288
 
@@ -592,7 +593,7 @@ class ArticlesControllerTest < ActionDispatch::IntegrationTest
592
593
  post "/logout"
593
594
  assert_redirected_to "/"
594
595
  end
595
-
596
+
596
597
  test "required authentication" do
597
598
  get :index
598
599
 
@@ -616,7 +617,7 @@ end
616
617
  ```
617
618
 
618
619
  For more examples and information about testing with rodauth, see
619
- [this wiki page about testing](https://github.com/janko/rodauth-rails/wiki/Testing).
620
+ [this wiki page about testing](https://github.com/janko/rodauth-rails/wiki/Testing).
620
621
 
621
622
  ## Configuring
622
623
 
@@ -643,7 +644,7 @@ Rodauth::Rails.configure do |config|
643
644
  config.middleware = false # disable auto-insertion
644
645
  end
645
646
 
646
- Rails.application.config.middleware.insert_before AnotherMiddleware, Rodauth::Rails::Middleware
647
+ Rails.configuration.middleware.insert_before AnotherMiddleware, Rodauth::Rails::Middleware
647
648
  ```
648
649
 
649
650
  ## How it works
@@ -66,7 +66,7 @@ module Rodauth
66
66
  end
67
67
 
68
68
  def create_fixtures
69
- generator_options = ::Rails.application.config.generators.options
69
+ generator_options = ::Rails.configuration.generators.options
70
70
  if generator_options[:test_unit][:fixture] && generator_options[:test_unit][:fixture_replacement].nil?
71
71
  test_dir = generator_options[:rails][:test_framework] == :rspec ? "spec" : "test"
72
72
  template "test/fixtures/accounts.yml", "#{test_dir}/fixtures/#{table_prefix.pluralize}.yml"
@@ -101,17 +101,21 @@ module Rodauth
101
101
  options[:argon2]
102
102
  end
103
103
 
104
+ def primary_key_integer?
105
+ !::Rails.configuration.generators.options.dig(:active_record, :primary_key_type)
106
+ end
107
+
104
108
  def sequel_activerecord_integration?
105
109
  defined?(ActiveRecord::Railtie) &&
106
110
  (!defined?(Sequel) || Sequel::DATABASES.empty?)
107
111
  end
108
112
 
109
113
  def session_store?
110
- !!::Rails.application.config.session_store
114
+ !!::Rails.configuration.session_store
111
115
  end
112
116
 
113
117
  def api_only?
114
- ::Rails.application.config.api_only
118
+ ::Rails.configuration.api_only
115
119
  end
116
120
 
117
121
  def sequel_adapter
@@ -120,7 +120,7 @@ module Rodauth
120
120
  end
121
121
 
122
122
  def primary_key_type(key = :id)
123
- generators = ::Rails.application.config.generators
123
+ generators = ::Rails.configuration.generators
124
124
  column_type = generators.options[:active_record][:primary_key_type]
125
125
 
126
126
  if key
@@ -20,6 +20,9 @@ class RodauthMain < Rodauth::Rails::Auth
20
20
  db Sequel.<%= sequel_adapter %>(extensions: :activerecord_connection, keep_reference: false)
21
21
  <% end -%>
22
22
 
23
+ # Avoid DB query that checks accounts table schema at boot time.
24
+ convert_token_id_to_integer? <%= primary_key_integer? %>
25
+
23
26
  <% end -%>
24
27
  # Change prefix of table and foreign key column names from default "account"
25
28
  <% if table -%>
@@ -86,6 +89,7 @@ class RodauthMain < Rodauth::Rails::Auth
86
89
 
87
90
  # Change some default param keys.
88
91
  login_param "email"
92
+ login_confirm_param "email-confirm"
89
93
  # password_confirm_param "confirm_password"
90
94
 
91
95
  # Redirect back to originally requested location after authentication.
@@ -121,7 +121,7 @@ module Rodauth
121
121
  end
122
122
 
123
123
  def tailwind?
124
- ::Rails.application.config.generators.options[:rails][:template_engine] == :tailwindcss ||
124
+ ::Rails.configuration.generators.options[:rails][:template_engine] == :tailwindcss ||
125
125
  options[:css]&.downcase&.start_with?("tailwind")
126
126
  end
127
127
  end
@@ -32,7 +32,7 @@ module Rodauth
32
32
  end
33
33
 
34
34
  def rails_controller
35
- if only_json? && ::Rails.application.config.api_only
35
+ if only_json? && ::Rails.configuration.api_only
36
36
  ActionController::API
37
37
  else
38
38
  ActionController::Base
@@ -49,6 +49,12 @@ module Rodauth
49
49
 
50
50
  delegate :rails_routes, :rails_cookies, :rails_request, to: :scope
51
51
 
52
+ def session
53
+ super
54
+ rescue Roda::RodaError
55
+ fail Rodauth::Rails::Error, "There is no session middleware configured, see instructions on how to add it: https://guides.rubyonrails.org/api_app.html#using-session-middlewares"
56
+ end
57
+
52
58
  private
53
59
 
54
60
  def instantiate_rails_account
@@ -47,7 +47,7 @@ module Rodauth
47
47
  def rails_url_options
48
48
  return nil unless defined?(ActionMailer)
49
49
 
50
- ::Rails.application.config.action_mailer.default_url_options or
50
+ ::Rails.configuration.action_mailer.default_url_options or
51
51
  fail Error, "There is no information to set the URL host from. Please set config.action_mailer.default_url_options in your Rails application, or configure #domain and #base_url in your Rodauth configuration."
52
52
  end
53
53
  end
@@ -21,9 +21,9 @@ module Rodauth
21
21
 
22
22
  # Check whether it's a request to an asset managed by Sprockets or Propshaft.
23
23
  def asset_request?(env)
24
- return false unless ::Rails.application.config.respond_to?(:assets)
24
+ return false unless ::Rails.configuration.respond_to?(:assets)
25
25
 
26
- env["PATH_INFO"] =~ %r(\A/{0,2}#{::Rails.application.config.assets.prefix})
26
+ env["PATH_INFO"] =~ %r(\A/{0,2}#{::Rails.configuration.assets.prefix})
27
27
  end
28
28
  end
29
29
  end
@@ -35,6 +35,10 @@ module Rodauth
35
35
 
36
36
  response
37
37
  end
38
+
39
+ def rodauth(name = nil)
40
+ @controller.rodauth(name)
41
+ end
38
42
  end
39
43
  end
40
44
  end
@@ -1,5 +1,5 @@
1
1
  module Rodauth
2
2
  module Rails
3
- VERSION = "1.12.0"
3
+ VERSION = "1.13.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rodauth-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.0
4
+ version: 1.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janko Marohnić
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-20 00:00:00.000000000 Z
11
+ date: 2023-12-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties