rodauth-rails 1.2.2 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +22 -0
- data/README.md +108 -2
- data/lib/generators/rodauth/install_generator.rb +9 -10
- data/lib/generators/rodauth/migration/{account_expiration.erb → active_record/account_expiration.erb} +0 -0
- data/lib/generators/rodauth/migration/{active_sessions.erb → active_record/active_sessions.erb} +0 -0
- data/lib/generators/rodauth/migration/{audit_logging.erb → active_record/audit_logging.erb} +0 -0
- data/lib/generators/rodauth/migration/{base.erb → active_record/base.erb} +2 -7
- data/lib/generators/rodauth/migration/{disallow_password_reuse.erb → active_record/disallow_password_reuse.erb} +1 -1
- data/lib/generators/rodauth/migration/{email_auth.erb → active_record/email_auth.erb} +0 -0
- data/lib/generators/rodauth/migration/{jwt_refresh.erb → active_record/jwt_refresh.erb} +0 -0
- data/lib/generators/rodauth/migration/{lockout.erb → active_record/lockout.erb} +0 -0
- data/lib/generators/rodauth/migration/{otp.erb → active_record/otp.erb} +0 -0
- data/lib/generators/rodauth/migration/{password_expiration.erb → active_record/password_expiration.erb} +0 -0
- data/lib/generators/rodauth/migration/{recovery_codes.erb → active_record/recovery_codes.erb} +0 -0
- data/lib/generators/rodauth/migration/{remember.erb → active_record/remember.erb} +0 -0
- data/lib/generators/rodauth/migration/{reset_password.erb → active_record/reset_password.erb} +0 -0
- data/lib/generators/rodauth/migration/{single_session.erb → active_record/single_session.erb} +0 -0
- data/lib/generators/rodauth/migration/{sms_codes.erb → active_record/sms_codes.erb} +0 -0
- data/lib/generators/rodauth/migration/{verify_account.erb → active_record/verify_account.erb} +0 -0
- data/lib/generators/rodauth/migration/{verify_login_change.erb → active_record/verify_login_change.erb} +0 -0
- data/lib/generators/rodauth/migration/{webauthn.erb → active_record/webauthn.erb} +0 -0
- data/lib/generators/rodauth/migration/sequel/account_expiration.erb +7 -0
- data/lib/generators/rodauth/migration/sequel/active_sessions.erb +8 -0
- data/lib/generators/rodauth/migration/sequel/audit_logging.erb +17 -0
- data/lib/generators/rodauth/migration/sequel/base.erb +25 -0
- data/lib/generators/rodauth/migration/sequel/disallow_password_reuse.erb +6 -0
- data/lib/generators/rodauth/migration/sequel/email_auth.erb +7 -0
- data/lib/generators/rodauth/migration/sequel/jwt_refresh.erb +8 -0
- data/lib/generators/rodauth/migration/sequel/lockout.erb +11 -0
- data/lib/generators/rodauth/migration/sequel/otp.erb +7 -0
- data/lib/generators/rodauth/migration/sequel/password_expiration.erb +5 -0
- data/lib/generators/rodauth/migration/sequel/recovery_codes.erb +6 -0
- data/lib/generators/rodauth/migration/sequel/remember.erb +6 -0
- data/lib/generators/rodauth/migration/sequel/reset_password.erb +7 -0
- data/lib/generators/rodauth/migration/sequel/single_session.erb +5 -0
- data/lib/generators/rodauth/migration/sequel/sms_codes.erb +8 -0
- data/lib/generators/rodauth/migration/sequel/verify_account.erb +7 -0
- data/lib/generators/rodauth/migration/sequel/verify_login_change.erb +7 -0
- data/lib/generators/rodauth/migration/sequel/webauthn.erb +13 -0
- data/lib/generators/rodauth/migration_generator.rb +89 -9
- data/lib/generators/rodauth/templates/app/mailers/rodauth_mailer.rb +24 -0
- data/lib/generators/rodauth/templates/app/misc/rodauth_main.rb +4 -1
- data/lib/generators/rodauth/templates/app/models/account.rb +11 -0
- data/lib/generators/rodauth/templates/db/migrate/create_rodauth.rb +8 -0
- data/lib/rodauth/rails/app.rb +19 -7
- data/lib/rodauth/rails/controller_methods.rb +9 -0
- data/lib/rodauth/rails/feature/associations.rb +54 -0
- data/lib/rodauth/rails/feature/base.rb +10 -0
- data/lib/rodauth/rails/feature/instrumentation.rb +8 -0
- data/lib/rodauth/rails/feature.rb +2 -0
- data/lib/rodauth/rails/middleware.rb +9 -0
- data/lib/rodauth/rails/model.rb +8 -8
- data/lib/rodauth/rails/railtie.rb +9 -0
- data/lib/rodauth/rails/test/controller.rb +41 -0
- data/lib/rodauth/rails/test.rb +7 -0
- data/lib/rodauth/rails/version.rb +1 -1
- data/rodauth-rails.gemspec +2 -1
- metadata +57 -26
- data/lib/generators/rodauth/migration_helpers.rb +0 -77
- data/lib/rodauth/rails/app/flash.rb +0 -45
- data/lib/rodauth/rails/app/middleware.rb +0 -36
- data/lib/rodauth/rails/model/associations.rb +0 -195
@@ -1,14 +1,22 @@
|
|
1
1
|
class RodauthMailer < ApplicationMailer
|
2
2
|
def verify_account(account_id, key)
|
3
3
|
@email_link = rodauth.verify_account_url(key: email_token(account_id, key))
|
4
|
+
<% if defined?(ActiveRecord::Railtie) -%>
|
4
5
|
@account = Account.find(account_id)
|
6
|
+
<% else -%>
|
7
|
+
@account = Account.with_pk!(account_id)
|
8
|
+
<% end -%>
|
5
9
|
|
6
10
|
mail to: @account.email, subject: rodauth.verify_account_email_subject
|
7
11
|
end
|
8
12
|
|
9
13
|
def reset_password(account_id, key)
|
10
14
|
@email_link = rodauth.reset_password_url(key: email_token(account_id, key))
|
15
|
+
<% if defined?(ActiveRecord::Railtie) -%>
|
11
16
|
@account = Account.find(account_id)
|
17
|
+
<% else -%>
|
18
|
+
@account = Account.with_pk!(account_id)
|
19
|
+
<% end -%>
|
12
20
|
|
13
21
|
mail to: @account.email, subject: rodauth.reset_password_email_subject
|
14
22
|
end
|
@@ -17,27 +25,43 @@ class RodauthMailer < ApplicationMailer
|
|
17
25
|
@old_login = old_login
|
18
26
|
@new_login = new_login
|
19
27
|
@email_link = rodauth.verify_login_change_url(key: email_token(account_id, key))
|
28
|
+
<% if defined?(ActiveRecord::Railtie) -%>
|
20
29
|
@account = Account.find(account_id)
|
30
|
+
<% else -%>
|
31
|
+
@account = Account.with_pk!(account_id)
|
32
|
+
<% end -%>
|
21
33
|
|
22
34
|
mail to: new_login, subject: rodauth.verify_login_change_email_subject
|
23
35
|
end
|
24
36
|
|
25
37
|
def password_changed(account_id)
|
38
|
+
<% if defined?(ActiveRecord::Railtie) -%>
|
26
39
|
@account = Account.find(account_id)
|
40
|
+
<% else -%>
|
41
|
+
@account = Account.with_pk!(account_id)
|
42
|
+
<% end -%>
|
27
43
|
|
28
44
|
mail to: @account.email, subject: rodauth.password_changed_email_subject
|
29
45
|
end
|
30
46
|
|
31
47
|
# def email_auth(account_id, key)
|
32
48
|
# @email_link = rodauth.email_auth_url(key: email_token(account_id, key))
|
49
|
+
<% if defined?(ActiveRecord::Railtie) -%>
|
33
50
|
# @account = Account.find(account_id)
|
51
|
+
<% else -%>
|
52
|
+
# @account = Account.with_pk!(account_id)
|
53
|
+
<% end -%>
|
34
54
|
|
35
55
|
# mail to: @account.email, subject: rodauth.email_auth_email_subject
|
36
56
|
# end
|
37
57
|
|
38
58
|
# def unlock_account(account_id, key)
|
39
59
|
# @email_link = rodauth.unlock_account_url(key: email_token(account_id, key))
|
60
|
+
<% if defined?(ActiveRecord::Railtie) -%>
|
40
61
|
# @account = Account.find(account_id)
|
62
|
+
<% else -%>
|
63
|
+
# @account = Account.with_pk!(account_id)
|
64
|
+
<% end -%>
|
41
65
|
|
42
66
|
# mail to: @account.email, subject: rodauth.unlock_account_email_subject
|
43
67
|
# end
|
@@ -35,7 +35,7 @@ class RodauthMain < Rodauth::Rails::Auth
|
|
35
35
|
account_status_column :status
|
36
36
|
|
37
37
|
# Store password hash in a column instead of a separate table.
|
38
|
-
|
38
|
+
account_password_hash_column :password_hash
|
39
39
|
|
40
40
|
# Set password when creating account instead of when verifying.
|
41
41
|
verify_account_set_password? false
|
@@ -138,6 +138,9 @@ class RodauthMain < Rodauth::Rails::Auth
|
|
138
138
|
|
139
139
|
# Redirect to login page after password reset.
|
140
140
|
reset_password_redirect { login_path }
|
141
|
+
|
142
|
+
# Ensure requiring login follows login route changes.
|
143
|
+
require_login_redirect { login_path }
|
141
144
|
<% end -%>
|
142
145
|
|
143
146
|
# ==> Deadlines
|
@@ -1,4 +1,15 @@
|
|
1
|
+
<% if defined?(ActiveRecord::Railtie) -%>
|
1
2
|
class Account < ApplicationRecord
|
2
3
|
include Rodauth::Rails.model
|
4
|
+
<% if ActiveRecord.version >= Gem::Version.new("7.0") -%>
|
3
5
|
enum :status, unverified: 1, verified: 2, closed: 3
|
6
|
+
<% else -%>
|
7
|
+
enum status: { unverified: 1, verified: 2, closed: 3 }
|
8
|
+
<% end -%>
|
4
9
|
end
|
10
|
+
<% else -%>
|
11
|
+
class Account < Sequel::Model
|
12
|
+
plugin :enum
|
13
|
+
enum :status, unverified: 1, verified: 2, closed: 3
|
14
|
+
end
|
15
|
+
<% end -%>
|
@@ -1,5 +1,13 @@
|
|
1
|
+
<% if defined?(::ActiveRecord::Railtie) -%>
|
1
2
|
class <%= migration_class_name %> < ActiveRecord::Migration<%= migration_version %>
|
2
3
|
def change
|
3
4
|
<%= migration_content -%>
|
4
5
|
end
|
5
6
|
end
|
7
|
+
<% else -%>
|
8
|
+
Sequel.migration do
|
9
|
+
change do
|
10
|
+
<%= migration_content -%>
|
11
|
+
end
|
12
|
+
end
|
13
|
+
<% end -%>
|
data/lib/rodauth/rails/app.rb
CHANGED
@@ -5,17 +5,21 @@ module Rodauth
|
|
5
5
|
module Rails
|
6
6
|
# The superclass for creating a Rodauth middleware.
|
7
7
|
class App < Roda
|
8
|
-
|
9
|
-
|
8
|
+
plugin :middleware, forward_response_headers: true do |middleware|
|
9
|
+
middleware.class_eval do
|
10
|
+
def self.inspect
|
11
|
+
"#{superclass}::Middleware"
|
12
|
+
end
|
13
|
+
|
14
|
+
def inspect
|
15
|
+
"#<#{self.class.inspect} request=#{request.inspect} response=#{response.inspect}>"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
10
19
|
|
11
20
|
plugin :hooks
|
12
21
|
plugin :render, layout: false
|
13
22
|
|
14
|
-
unless Rodauth::Rails.api_only?
|
15
|
-
require "rodauth/rails/app/flash"
|
16
|
-
plugin Flash
|
17
|
-
end
|
18
|
-
|
19
23
|
def self.configure(*args, **options, &block)
|
20
24
|
auth_class = args.shift if args[0].is_a?(Class)
|
21
25
|
name = args.shift if args[0].is_a?(Symbol)
|
@@ -35,6 +39,14 @@ module Rodauth
|
|
35
39
|
end
|
36
40
|
end
|
37
41
|
|
42
|
+
after do
|
43
|
+
rails_request.commit_flash
|
44
|
+
end unless ActionPack.version < Gem::Version.new("5.0")
|
45
|
+
|
46
|
+
def flash
|
47
|
+
rails_request.flash
|
48
|
+
end
|
49
|
+
|
38
50
|
def rails_routes
|
39
51
|
::Rails.application.routes.url_helpers
|
40
52
|
end
|
@@ -18,6 +18,15 @@ module Rodauth
|
|
18
18
|
|
19
19
|
private
|
20
20
|
|
21
|
+
# Adds response status to instrumentation payload for logging,
|
22
|
+
# when calling a halting rodauth method inside a controller.
|
23
|
+
def append_info_to_payload(payload)
|
24
|
+
super
|
25
|
+
if request.env["rodauth.rails.status"]
|
26
|
+
payload[:status] = request.env.delete("rodauth.rails.status")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
21
30
|
def rodauth_response
|
22
31
|
res = catch(:halt) { return yield }
|
23
32
|
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Rodauth
|
2
|
+
module Rails
|
3
|
+
module Feature
|
4
|
+
module Associations
|
5
|
+
def associations
|
6
|
+
list = []
|
7
|
+
|
8
|
+
features.each do |feature|
|
9
|
+
case feature
|
10
|
+
when :remember
|
11
|
+
list << { name: :remember_key, type: :one, table: remember_table, foreign_key: remember_id_column }
|
12
|
+
when :verify_account
|
13
|
+
list << { name: :verification_key, type: :one, table: verify_account_table, foreign_key: verify_account_id_column }
|
14
|
+
when :reset_password
|
15
|
+
list << { name: :password_reset_key, type: :one, table: reset_password_table, foreign_key: reset_password_id_column }
|
16
|
+
when :verify_login_change
|
17
|
+
list << { name: :login_change_key, type: :one, table: verify_login_change_table, foreign_key: verify_login_change_id_column }
|
18
|
+
when :lockout
|
19
|
+
list << { name: :lockout, type: :one, table: account_lockouts_table, foreign_key: account_lockouts_id_column }
|
20
|
+
list << { name: :login_failure, type: :one, table: account_login_failures_table, foreign_key: account_login_failures_id_column }
|
21
|
+
when :email_auth
|
22
|
+
list << { name: :email_auth_key, type: :one, table: email_auth_table, foreign_key: email_auth_id_column }
|
23
|
+
when :account_expiration
|
24
|
+
list << { name: :activity_time, type: :one, table: account_activity_table, foreign_key: account_activity_id_column }
|
25
|
+
when :active_sessions
|
26
|
+
list << { name: :active_session_keys, type: :many, table: active_sessions_table, foreign_key: active_sessions_account_id_column }
|
27
|
+
when :audit_logging
|
28
|
+
list << { name: :authentication_audit_logs, type: :many, table: audit_logging_table, foreign_key: audit_logging_account_id_column }
|
29
|
+
when :disallow_password_reuse
|
30
|
+
list << { name: :previous_password_hashes, type: :many, table: previous_password_hash_table, foreign_key: previous_password_account_id_column }
|
31
|
+
when :jwt_refresh
|
32
|
+
list << { name: :jwt_refresh_keys, type: :many, table: jwt_refresh_token_table, foreign_key: jwt_refresh_token_account_id_column }
|
33
|
+
when :password_expiration
|
34
|
+
list << { name: :password_change_time, type: :one, table: password_expiration_table, foreign_key: password_expiration_id_column }
|
35
|
+
when :single_session
|
36
|
+
list << { name: :session_key, type: :one, table: single_session_table, foreign_key: single_session_id_column }
|
37
|
+
when :otp
|
38
|
+
list << { name: :otp_key, type: :one, table: otp_keys_table, foreign_key: otp_keys_id_column }
|
39
|
+
when :sms_codes
|
40
|
+
list << { name: :sms_code, type: :one, table: sms_codes_table, foreign_key: sms_id_column }
|
41
|
+
when :recovery_codes
|
42
|
+
list << { name: :recovery_codes, type: :many, table: recovery_codes_table, foreign_key: recovery_codes_id_column }
|
43
|
+
when :webauthn
|
44
|
+
list << { name: :webauthn_user_id, type: :one, table: webauthn_user_ids_table, foreign_key: webauthn_user_ids_account_id_column }
|
45
|
+
list << { name: :webauthn_keys, type: :many, table: webauthn_keys_table, foreign_key: webauthn_keys_account_id_column }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
list
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -54,6 +54,16 @@ module Rodauth
|
|
54
54
|
|
55
55
|
private
|
56
56
|
|
57
|
+
unless ActionPack.version < Gem::Version.new("5.0")
|
58
|
+
# When calling a Rodauth method that redirects inside the Rails
|
59
|
+
# router, Roda's after hook that commits the flash would never get
|
60
|
+
# called, so we make sure to commit the flash beforehand.
|
61
|
+
def redirect(*)
|
62
|
+
rails_request.commit_flash
|
63
|
+
super
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
57
67
|
def instantiate_rails_account
|
58
68
|
if defined?(ActiveRecord::Base) && rails_account_model < ActiveRecord::Base
|
59
69
|
rails_account_model.instantiate(account.stringify_keys)
|
@@ -10,6 +10,14 @@ module Rodauth
|
|
10
10
|
|
11
11
|
def redirect(*)
|
12
12
|
rails_instrument_redirection { super }
|
13
|
+
ensure
|
14
|
+
request.env["rodauth.rails.status"] = response.status
|
15
|
+
end
|
16
|
+
|
17
|
+
def return_response(*)
|
18
|
+
super
|
19
|
+
ensure
|
20
|
+
request.env["rodauth.rails.status"] = response.status
|
13
21
|
end
|
14
22
|
|
15
23
|
def rails_render(*)
|
@@ -11,6 +11,7 @@ module Rodauth
|
|
11
11
|
require "rodauth/rails/feature/email"
|
12
12
|
require "rodauth/rails/feature/instrumentation"
|
13
13
|
require "rodauth/rails/feature/internal_request"
|
14
|
+
require "rodauth/rails/feature/associations"
|
14
15
|
|
15
16
|
include Rodauth::Rails::Feature::Base
|
16
17
|
include Rodauth::Rails::Feature::Callbacks
|
@@ -19,5 +20,6 @@ module Rodauth
|
|
19
20
|
include Rodauth::Rails::Feature::Email
|
20
21
|
include Rodauth::Rails::Feature::Instrumentation
|
21
22
|
include Rodauth::Rails::Feature::InternalRequest
|
23
|
+
include Rodauth::Rails::Feature::Associations
|
22
24
|
end
|
23
25
|
end
|
@@ -9,6 +9,8 @@ module Rodauth
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def call(env)
|
12
|
+
return @app.call(env) if asset_request?(env)
|
13
|
+
|
12
14
|
app = Rodauth::Rails.app.new(@app)
|
13
15
|
|
14
16
|
# allow the Rails app to call Rodauth methods that throw :halt
|
@@ -16,6 +18,13 @@ module Rodauth
|
|
16
18
|
app.call(env)
|
17
19
|
end
|
18
20
|
end
|
21
|
+
|
22
|
+
# Check whether it's a request to an asset managed by Sprockets or Propshaft.
|
23
|
+
def asset_request?(env)
|
24
|
+
return false unless ::Rails.application.config.respond_to?(:assets)
|
25
|
+
|
26
|
+
env["PATH_INFO"] =~ %r(\A/{0,2}#{::Rails.application.config.assets.prefix})
|
27
|
+
end
|
19
28
|
end
|
20
29
|
end
|
21
30
|
end
|
data/lib/rodauth/rails/model.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Rodauth
|
2
2
|
module Rails
|
3
3
|
class Model < Module
|
4
|
-
|
4
|
+
ASSOCIATION_TYPES = { one: :has_one, many: :has_many }
|
5
5
|
|
6
6
|
def initialize(auth_class, association_options: {})
|
7
7
|
@auth_class = auth_class
|
@@ -46,8 +46,8 @@ module Rodauth
|
|
46
46
|
def define_associations(model)
|
47
47
|
define_password_hash_association(model) unless rodauth.account_password_hash_column
|
48
48
|
|
49
|
-
|
50
|
-
define_association(model, **association)
|
49
|
+
rodauth.associations.each do |association|
|
50
|
+
define_association(model, **association, type: ASSOCIATION_TYPES.fetch(association[:type]))
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
@@ -74,19 +74,19 @@ module Rodauth
|
|
74
74
|
|
75
75
|
model.const_set(name.to_s.singularize.camelize, associated_model)
|
76
76
|
|
77
|
+
unless name == :authentication_audit_logs
|
78
|
+
dependent = type == :has_many ? :delete_all : :delete
|
79
|
+
end
|
80
|
+
|
77
81
|
model.public_send type, name, scope,
|
78
82
|
class_name: associated_model.name,
|
79
83
|
foreign_key: foreign_key,
|
80
|
-
dependent:
|
84
|
+
dependent: dependent,
|
81
85
|
inverse_of: :account,
|
82
86
|
**options,
|
83
87
|
**association_options(name)
|
84
88
|
end
|
85
89
|
|
86
|
-
def feature_associations
|
87
|
-
Rodauth::Rails::Model::Associations.call(rodauth)
|
88
|
-
end
|
89
|
-
|
90
90
|
def association_options(name)
|
91
91
|
options = @association_options
|
92
92
|
options = options.call(name) if options.respond_to?(:call)
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require "rodauth/rails/middleware"
|
2
2
|
require "rodauth/rails/controller_methods"
|
3
|
+
require "rodauth/rails/test"
|
3
4
|
|
4
5
|
require "rails"
|
5
6
|
|
@@ -21,6 +22,14 @@ module Rodauth
|
|
21
22
|
initializer "rodauth.test" do
|
22
23
|
# Rodauth uses RACK_ENV to set the default bcrypt hash cost
|
23
24
|
ENV["RACK_ENV"] = "test" if ::Rails.env.test?
|
25
|
+
|
26
|
+
if ActionPack.version >= Gem::Version.new("5.0")
|
27
|
+
ActiveSupport.on_load(:action_controller_test_case) do
|
28
|
+
include Rodauth::Rails::Test::Controller
|
29
|
+
end
|
30
|
+
else
|
31
|
+
ActionController::TestCase.include Rodauth::Rails::Test::Controller
|
32
|
+
end
|
24
33
|
end
|
25
34
|
|
26
35
|
rake_tasks do
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require "active_support/concern"
|
2
|
+
|
3
|
+
module Rodauth
|
4
|
+
module Rails
|
5
|
+
module Test
|
6
|
+
module Controller
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
|
9
|
+
included do
|
10
|
+
setup :setup_rodauth
|
11
|
+
end
|
12
|
+
|
13
|
+
def process(*)
|
14
|
+
catch_rodauth { super }
|
15
|
+
end
|
16
|
+
ruby2_keywords(:process) if respond_to?(:ruby2_keywords, true)
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def setup_rodauth
|
21
|
+
Rodauth::Rails.app.opts[:rodauths].each do |name, auth_class|
|
22
|
+
scope = auth_class.roda_class.new(request.env)
|
23
|
+
request.env[["rodauth", *name].join(".")] = auth_class.new(scope)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def catch_rodauth(&block)
|
28
|
+
result = catch(:halt, &block)
|
29
|
+
|
30
|
+
if result.is_a?(Array) # rodauth response
|
31
|
+
response.status = result[0]
|
32
|
+
response.headers.merge! result[1]
|
33
|
+
response.body = result[2]
|
34
|
+
end
|
35
|
+
|
36
|
+
response
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/rodauth-rails.gemspec
CHANGED
@@ -17,7 +17,8 @@ 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.23"
|
21
|
+
spec.add_dependency "roda", "~> 3.55"
|
21
22
|
spec.add_dependency "sequel-activerecord_connection", "~> 1.1"
|
22
23
|
spec.add_dependency "tilt"
|
23
24
|
spec.add_dependency "bcrypt"
|
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.4.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: 2022-
|
11
|
+
date: 2022-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -36,14 +36,28 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '2.
|
39
|
+
version: '2.23'
|
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.23'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: roda
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '3.55'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '3.55'
|
47
61
|
- !ruby/object:Gem::Dependency
|
48
62
|
name: sequel-activerecord_connection
|
49
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -153,26 +167,43 @@ files:
|
|
153
167
|
- LICENSE.txt
|
154
168
|
- README.md
|
155
169
|
- lib/generators/rodauth/install_generator.rb
|
156
|
-
- lib/generators/rodauth/migration/account_expiration.erb
|
157
|
-
- lib/generators/rodauth/migration/active_sessions.erb
|
158
|
-
- lib/generators/rodauth/migration/audit_logging.erb
|
159
|
-
- lib/generators/rodauth/migration/base.erb
|
160
|
-
- lib/generators/rodauth/migration/disallow_password_reuse.erb
|
161
|
-
- lib/generators/rodauth/migration/email_auth.erb
|
162
|
-
- lib/generators/rodauth/migration/jwt_refresh.erb
|
163
|
-
- lib/generators/rodauth/migration/lockout.erb
|
164
|
-
- lib/generators/rodauth/migration/otp.erb
|
165
|
-
- lib/generators/rodauth/migration/password_expiration.erb
|
166
|
-
- lib/generators/rodauth/migration/recovery_codes.erb
|
167
|
-
- lib/generators/rodauth/migration/remember.erb
|
168
|
-
- lib/generators/rodauth/migration/reset_password.erb
|
169
|
-
- lib/generators/rodauth/migration/single_session.erb
|
170
|
-
- lib/generators/rodauth/migration/sms_codes.erb
|
171
|
-
- lib/generators/rodauth/migration/verify_account.erb
|
172
|
-
- lib/generators/rodauth/migration/verify_login_change.erb
|
173
|
-
- lib/generators/rodauth/migration/webauthn.erb
|
170
|
+
- lib/generators/rodauth/migration/active_record/account_expiration.erb
|
171
|
+
- lib/generators/rodauth/migration/active_record/active_sessions.erb
|
172
|
+
- lib/generators/rodauth/migration/active_record/audit_logging.erb
|
173
|
+
- lib/generators/rodauth/migration/active_record/base.erb
|
174
|
+
- lib/generators/rodauth/migration/active_record/disallow_password_reuse.erb
|
175
|
+
- lib/generators/rodauth/migration/active_record/email_auth.erb
|
176
|
+
- lib/generators/rodauth/migration/active_record/jwt_refresh.erb
|
177
|
+
- lib/generators/rodauth/migration/active_record/lockout.erb
|
178
|
+
- lib/generators/rodauth/migration/active_record/otp.erb
|
179
|
+
- lib/generators/rodauth/migration/active_record/password_expiration.erb
|
180
|
+
- lib/generators/rodauth/migration/active_record/recovery_codes.erb
|
181
|
+
- lib/generators/rodauth/migration/active_record/remember.erb
|
182
|
+
- lib/generators/rodauth/migration/active_record/reset_password.erb
|
183
|
+
- lib/generators/rodauth/migration/active_record/single_session.erb
|
184
|
+
- lib/generators/rodauth/migration/active_record/sms_codes.erb
|
185
|
+
- lib/generators/rodauth/migration/active_record/verify_account.erb
|
186
|
+
- lib/generators/rodauth/migration/active_record/verify_login_change.erb
|
187
|
+
- lib/generators/rodauth/migration/active_record/webauthn.erb
|
188
|
+
- lib/generators/rodauth/migration/sequel/account_expiration.erb
|
189
|
+
- lib/generators/rodauth/migration/sequel/active_sessions.erb
|
190
|
+
- lib/generators/rodauth/migration/sequel/audit_logging.erb
|
191
|
+
- lib/generators/rodauth/migration/sequel/base.erb
|
192
|
+
- lib/generators/rodauth/migration/sequel/disallow_password_reuse.erb
|
193
|
+
- lib/generators/rodauth/migration/sequel/email_auth.erb
|
194
|
+
- lib/generators/rodauth/migration/sequel/jwt_refresh.erb
|
195
|
+
- lib/generators/rodauth/migration/sequel/lockout.erb
|
196
|
+
- lib/generators/rodauth/migration/sequel/otp.erb
|
197
|
+
- lib/generators/rodauth/migration/sequel/password_expiration.erb
|
198
|
+
- lib/generators/rodauth/migration/sequel/recovery_codes.erb
|
199
|
+
- lib/generators/rodauth/migration/sequel/remember.erb
|
200
|
+
- lib/generators/rodauth/migration/sequel/reset_password.erb
|
201
|
+
- lib/generators/rodauth/migration/sequel/single_session.erb
|
202
|
+
- lib/generators/rodauth/migration/sequel/sms_codes.erb
|
203
|
+
- lib/generators/rodauth/migration/sequel/verify_account.erb
|
204
|
+
- lib/generators/rodauth/migration/sequel/verify_login_change.erb
|
205
|
+
- lib/generators/rodauth/migration/sequel/webauthn.erb
|
174
206
|
- lib/generators/rodauth/migration_generator.rb
|
175
|
-
- lib/generators/rodauth/migration_helpers.rb
|
176
207
|
- lib/generators/rodauth/templates/INSTRUCTIONS
|
177
208
|
- lib/generators/rodauth/templates/app/controllers/rodauth_controller.rb
|
178
209
|
- lib/generators/rodauth/templates/app/mailers/rodauth_mailer.rb
|
@@ -230,11 +261,10 @@ files:
|
|
230
261
|
- lib/rodauth-rails.rb
|
231
262
|
- lib/rodauth/rails.rb
|
232
263
|
- lib/rodauth/rails/app.rb
|
233
|
-
- lib/rodauth/rails/app/flash.rb
|
234
|
-
- lib/rodauth/rails/app/middleware.rb
|
235
264
|
- lib/rodauth/rails/auth.rb
|
236
265
|
- lib/rodauth/rails/controller_methods.rb
|
237
266
|
- lib/rodauth/rails/feature.rb
|
267
|
+
- lib/rodauth/rails/feature/associations.rb
|
238
268
|
- lib/rodauth/rails/feature/base.rb
|
239
269
|
- lib/rodauth/rails/feature/callbacks.rb
|
240
270
|
- lib/rodauth/rails/feature/csrf.rb
|
@@ -244,9 +274,10 @@ files:
|
|
244
274
|
- lib/rodauth/rails/feature/render.rb
|
245
275
|
- lib/rodauth/rails/middleware.rb
|
246
276
|
- lib/rodauth/rails/model.rb
|
247
|
-
- lib/rodauth/rails/model/associations.rb
|
248
277
|
- lib/rodauth/rails/railtie.rb
|
249
278
|
- lib/rodauth/rails/tasks.rake
|
279
|
+
- lib/rodauth/rails/test.rb
|
280
|
+
- lib/rodauth/rails/test/controller.rb
|
250
281
|
- lib/rodauth/rails/version.rb
|
251
282
|
- rodauth-rails.gemspec
|
252
283
|
homepage: https://github.com/janko/rodauth-rails
|
@@ -1,77 +0,0 @@
|
|
1
|
-
require "erb"
|
2
|
-
|
3
|
-
module Rodauth
|
4
|
-
module Rails
|
5
|
-
module Generators
|
6
|
-
module MigrationHelpers
|
7
|
-
attr_reader :migration_class_name
|
8
|
-
|
9
|
-
def migration_template(source, destination = File.basename(source))
|
10
|
-
@migration_class_name = destination.chomp(".rb").camelize
|
11
|
-
|
12
|
-
super source, File.join(db_migrate_path, destination)
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
|
17
|
-
def migration_content
|
18
|
-
migration_features
|
19
|
-
.select { |feature| File.exist?("#{__dir__}/migration/#{feature}.erb") }
|
20
|
-
.map { |feature| File.read("#{__dir__}/migration/#{feature}.erb") }
|
21
|
-
.map { |content| erb_eval(content) }
|
22
|
-
.join("\n")
|
23
|
-
.indent(4)
|
24
|
-
end
|
25
|
-
|
26
|
-
def activerecord_adapter
|
27
|
-
if ActiveRecord::Base.respond_to?(:connection_db_config)
|
28
|
-
ActiveRecord::Base.connection_db_config.adapter
|
29
|
-
else
|
30
|
-
ActiveRecord::Base.connection_config.fetch(:adapter)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def migration_version
|
35
|
-
return unless ActiveRecord.version >= Gem::Version.new("5.0")
|
36
|
-
|
37
|
-
"[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]"
|
38
|
-
end
|
39
|
-
|
40
|
-
def db_migrate_path
|
41
|
-
return "db/migrate" unless ActiveRecord.version >= Gem::Version.new("5.0")
|
42
|
-
|
43
|
-
super
|
44
|
-
end
|
45
|
-
|
46
|
-
def primary_key_type(key = :id)
|
47
|
-
generators = ::Rails.application.config.generators
|
48
|
-
column_type = generators.options[:active_record][:primary_key_type]
|
49
|
-
|
50
|
-
return unless column_type
|
51
|
-
|
52
|
-
if key
|
53
|
-
", #{key}: :#{column_type}"
|
54
|
-
else
|
55
|
-
column_type
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def erb_eval(content)
|
60
|
-
if ERB.version[/\d+\.\d+\.\d+/].to_s >= "2.2.0"
|
61
|
-
ERB.new(content, trim_mode: "-").result(binding)
|
62
|
-
else
|
63
|
-
ERB.new(content, 0, "-").result(binding)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def current_timestamp
|
68
|
-
if ActiveRecord.version >= Gem::Version.new("5.0")
|
69
|
-
%(-> { "CURRENT_TIMESTAMP" })
|
70
|
-
else
|
71
|
-
%(OpenStruct.new(quoted_id: "CURRENT_TIMESTAMP"))
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|