rodauth-rails 1.12.0 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +6 -5
- data/lib/generators/rodauth/install_generator.rb +7 -3
- data/lib/generators/rodauth/migration_generator.rb +1 -1
- data/lib/generators/rodauth/templates/app/misc/rodauth_main.rb.tt +4 -0
- data/lib/generators/rodauth/views_generator.rb +1 -1
- data/lib/rodauth/rails/feature/base.rb +7 -1
- data/lib/rodauth/rails/feature/internal_request.rb +1 -1
- data/lib/rodauth/rails/middleware.rb +2 -2
- data/lib/rodauth/rails/test/controller.rb +4 -0
- data/lib/rodauth/rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f56967000d0a2cc64e51a707783fc541d4ff37dbb3e68f1fc519ef02a0a83e65
|
4
|
+
data.tar.gz: dfe189f65d18781e42058e133f0e403ed769421fb8682e4a63078b1f7e39cb8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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/
|
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.
|
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.
|
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.
|
114
|
+
!!::Rails.configuration.session_store
|
111
115
|
end
|
112
116
|
|
113
117
|
def api_only?
|
114
|
-
::Rails.
|
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.
|
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.
|
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.
|
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.
|
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.
|
24
|
+
return false unless ::Rails.configuration.respond_to?(:assets)
|
25
25
|
|
26
|
-
env["PATH_INFO"] =~ %r(\A/{0,2}#{::Rails.
|
26
|
+
env["PATH_INFO"] =~ %r(\A/{0,2}#{::Rails.configuration.assets.prefix})
|
27
27
|
end
|
28
28
|
end
|
29
29
|
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.
|
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-
|
11
|
+
date: 2023-12-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|