rodauth-rails 1.5.0 → 1.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +32 -0
- data/README.md +16 -13
- data/lib/generators/rodauth/install_generator.rb +11 -0
- data/lib/generators/rodauth/migration/sequel/base.erb +7 -9
- data/lib/generators/rodauth/templates/test/fixtures/accounts.yml +10 -0
- data/lib/rodauth/rails/app.rb +6 -0
- data/lib/rodauth/rails/feature/instrumentation.rb +1 -1
- data/lib/rodauth/rails/tasks.rake +19 -5
- data/lib/rodauth/rails/version.rb +1 -1
- data/rodauth-rails.gemspec +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c63496f359a15bb061b6b419a609cbe63c24991e156731721d9f077ecf9deac4
|
4
|
+
data.tar.gz: 68212d9c722391c8c79f8bf8c48f8a05a39410ea0d97396876a6c2f5e92f103a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3632843dbd0214b73fa23134a0f2b42ec3b8f1c33430af1c776c685956ccf50e475840993299bff9863491456a369ad42b7e688e3ed03b783e51f4585d6be621
|
7
|
+
data.tar.gz: 6c123e024a51d3c2ba6b224b64c1f21d3b46363523d5b498e93fbe659052489660a61a3dd83da5080a07067d9052a82450da17a7bf156e9c905b2aa81ca861f6
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,35 @@
|
|
1
|
+
## 1.5.4 (2022-07-21)
|
2
|
+
|
3
|
+
* Generate account fixtures in `spec/fixtures` directory when using RSpec (@benkoshy)
|
4
|
+
|
5
|
+
* Generate account fixtures in `test/fixtures` directory instead of `app/test/fixtures` (@benkoshy)
|
6
|
+
|
7
|
+
* Use string status column values in generated accounts fixture (@janko)
|
8
|
+
|
9
|
+
* Create integer status column in generated Sequel migration (@janko)
|
10
|
+
|
11
|
+
* Store password hash in accounts table in generated Sequel migration (@janko)
|
12
|
+
|
13
|
+
## 1.5.3 (2022-07-21)
|
14
|
+
|
15
|
+
*Yanked*
|
16
|
+
|
17
|
+
## 1.5.2 (2022-07-03)
|
18
|
+
|
19
|
+
* Bump Rodauth dependency version to 2.25+ (@janko)
|
20
|
+
|
21
|
+
* Generate fixture file for accounts on `rodauth:install` (@benkoshy)
|
22
|
+
|
23
|
+
* Fix error about undefined `controller_path` method in `newrelic_rpm` gem instrumentation (@janko)
|
24
|
+
|
25
|
+
* Don't display disabled routes in `rodauth:routes` (@janko)
|
26
|
+
|
27
|
+
* Display HTTP verbs of endpoints in `rodauth:routes` rake task (@janko)
|
28
|
+
|
29
|
+
## 1.5.1 (2022-06-19)
|
30
|
+
|
31
|
+
* Fix syntax for creating `citext` PG extension in Sequel base migration (@Empact)
|
32
|
+
|
1
33
|
## 1.5.0 (2022-06-11)
|
2
34
|
|
3
35
|
* Remove `content_for` calls from generated view templates (@janko)
|
data/README.md
CHANGED
@@ -14,6 +14,7 @@ Provides Rails integration for the [Rodauth] authentication framework.
|
|
14
14
|
🎥 Screencasts:
|
15
15
|
|
16
16
|
* [Rails Authentication with Rodauth](https://www.youtube.com/watch?v=2hDpNikacf0)
|
17
|
+
* [Multifactor Authentication via TOTP with Rodauth](https://www.youtube.com/watch?v=9ON-kgXpz2A)
|
17
18
|
|
18
19
|
📚 Articles:
|
19
20
|
|
@@ -66,7 +67,7 @@ Next, run the install generator:
|
|
66
67
|
$ rails generate rodauth:install
|
67
68
|
```
|
68
69
|
|
69
|
-
Or if you want Rodauth endpoints to be exposed via JSON API:
|
70
|
+
Or if you want Rodauth endpoints to be exposed via [JSON API]:
|
70
71
|
|
71
72
|
```sh
|
72
73
|
$ rails generate rodauth:install --json # regular authentication using the Rails session
|
@@ -110,18 +111,18 @@ $ rails rodauth:routes
|
|
110
111
|
```
|
111
112
|
Routes handled by RodauthApp:
|
112
113
|
|
113
|
-
/login rodauth.login_path
|
114
|
-
/create-account rodauth.create_account_path
|
115
|
-
/verify-account-resend rodauth.verify_account_resend_path
|
116
|
-
/verify-account rodauth.verify_account_path
|
117
|
-
/change-password rodauth.change_password_path
|
118
|
-
/change-login rodauth.change_login_path
|
119
|
-
/logout rodauth.logout_path
|
120
|
-
/remember rodauth.remember_path
|
121
|
-
/reset-password-request rodauth.reset_password_request_path
|
122
|
-
/reset-password rodauth.reset_password_path
|
123
|
-
/verify-login-change rodauth.verify_login_change_path
|
124
|
-
/close-account rodauth.close_account_path
|
114
|
+
GET/POST /login rodauth.login_path
|
115
|
+
GET/POST /create-account rodauth.create_account_path
|
116
|
+
GET/POST /verify-account-resend rodauth.verify_account_resend_path
|
117
|
+
GET/POST /verify-account rodauth.verify_account_path
|
118
|
+
GET/POST /change-password rodauth.change_password_path
|
119
|
+
GET/POST /change-login rodauth.change_login_path
|
120
|
+
GET/POST /logout rodauth.logout_path
|
121
|
+
GET/POST /remember rodauth.remember_path
|
122
|
+
GET/POST /reset-password-request rodauth.reset_password_request_path
|
123
|
+
GET/POST /reset-password rodauth.reset_password_path
|
124
|
+
GET/POST /verify-login-change rodauth.verify_login_change_path
|
125
|
+
GET/POST /close-account rodauth.close_account_path
|
125
126
|
```
|
126
127
|
|
127
128
|
Using this information, you can add some basic authentication links to your
|
@@ -381,6 +382,7 @@ class RodauthController < ApplicationController
|
|
381
382
|
when rodauth.login_path,
|
382
383
|
rodauth.create_account_path,
|
383
384
|
rodauth.verify_account_path,
|
385
|
+
rodauth.verify_account_resend_path,
|
384
386
|
rodauth.reset_password_path,
|
385
387
|
rodauth.reset_password_request_path
|
386
388
|
"authentication"
|
@@ -1214,3 +1216,4 @@ conduct](https://github.com/janko/rodauth-rails/blob/master/CODE_OF_CONDUCT.md).
|
|
1214
1216
|
[custom mailer worker]: https://github.com/janko/rodauth-rails/wiki/Custom-Mailer-Worker
|
1215
1217
|
[Turbo]: https://turbo.hotwired.dev/
|
1216
1218
|
[rodauth-model]: https://github.com/janko/rodauth-model
|
1219
|
+
[JSON API]: https://github.com/janko/rodauth-rails/wiki/JSON-API
|
@@ -70,6 +70,17 @@ module Rodauth
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
+
def create_fixtures
|
74
|
+
test_unit_options = ::Rails.application.config.generators.options[:test_unit]
|
75
|
+
if test_unit_options[:fixture] && test_unit_options[:fixture_replacement].nil?
|
76
|
+
if ::Rails.application.config.generators.options[:rails][:test_framework] == :rspec
|
77
|
+
template "test/fixtures/accounts.yml", "spec/fixtures/accounts.yml"
|
78
|
+
else
|
79
|
+
template "test/fixtures/accounts.yml", "test/fixtures/accounts.yml"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
73
84
|
def show_instructions
|
74
85
|
readme "INSTRUCTIONS" if behavior == :invoke
|
75
86
|
end
|
@@ -1,5 +1,8 @@
|
|
1
1
|
<% if db.database_type == :postgres -%>
|
2
|
-
|
2
|
+
begin
|
3
|
+
run "CREATE EXTENSION IF NOT EXISTS citext"
|
4
|
+
rescue NoMethodError # migration is being reverted
|
5
|
+
end
|
3
6
|
|
4
7
|
<% end -%>
|
5
8
|
create_table :accounts do
|
@@ -10,16 +13,11 @@ create_table :accounts do
|
|
10
13
|
<% else -%>
|
11
14
|
String :email, null: false
|
12
15
|
<% end -%>
|
13
|
-
|
16
|
+
Integer :status, null: false, default: 1
|
14
17
|
<% if db.supports_partial_indexes? -%>
|
15
|
-
index :email, unique: true, where: { status: [
|
18
|
+
index :email, unique: true, where: { status: [1, 2] }
|
16
19
|
<% else -%>
|
17
20
|
index :email, unique: true
|
18
21
|
<% end -%>
|
19
|
-
|
20
|
-
|
21
|
-
# Used if storing password hashes in a separate table (default)
|
22
|
-
create_table :account_password_hashes do
|
23
|
-
foreign_key :id, :accounts, primary_key: true, type: :Bignum
|
24
|
-
String :password_hash, null: false
|
22
|
+
String :password_hash
|
25
23
|
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
2
|
+
one:
|
3
|
+
email: freddie@queen.com
|
4
|
+
password_hash: <%%= BCrypt::Password.create("password", cost: BCrypt::Engine::MIN_COST) %>
|
5
|
+
status: verified
|
6
|
+
|
7
|
+
two:
|
8
|
+
email: brian@queen.com
|
9
|
+
password_hash: <%%= BCrypt::Password.create("password", cost: BCrypt::Engine::MIN_COST) %>
|
10
|
+
status: verified
|
data/lib/rodauth/rails/app.rb
CHANGED
@@ -59,6 +59,12 @@ module Rodauth
|
|
59
59
|
rodauth(name) or fail ArgumentError, "unknown rodauth configuration: #{name.inspect}"
|
60
60
|
end
|
61
61
|
|
62
|
+
# The newrelic_rpm gem expects this when we pass the roda class as
|
63
|
+
# :controller in instrumentation payload.
|
64
|
+
def self.controller_path
|
65
|
+
name.underscore
|
66
|
+
end
|
67
|
+
|
62
68
|
module RequestMethods
|
63
69
|
def rodauth(name = nil)
|
64
70
|
prefix = scope.rodauth(name).prefix
|
@@ -6,20 +6,34 @@ namespace :rodauth do
|
|
6
6
|
|
7
7
|
app.opts[:rodauths].each do |configuration_name, auth_class|
|
8
8
|
rodauth = auth_class.allocate
|
9
|
+
only_json = rodauth.method(:only_json?).owner != Rodauth::Base && rodauth.only_json?
|
10
|
+
|
11
|
+
routes = auth_class.route_hash.map do |path, handle_method|
|
12
|
+
file_path, start_line = rodauth.method(:"_#{handle_method}").source_location
|
13
|
+
lines = File.foreach(file_path).to_a
|
14
|
+
indentation = lines[start_line - 1][/^\s+/]
|
15
|
+
verbs = []
|
16
|
+
|
17
|
+
lines[start_line..-1].each do |code|
|
18
|
+
verbs << :GET if code.include?("r.get") && !only_json
|
19
|
+
verbs << :POST if code.include?("r.post")
|
20
|
+
break if code.start_with?("#{indentation}end")
|
21
|
+
end
|
9
22
|
|
10
|
-
routes = auth_class.routes.map do |handle_method|
|
11
23
|
path_method = "#{handle_method.to_s.sub(/\Ahandle_/, "")}_path"
|
12
24
|
|
13
25
|
[
|
14
|
-
|
26
|
+
verbs.join("/"),
|
27
|
+
"#{rodauth.prefix}#{path}",
|
15
28
|
"rodauth#{configuration_name && "(:#{configuration_name})"}.#{path_method}",
|
16
29
|
]
|
17
30
|
end
|
18
31
|
|
19
|
-
|
32
|
+
verbs_padding = routes.map { |verbs, _, _| verbs.length }.max
|
33
|
+
path_padding = routes.map { |_, path, _| path.length }.max
|
20
34
|
|
21
|
-
route_lines = routes.map do |path, code|
|
22
|
-
"#{path.ljust(
|
35
|
+
route_lines = routes.map do |verbs, path, code|
|
36
|
+
"#{verbs.ljust(verbs_padding)} #{path.ljust(path_padding)} #{code}"
|
23
37
|
end
|
24
38
|
|
25
39
|
puts "\n #{route_lines.join("\n ")}" unless route_lines.empty?
|
data/rodauth-rails.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.require_paths = ["lib"]
|
18
18
|
|
19
19
|
spec.add_dependency "railties", ">= 4.2", "< 8"
|
20
|
-
spec.add_dependency "rodauth", "~> 2.
|
20
|
+
spec.add_dependency "rodauth", "~> 2.25"
|
21
21
|
spec.add_dependency "roda", "~> 3.55"
|
22
22
|
spec.add_dependency "sequel-activerecord_connection", "~> 1.1"
|
23
23
|
spec.add_dependency "rodauth-model", "~> 0.2"
|
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.5.
|
4
|
+
version: 1.5.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Janko Marohnić
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -36,14 +36,14 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '2.
|
39
|
+
version: '2.25'
|
40
40
|
type: :runtime
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '2.
|
46
|
+
version: '2.25'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: roda
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -271,6 +271,7 @@ files:
|
|
271
271
|
- lib/generators/rodauth/templates/config/initializers/rodauth.rb
|
272
272
|
- lib/generators/rodauth/templates/config/initializers/sequel.rb
|
273
273
|
- lib/generators/rodauth/templates/db/migrate/create_rodauth.rb
|
274
|
+
- lib/generators/rodauth/templates/test/fixtures/accounts.yml
|
274
275
|
- lib/generators/rodauth/views_generator.rb
|
275
276
|
- lib/rodauth-rails.rb
|
276
277
|
- lib/rodauth/rails.rb
|