rodauth-rails 1.15.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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/instrumentation.rb +1 -1
- data/lib/rodauth/rails/version.rb +1 -1
- data/lib/rodauth/rails.rb +1 -11
- data/rodauth-rails.gemspec +3 -4
- metadata +10 -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: d494712a7d9e548251e812cfb962c74c170663905f4b07f239d7c32f01f2a4c3
|
4
|
+
data.tar.gz: 064204c2a262f5cae1360d8509623595a333acb43cbf421f0bfa45bb6b7de36a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a8a072ee2d3f615f14df9484ff04a1d1f85ebbef0aa0273087fca7042d437ac04e8628392e56b81c4ab23940aa7a3b4ca324899d53079d51bd5dda296429285
|
7
|
+
data.tar.gz: a79173adc2a6edd193e8cdb5b11124387f3cc0ab8c001032fe564ed0824ef0a007b5bcadeab98800c149ad303aa5f032359e0cca917c2491a34c8c10ebc0dc22
|
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
|
data/lib/rodauth/rails.rb
CHANGED
@@ -7,10 +7,9 @@ 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 :Model, "rodauth/rails/model"
|
14
13
|
|
15
14
|
@app = nil
|
16
15
|
@middleware = true
|
@@ -66,15 +65,6 @@ module Rodauth
|
|
66
65
|
end
|
67
66
|
end
|
68
67
|
|
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
68
|
if ::Rails.gem_version >= Gem::Version.new("5.2")
|
79
69
|
def secret_key_base
|
80
70
|
::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.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: 2024-
|
11
|
+
date: 2024-12-16 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
|
@@ -352,7 +338,6 @@ files:
|
|
352
338
|
- lib/rodauth/rails/feature/internal_request.rb
|
353
339
|
- lib/rodauth/rails/feature/render.rb
|
354
340
|
- lib/rodauth/rails/middleware.rb
|
355
|
-
- lib/rodauth/rails/model.rb
|
356
341
|
- lib/rodauth/rails/railtie.rb
|
357
342
|
- lib/rodauth/rails/tasks.rake
|
358
343
|
- lib/rodauth/rails/tasks/routes.rb
|
@@ -372,14 +357,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
372
357
|
requirements:
|
373
358
|
- - ">="
|
374
359
|
- !ruby/object:Gem::Version
|
375
|
-
version: '2.
|
360
|
+
version: '2.6'
|
376
361
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
377
362
|
requirements:
|
378
363
|
- - ">="
|
379
364
|
- !ruby/object:Gem::Version
|
380
365
|
version: '0'
|
381
366
|
requirements: []
|
382
|
-
rubygems_version: 3.5.
|
367
|
+
rubygems_version: 3.5.22
|
383
368
|
signing_key:
|
384
369
|
specification_version: 4
|
385
370
|
summary: Provides Rails integration for Rodauth authentication framework.
|