rodauth-rails 1.15.2 → 2.0.1
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/README.md +8 -4
- data/lib/generators/rodauth/install_generator.rb +17 -1
- data/lib/generators/rodauth/mailer_generator.rb +1 -5
- data/lib/generators/rodauth/migration/active_record/base.erb +1 -0
- data/lib/generators/rodauth/migration_generator.rb +2 -10
- data/lib/generators/rodauth/views_generator.rb +0 -11
- data/lib/rodauth/rails/controller_methods.rb +1 -5
- data/lib/rodauth/rails/feature/email.rb +6 -8
- data/lib/rodauth/rails/feature/instrumentation.rb +1 -1
- data/lib/rodauth/rails/mailer.rb +9 -0
- data/lib/rodauth/rails/version.rb +1 -1
- data/lib/rodauth/rails.rb +2 -11
- data/rodauth-rails.gemspec +3 -4
- metadata +11 -25
- data/lib/rodauth/rails/model.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cca905fd1f4b103aef68317cf45c2758d432b32c0f91a50e2f896c83750c4567
|
4
|
+
data.tar.gz: 3170987bb8ba8821d66c2ad46369be451069d3cac01d0bcc6aa7f3e149b150f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13108dbbf6bedd2201c58b4377defbc9a41fa893c874b5ac833c1fd63d3b2b418dc397c59a50cc1eede6739d5d4e6a9d682e10f5a061645f8cd0eae9ac2cb0cb
|
7
|
+
data.tar.gz: d0bec919f0fdadfb978b15c6da1e35ba18a823c27b4e75b715eac536bff8a9f886567b3ff918384594546ed4f31de4897bb886164ebbc0a622cadd7e01b45eb4
|
data/README.md
CHANGED
@@ -90,17 +90,15 @@ $ rails generate rodauth:install users
|
|
90
90
|
If you want Rodauth endpoints to be exposed via [JSON API]:
|
91
91
|
|
92
92
|
```sh
|
93
|
-
$ rails generate rodauth:install --json #
|
93
|
+
$ rails generate rodauth:install --json # cookied-based authentication
|
94
94
|
# or
|
95
|
-
$ rails generate rodauth:install --jwt # token authentication
|
96
|
-
$ bundle add jwt
|
95
|
+
$ rails generate rodauth:install --jwt # token-based authentication
|
97
96
|
```
|
98
97
|
|
99
98
|
To use Argon2 instead of bcrypt for password hashing:
|
100
99
|
|
101
100
|
```sh
|
102
101
|
$ rails generate rodauth:install --argon2
|
103
|
-
$ bundle add argon2
|
104
102
|
```
|
105
103
|
|
106
104
|
## Usage
|
@@ -672,6 +670,11 @@ $ rails middleware
|
|
672
670
|
# run MyApp::Application.routes
|
673
671
|
```
|
674
672
|
|
673
|
+
> [!NOTE]
|
674
|
+
> If you're using a middleware that should be called before Rodauth routes, make sure that middleware is inserted *before* Rodauth.
|
675
|
+
>
|
676
|
+
> For example, if you're using [Rack::Attack] to throttle signups, make sure you put the `rack-attack` gem *above* `rodauth-rails` in the Gemfile, so that its middleware is inserted first.
|
677
|
+
|
675
678
|
### Roda app
|
676
679
|
|
677
680
|
The [`Rodauth::Rails::App`](/lib/rodauth/rails/app.rb) class is a [Roda]
|
@@ -795,3 +798,4 @@ conduct](CODE_OF_CONDUCT.md).
|
|
795
798
|
[inheritance]: http://rodauth.jeremyevans.net/rdoc/files/doc/guides/share_configuration_rdoc.html
|
796
799
|
[library]: https://github.com/jeremyevans/rodauth#label-Using+Rodauth+as+a+Library
|
797
800
|
[restoring defaults]: https://github.com/janko/rodauth-rails/wiki/Restoring-Rodauth-Defaults
|
801
|
+
[Rack::Attack]: https://github.com/rack/rack-attack
|
@@ -38,6 +38,22 @@ module Rodauth
|
|
38
38
|
template "app/misc/rodauth_main.rb"
|
39
39
|
end
|
40
40
|
|
41
|
+
def add_gems
|
42
|
+
if activerecord? && !sequel?
|
43
|
+
gem "sequel-activerecord_connection", "~> 2.0", comment: "Enables Sequel to use Active Record's database connection"
|
44
|
+
gem "after_commit_everywhere", "~> 1.1", comment: "Required for Sequel's transaction hooks to work in all cases (on Active Record < 7.2)" if ActiveRecord.version < Gem::Version.new("7.2")
|
45
|
+
end
|
46
|
+
if argon2?
|
47
|
+
gem "argon2", "~> 2.3", comment: "Used by Rodauth for password hashing"
|
48
|
+
else
|
49
|
+
gem "bcrypt", "~> 3.1", comment: "Used by Rodauth for password hashing"
|
50
|
+
end
|
51
|
+
if jwt?
|
52
|
+
gem "jwt", "~> 2.9", comment: "Used by Rodauth for JWT support"
|
53
|
+
end
|
54
|
+
gem "tilt", "~> 2.4", comment: "Used by Rodauth for rendering built-in view and email templates"
|
55
|
+
end
|
56
|
+
|
41
57
|
def create_rodauth_controller
|
42
58
|
template "app/controllers/rodauth_controller.rb"
|
43
59
|
end
|
@@ -55,7 +71,7 @@ module Rodauth
|
|
55
71
|
end
|
56
72
|
|
57
73
|
def show_instructions
|
58
|
-
readme "INSTRUCTIONS" if behavior == :invoke && !
|
74
|
+
readme "INSTRUCTIONS" if behavior == :invoke && !json? && !jwt?
|
59
75
|
end
|
60
76
|
|
61
77
|
private
|
@@ -83,11 +83,7 @@ module Rodauth
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def erb_eval(content)
|
86
|
-
|
87
|
-
ERB.new(content, trim_mode: "-").result(binding)
|
88
|
-
else
|
89
|
-
ERB.new(content, 0, "-").result(binding)
|
90
|
-
end
|
86
|
+
ERB.new(content, trim_mode: "-").result(binding)
|
91
87
|
end
|
92
88
|
|
93
89
|
def emails
|
@@ -7,6 +7,7 @@ create_table :<%= table_prefix.pluralize %><%= primary_key_type %> do |t|
|
|
7
7
|
<% case activerecord_adapter -%>
|
8
8
|
<% when "postgresql" -%>
|
9
9
|
t.citext :email, null: false
|
10
|
+
t.check_constraint "email ~ '^[^,;@ \r\n]+@[^,@; \r\n]+\.[^,@; \r\n]+$'", name: "valid_email"
|
10
11
|
<% else -%>
|
11
12
|
t.string :email, null: false
|
12
13
|
<% end -%>
|
@@ -54,11 +54,7 @@ module Rodauth
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def erb_eval(content)
|
57
|
-
|
58
|
-
ERB.new(content, trim_mode: "-").result(binding)
|
59
|
-
else
|
60
|
-
ERB.new(content, 0, "-").result(binding)
|
61
|
-
end
|
57
|
+
ERB.new(content, trim_mode: "-").result(binding)
|
62
58
|
end
|
63
59
|
|
64
60
|
def migration_chunk(feature)
|
@@ -132,11 +128,7 @@ module Rodauth
|
|
132
128
|
end
|
133
129
|
|
134
130
|
def default_primary_key_type
|
135
|
-
|
136
|
-
:bigint
|
137
|
-
else
|
138
|
-
:integer
|
139
|
-
end
|
131
|
+
activerecord_adapter == "sqlite3" ? :integer : :bigint
|
140
132
|
end
|
141
133
|
|
142
134
|
# Active Record 7+ sets default precision to 6 for timestamp columns,
|
@@ -52,7 +52,6 @@ module Rodauth
|
|
52
52
|
copy_file view_location(view), "app/views/#{directory}/#{view}.html.erb" do |content|
|
53
53
|
content = content.gsub("rodauth.", "rodauth(:#{configuration_name}).") if configuration_name
|
54
54
|
content = content.gsub("rodauth/", "#{directory}/")
|
55
|
-
content = form_helpers_compatibility(content) if ActionView.version < Gem::Version.new("5.1")
|
56
55
|
content
|
57
56
|
end
|
58
57
|
end
|
@@ -103,16 +102,6 @@ module Rodauth
|
|
103
102
|
options[:name]&.to_sym
|
104
103
|
end
|
105
104
|
|
106
|
-
# We need to use the *_tag helpers on versions lower than Rails 5.1.
|
107
|
-
def form_helpers_compatibility(content)
|
108
|
-
content
|
109
|
-
.gsub(/form_with url: (.+) do \|form\|/, 'form_tag \1 do')
|
110
|
-
.gsub(/form\.(label|submit)/, '\1_tag')
|
111
|
-
.gsub(/form\.(email|password|text|telephone|hidden)_field (\S+), value:/, '\1_field_tag \2,')
|
112
|
-
.gsub(/form\.radio_button (\S+), (\S+),/, 'radio_button_tag \1, \2, false,')
|
113
|
-
.gsub(/form\.check_box (\S+), (.+) /, 'check_box_tag \1, "t", false, \2 ')
|
114
|
-
end
|
115
|
-
|
116
105
|
def view_location(view)
|
117
106
|
if tailwind?
|
118
107
|
"app/views/rodauth/tailwind/#{view}.html.erb"
|
@@ -4,14 +4,10 @@ module Rodauth
|
|
4
4
|
def self.included(controller)
|
5
5
|
# ActionController::API doesn't have helper methods
|
6
6
|
if controller.respond_to?(:helper_method)
|
7
|
-
controller.helper_method :rodauth
|
7
|
+
controller.helper_method :rodauth
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
def current_account(name = nil)
|
12
|
-
rodauth(name).rails_account
|
13
|
-
end
|
14
|
-
|
15
11
|
def rodauth(name = nil)
|
16
12
|
request.env.fetch ["rodauth", *name].join(".")
|
17
13
|
end
|
@@ -12,20 +12,18 @@ module Rodauth
|
|
12
12
|
|
13
13
|
# Create emails with ActionMailer which uses configured delivery method.
|
14
14
|
def create_email_to(to, subject, body)
|
15
|
-
Mailer.create_email(
|
15
|
+
Rodauth::Rails::Mailer.create_email(
|
16
|
+
to: to,
|
17
|
+
from: email_from,
|
18
|
+
subject: "#{email_subject_prefix}#{subject}",
|
19
|
+
body: body
|
20
|
+
)
|
16
21
|
end
|
17
22
|
|
18
23
|
# Delivers the given email.
|
19
24
|
def send_email(email)
|
20
25
|
email.deliver_now
|
21
26
|
end
|
22
|
-
|
23
|
-
# ActionMailer subclass for correct email delivering.
|
24
|
-
class Mailer < ActionMailer::Base
|
25
|
-
def create_email(options)
|
26
|
-
mail(options)
|
27
|
-
end
|
28
|
-
end
|
29
27
|
end
|
30
28
|
end
|
31
29
|
end
|
data/lib/rodauth/rails.rb
CHANGED
@@ -7,10 +7,10 @@ module Rodauth
|
|
7
7
|
class Error < StandardError
|
8
8
|
end
|
9
9
|
|
10
|
-
# This allows
|
10
|
+
# This allows avoiding loading Rodauth at boot time.
|
11
11
|
autoload :App, "rodauth/rails/app"
|
12
12
|
autoload :Auth, "rodauth/rails/auth"
|
13
|
-
autoload :
|
13
|
+
autoload :Mailer, "rodauth/rails/mailer"
|
14
14
|
|
15
15
|
@app = nil
|
16
16
|
@middleware = true
|
@@ -66,15 +66,6 @@ module Rodauth
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
-
def authenticated(name = nil, &condition)
|
70
|
-
warn "Rodauth::Rails.authenticated has been deprecated in favor of Rodauth::Rails.authenticate, which additionally requires existence of the account record."
|
71
|
-
lambda do |request|
|
72
|
-
rodauth = request.env.fetch ["rodauth", *name].join(".")
|
73
|
-
rodauth.require_authentication
|
74
|
-
rodauth.authenticated? && (condition.nil? || condition.call(rodauth))
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
69
|
if ::Rails.gem_version >= Gem::Version.new("5.2")
|
79
70
|
def secret_key_base
|
80
71
|
::Rails.application.secret_key_base
|
data/rodauth-rails.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.homepage = "https://github.com/janko/rodauth-rails"
|
12
12
|
spec.license = "MIT"
|
13
13
|
|
14
|
-
spec.required_ruby_version = ">= 2.
|
14
|
+
spec.required_ruby_version = ">= 2.6"
|
15
15
|
|
16
16
|
spec.files = Dir["README.md", "LICENSE.txt", "lib/**/*", "*.gemspec"]
|
17
17
|
spec.require_paths = ["lib"]
|
@@ -19,11 +19,10 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.add_dependency "railties", ">= 5.0", "< 8.1"
|
20
20
|
spec.add_dependency "rodauth", "~> 2.36"
|
21
21
|
spec.add_dependency "roda", "~> 3.76"
|
22
|
-
spec.add_dependency "sequel-activerecord_connection", "~> 1.1"
|
23
22
|
spec.add_dependency "rodauth-model", "~> 0.2"
|
24
|
-
spec.add_dependency "tilt"
|
25
|
-
spec.add_dependency "bcrypt"
|
26
23
|
|
24
|
+
spec.add_development_dependency "tilt"
|
25
|
+
spec.add_development_dependency "bcrypt", "~> 3.1"
|
27
26
|
spec.add_development_dependency "jwt"
|
28
27
|
spec.add_development_dependency "rotp"
|
29
28
|
spec.add_development_dependency "rqrcode"
|
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:
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Janko Marohnić
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -58,20 +58,6 @@ dependencies:
|
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '3.76'
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
|
-
name: sequel-activerecord_connection
|
63
|
-
requirement: !ruby/object:Gem::Requirement
|
64
|
-
requirements:
|
65
|
-
- - "~>"
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: '1.1'
|
68
|
-
type: :runtime
|
69
|
-
prerelease: false
|
70
|
-
version_requirements: !ruby/object:Gem::Requirement
|
71
|
-
requirements:
|
72
|
-
- - "~>"
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
version: '1.1'
|
75
61
|
- !ruby/object:Gem::Dependency
|
76
62
|
name: rodauth-model
|
77
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -93,7 +79,7 @@ dependencies:
|
|
93
79
|
- - ">="
|
94
80
|
- !ruby/object:Gem::Version
|
95
81
|
version: '0'
|
96
|
-
type: :
|
82
|
+
type: :development
|
97
83
|
prerelease: false
|
98
84
|
version_requirements: !ruby/object:Gem::Requirement
|
99
85
|
requirements:
|
@@ -104,16 +90,16 @@ dependencies:
|
|
104
90
|
name: bcrypt
|
105
91
|
requirement: !ruby/object:Gem::Requirement
|
106
92
|
requirements:
|
107
|
-
- - "
|
93
|
+
- - "~>"
|
108
94
|
- !ruby/object:Gem::Version
|
109
|
-
version: '
|
110
|
-
type: :
|
95
|
+
version: '3.1'
|
96
|
+
type: :development
|
111
97
|
prerelease: false
|
112
98
|
version_requirements: !ruby/object:Gem::Requirement
|
113
99
|
requirements:
|
114
|
-
- - "
|
100
|
+
- - "~>"
|
115
101
|
- !ruby/object:Gem::Version
|
116
|
-
version: '
|
102
|
+
version: '3.1'
|
117
103
|
- !ruby/object:Gem::Dependency
|
118
104
|
name: jwt
|
119
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -351,8 +337,8 @@ files:
|
|
351
337
|
- lib/rodauth/rails/feature/instrumentation.rb
|
352
338
|
- lib/rodauth/rails/feature/internal_request.rb
|
353
339
|
- lib/rodauth/rails/feature/render.rb
|
340
|
+
- lib/rodauth/rails/mailer.rb
|
354
341
|
- lib/rodauth/rails/middleware.rb
|
355
|
-
- lib/rodauth/rails/model.rb
|
356
342
|
- lib/rodauth/rails/railtie.rb
|
357
343
|
- lib/rodauth/rails/tasks.rake
|
358
344
|
- lib/rodauth/rails/tasks/routes.rb
|
@@ -372,14 +358,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
372
358
|
requirements:
|
373
359
|
- - ">="
|
374
360
|
- !ruby/object:Gem::Version
|
375
|
-
version: '2.
|
361
|
+
version: '2.6'
|
376
362
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
377
363
|
requirements:
|
378
364
|
- - ">="
|
379
365
|
- !ruby/object:Gem::Version
|
380
366
|
version: '0'
|
381
367
|
requirements: []
|
382
|
-
rubygems_version: 3.5.
|
368
|
+
rubygems_version: 3.5.22
|
383
369
|
signing_key:
|
384
370
|
specification_version: 4
|
385
371
|
summary: Provides Rails integration for Rodauth authentication framework.
|