rodauth-rails 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6582c0a5c1acbaa774ec0dd8b3909797afdb7f6a5e09e528125a021aedb2b7d5
4
- data.tar.gz: 851e5ed231d870497e014d5eed35884e2ee15bacdb5ed66bd8ad4d5a00657b3e
3
+ metadata.gz: 43ab68591969400f7891b7451b3d3d19e6c0fedc93d58a6b2795a6df969fe6e3
4
+ data.tar.gz: 19da59d6f9a9a041a7fde9135754d6b6173414383303e3bade6a7ed6a5116762
5
5
  SHA512:
6
- metadata.gz: '0429e4c00fdd4d48b34e319763cf36598b7635720ac8e37ea965a7f0ff68b8a94914f48ab92801893329f3e9c32ccb17f304bb59c4894c83ed0c0dad09b3530b'
7
- data.tar.gz: f1df4d89de84cb4fe9294101eeb7e5e19e3b0338aeee932278810465e3ea7d0529c490e7071391d74b2bbb11de6c74729a9cfeb64c92ffb5ebf74e7e8dab63e8
6
+ metadata.gz: 23f0093e1c3da9917b8080472b179e9926a565bf3b5cf01d32eb09cbbaf94787ef99564d704599f9be8396af3fb775bc056151c31b6a399fe5f2d7769c5f1893
7
+ data.tar.gz: da88b97f2e2420ac8bd0f9397e69582ad6720d10a3bb04a695ad4b603b41ad276bd188ee5007a19642d682240944ca05402ccdd7996ecc0816c439f366d19739
@@ -0,0 +1,32 @@
1
+ ## 0.2.0 (2020-07-26)
2
+
3
+ * Drop support for Rodauth 1.x (@janko)
4
+
5
+ * Change `rodauth_app.rb` template to send emails in the background after transaction commit (@janko)
6
+
7
+ * Bump `sequel-activerecord_connection` dependency to `~> 0.3` (@janko)
8
+
9
+ * Use the JDBC adapter in sequel.rb initializer when on JRuby (@janko)
10
+
11
+ ## 0.1.3 (2020-07-04)
12
+
13
+ * Remove insecure MFA integration with remember feature suggestion in `lib/rodauth_app.rb` (@janko, @nicolas-besnard)
14
+
15
+ * Use correct password autocomplete value on Rodauth 2.1+ (@janko)
16
+
17
+ * Enable skipping CSRF protection on Rodauth 2.1+ by overriding `#check_csrf?` (@janko)
18
+
19
+ * Don't generate Sequel initializer if Sequel connection exists (@janko)
20
+
21
+ * Fix typo in remember view template (@nicolas-besnard)
22
+
23
+ * Fix some more typos in `lib/rodauth_app.rb` (@janko)
24
+
25
+ ## 0.1.2 (2020-05-14)
26
+
27
+ * Fix some typos in comment suggestions in `lib/rodauth_app.rb` (@janko)
28
+
29
+ ## 0.1.1 (2020-05-09)
30
+
31
+ * Include view templates in the gem (@janko)
32
+ * Use `Login` labels to be consistent with Rodauth (@janko)
data/README.md CHANGED
@@ -13,7 +13,7 @@ Provides Rails integration for the [Rodauth] authentication framework.
13
13
  Add the gem to your Gemfile:
14
14
 
15
15
  ```rb
16
- gem "rodauth-rails", "~> 0.1"
16
+ gem "rodauth-rails", "~> 0.2"
17
17
  ```
18
18
 
19
19
  Then run `bundle install`.
@@ -358,23 +358,31 @@ class RodauthApp < Rodauth::Rails::App
358
358
  configure do
359
359
  # ...
360
360
  send_reset_password_email do
361
- RodauthMailer.reset_password(email_to, reset_password_email_link).deliver_now
361
+ mailer_send(:reset_password, email_to, reset_password_email_link)
362
362
  end
363
363
  send_verify_account_email do
364
- RodauthMailer.verify_account(email_to, verify_account_email_link).deliver_now
364
+ mailer_send(:verify_account, email_to, verify_account_email_link)
365
365
  end
366
366
  send_verify_login_change_email do |login|
367
- RodauthMailer.verify_login_change(login, verify_login_change_old_login, verify_login_change_new_login, verify_login_change_email_link).deliver_now
367
+ mailer_send(:verify_login_change, login, verify_login_change_old_login, verify_login_change_new_login, verify_login_change_email_link)
368
368
  end
369
369
  send_password_changed_email do
370
- RodauthMailer.password_changed(email_to).deliver_now
370
+ mailer_send(:password_changed, email_to)
371
371
  end
372
372
  # send_email_auth_email do
373
- # RodauthMailer.email_auth(email_to, email_auth_email_link).deliver_now
373
+ # mailer_send(:email_auth, email_to, email_auth_email_link)
374
374
  # end
375
375
  # send_unlock_account_email do
376
- # RodauthMailer.unlock_account(email_to, unlock_account_email_link).deliver_now
376
+ # mailer_send(:unlock_account, email_to, unlock_account_email_link)
377
377
  # end
378
+ auth_class_eval do
379
+ # queue email delivery on the mailer after the transaction commits
380
+ def mailer_send(type, *args)
381
+ db.after_commit do
382
+ RodauthMailer.public_send(type, *args).deliver_later
383
+ end
384
+ end
385
+ end
378
386
  # ...
379
387
  end
380
388
  end
@@ -399,7 +407,7 @@ The Rodauth app stores the `Rodauth::Auth` instance in the Rack env hash, which
399
407
  is then available in your Rails app:
400
408
 
401
409
  ```rb
402
- request.env["rodauth"] #=> #<Rodauth::Auth>
410
+ request.env["rodauth"] #=> #<Rodauth::Auth>
403
411
  request.env["rodauth.secondary"] #=> #<Rodauth::Auth> (if using multiple configurations)
404
412
  ```
405
413
 
@@ -409,13 +417,13 @@ and controllers:
409
417
  ```rb
410
418
  class MyController < ApplicationController
411
419
  def my_action
412
- rodauth #=> #<Rodauth::Auth>
420
+ rodauth #=> #<Rodauth::Auth>
413
421
  rodauth(:secondary) #=> #<Rodauth::Auth> (if using multiple configurations)
414
422
  end
415
423
  end
416
424
  ```
417
425
  ```erb
418
- <% rodauth #=> #<Rodauth::Auth> %>
426
+ <% rodauth #=> #<Rodauth::Auth> %>
419
427
  <% rodauth(:secondary) #=> #<Rodauth::Auth> (if using multiple configurations) %>
420
428
  ```
421
429
 
@@ -431,11 +439,11 @@ integration for Rodauth:
431
439
  * uses ActionMailer for sending emails
432
440
 
433
441
  The `configure { ... }` method wraps configuring the Rodauth plugin, forwarding
434
- any additional [options].
442
+ any additional [plugin options].
435
443
 
436
444
  ```rb
437
445
  configure { ... } # defining default Rodauth configuration
438
- configure(json: true) # passing options to the Rodauth plugin
446
+ configure(json: true) { ... } # passing options to the Rodauth plugin
439
447
  configure(:secondary) { ... } # defining multiple Rodauth configurations
440
448
  ```
441
449
 
@@ -487,7 +495,7 @@ end
487
495
 
488
496
  ## Working with JWT
489
497
 
490
- To work with JWT, you'll need to enable json in `Roda`, and the [JWT plugin][Rodauth JWT documentation]
498
+ To use Rodauth's [JWT feature], you'll need to load Roda's JSON support:
491
499
 
492
500
  ```rb
493
501
  # lib/rodauth_app.rb
@@ -595,10 +603,14 @@ create_table :accounts do |t|
595
603
  end
596
604
  ```
597
605
  ```diff
606
+ configure do
607
+ # ...
598
608
  - account_status_column :status
599
609
  - account_unverified_status_value "unverified"
600
610
  - account_open_status_value "verified"
601
611
  - account_closed_status_value "closed"
612
+ # ...
613
+ end
602
614
  ```
603
615
 
604
616
  ## License
@@ -616,13 +628,11 @@ conduct](https://github.com/janko/rodauth-rails/blob/master/CODE_OF_CONDUCT.md).
616
628
  [Sequel]: https://github.com/jeremyevans/sequel
617
629
  [rendering views outside of controllers]: https://blog.bigbinary.com/2016/01/08/rendering-views-outside-of-controllers-in-rails-5.html
618
630
  [feature documentation]: http://rodauth.jeremyevans.net/documentation.html
619
- [Rodauth JWT documentation]: http://rodauth.jeremyevans.net/rdoc/files/doc/jwt_rdoc.html
620
- [Rodauth plugin]: https://github.com/jeremyevans/rodauth/#label-Plugin+Options
631
+ [JWT feature]: http://rodauth.jeremyevans.net/rdoc/files/doc/jwt_rdoc.html
621
632
  [Bootstrap]: https://getbootstrap.com/
622
633
  [Roda]: http://roda.jeremyevans.net/
623
634
  [HMAC]: http://rodauth.jeremyevans.net/rdoc/files/README_rdoc.html#label-HMAC
624
635
  [database authentication functions]: http://rodauth.jeremyevans.net/rdoc/files/README_rdoc.html#label-Password+Hash+Access+Via+Database+Functions
625
- [multiple configurations]: http://rodauth.jeremyevans.net/rdoc/files/README_rdoc.html#label-With+Multiple+Configurations
626
- [views]: /app/views/rodauth
627
636
  [Rodauth migration]: http://rodauth.jeremyevans.net/rdoc/files/README_rdoc.html#label-Creating+tables
628
637
  [sequel-activerecord_connection]: https://github.com/janko/sequel-activerecord_connection
638
+ [plugin options]: http://rodauth.jeremyevans.net/rdoc/files/README_rdoc.html#label-Plugin+Options
@@ -23,7 +23,7 @@ module Rodauth
23
23
 
24
24
  def create_sequel_initializer
25
25
  return unless defined?(ActiveRecord::Base)
26
- return unless %w[postgresql mysql2 sqlite3].include?(adapter)
26
+ return unless %w[postgresql mysql2 sqlite3].include?(activerecord_adapter)
27
27
  return if defined?(Sequel) && !Sequel::DATABASES.empty?
28
28
 
29
29
  template "config/initializers/sequel.rb"
@@ -56,7 +56,17 @@ module Rodauth
56
56
  end
57
57
  end
58
58
 
59
- def adapter
59
+ def sequel_adapter
60
+ return "jdbc" if RUBY_ENGINE == "jruby"
61
+
62
+ case activerecord_adapter
63
+ when "postgresql" then "postgres"
64
+ when "mysql2" then "mysql2"
65
+ when "sqlite3" then "sqlite"
66
+ end
67
+ end
68
+
69
+ def activerecord_adapter
60
70
  ActiveRecord::Base.connection_config.fetch(:adapter)
61
71
  end
62
72
  end
@@ -1,4 +1,3 @@
1
- <% if Rodauth::MAJOR >= 2 -%>
2
1
  <%% unless rodauth.login_form_footer_links.empty? %>
3
2
  <h2>Other Options</h2>
4
3
  <ul>
@@ -7,17 +6,3 @@
7
6
  <%% end %>
8
7
  </ul>
9
8
  <%% end %>
10
- <% else -%>
11
- <%% if rodauth.features.include?(:create_account) %>
12
- <p><%%= link_to "Create a New Account", rodauth.create_account_path %></p>
13
- <%% end %>
14
- <%% if rodauth.features.include?(:reset_password) %>
15
- <p><%%= link_to "Forgot Password?", rodauth.reset_password_request_path %></p>
16
- <%% end %>
17
- <%% if rodauth.features.include?(:email_auth) && rodauth.valid_login_entered? %>
18
- <%%= render "email_auth_request_form" %>
19
- <%% end %>
20
- <%% if rodauth.features.include?(:verify_account) %>
21
- <p><%%= link_to "Resend Verify Account Information", rodauth.verify_account_resend_path %></p>
22
- <%% end %>
23
- <% end -%>
@@ -1,4 +1,4 @@
1
1
  <div class="form-group">
2
2
  <%%= label_tag "password", "Password" %>
3
- <%%= render "field", name: rodauth.password_param, id: "password", type: :password, value: "", autocomplete: <%= Rodauth::MAJOR >= 2 && Rodauth::MINOR >= 1 ? %(rodauth.password_field_autocomplete_value) : %("current-password") %> %>
3
+ <%%= render "field", name: rodauth.password_param, id: "password", type: :password, value: "", autocomplete: rodauth.password_field_autocomplete_value %>
4
4
  </div>
@@ -1,6 +1,4 @@
1
1
  <%%= form_tag rodauth.logout_path, method: :post do %>
2
- <% if Rodauth::MAJOR >= 2 -%>
3
2
  <%%= render "global_logout_field" if rodauth.features.include?(:active_sessions) %>
4
- <% end -%>
5
3
  <%%= render "submit", value: "Logout", class: "btn btn-warning" %>
6
4
  <%% end %>
@@ -2,12 +2,3 @@
2
2
  <%%= render "otp_auth_code_field" %>
3
3
  <%%= render "submit", value: "Authenticate Using TOTP" %>
4
4
  <%% end %>
5
- <% if Rodauth::MAJOR == 1 -%>
6
-
7
- <%% if rodauth.features.include?(:sms_codes) && rodauth.sms_available? %>
8
- <p><%%= link_to "Authenticate using SMS code", rodauth.sms_request_path %></p>
9
- <%% end %>
10
- <%% if rodauth.features.include?(:recovery_codes) %>
11
- <p><%%= link_to "Authenticate using recovery code", rodauth.recovery_auth_path %></p>
12
- <%% end %>
13
- <% end -%>
@@ -1,13 +1,6 @@
1
1
  require "sequel/core"
2
2
 
3
3
  # initialize the appropriate Sequel adapter without creating a connection
4
- <% case adapter -%>
5
- <% when "postgresql" -%>
6
- DB = Sequel.postgres(test: false)
7
- <% when "mysql2" -%>
8
- DB = Sequel.mysql2(test: false)
9
- <% when "sqlite3" -%>
10
- DB = Sequel.sqlite(test: false)
11
- <% end -%>
4
+ DB = Sequel.<%= sequel_adapter %>(test: false)
12
5
  # have Sequel use ActiveRecord's connection for database interaction
13
6
  DB.extension :activerecord_connection
@@ -1,11 +1,11 @@
1
1
  class CreateRodauth < ActiveRecord::Migration<%= migration_version %>
2
2
  def change
3
- <% if adapter == "postgresql" -%>
3
+ <% if activerecord_adapter == "postgresql" -%>
4
4
  enable_extension "citext"
5
5
 
6
6
  <% end -%>
7
7
  create_table :accounts do |t|
8
- <% case adapter -%>
8
+ <% case activerecord_adapter -%>
9
9
  <% when "postgresql" -%>
10
10
  t.citext :email, null: false, index: { unique: true, where: "status IN ('verified', 'unverified')" }
11
11
  <% else -%>
@@ -56,7 +56,7 @@ class CreateRodauth < ActiveRecord::Migration<%= migration_version %>
56
56
  # t.references :account, null: false
57
57
  # t.datetime :at, null: false, default: -> { "CURRENT_TIMESTAMP" }
58
58
  # t.text :message, null: false
59
- <% case adapter -%>
59
+ <% case activerecord_adapter -%>
60
60
  <% when "postgresql" -%>
61
61
  # t.jsonb :metadata
62
62
  <% when "sqlite3", "mysql2" -%>
@@ -42,26 +42,31 @@ class RodauthApp < Rodauth::Rails::App
42
42
  # ==> Emails
43
43
  # Uncomment the lines below once you've imported mailer views.
44
44
  # send_reset_password_email do
45
- # RodauthMailer.reset_password(email_to, reset_password_email_link).deliver_now
45
+ # mailer_send(:reset_password, email_to, reset_password_email_link)
46
46
  # end
47
47
  # send_verify_account_email do
48
- # RodauthMailer.verify_account(email_to, verify_account_email_link).deliver_now
48
+ # mailer_send(:verify_account, email_to, verify_account_email_link)
49
49
  # end
50
50
  # send_verify_login_change_email do |login|
51
- # RodauthMailer.verify_login_change(login, verify_login_change_old_login, verify_login_change_new_login, verify_login_change_email_link).deliver_now
51
+ # mailer_send(:verify_login_change, login, verify_login_change_old_login, verify_login_change_new_login, verify_login_change_email_link)
52
52
  # end
53
53
  # send_password_changed_email do
54
- # RodauthMailer.password_changed(email_to).deliver_now
54
+ # mailer_send(:password_changed, email_to)
55
55
  # end
56
56
  # # send_email_auth_email do
57
- # # RodauthMailer.email_auth(email_to, email_auth_email_link).deliver_now
57
+ # # mailer_send(:email_auth, email_to, email_auth_email_link)
58
58
  # # end
59
59
  # # send_unlock_account_email do
60
- <% if Rodauth::MAJOR == 1 -%>
61
- # # @unlock_account_key_value = get_unlock_account_key
62
- <% end -%>
63
- # # RodauthMailer.unlock_account(email_to, unlock_account_email_link).deliver_now
60
+ # # mailer_send(:unlock_account, email_to, unlock_account_email_link)
64
61
  # # end
62
+ # auth_class_eval do
63
+ # # queue email delivery on the mailer after the transaction commits
64
+ # def mailer_send(type, *args)
65
+ # db.after_commit do
66
+ # RodauthMailer.public_send(type, *args).deliver_later
67
+ # end
68
+ # end
69
+ # end
65
70
 
66
71
  # In the meantime you can tweak settings for emails created by Rodauth
67
72
  # email_subject_prefix "[MyApp] "
@@ -131,19 +136,6 @@ class RodauthApp < Rodauth::Rails::App
131
136
  # reset_password_deadline_interval Hash[hours: 6]
132
137
  # verify_login_change_deadline_interval Hash[days: 2]
133
138
  # remember_deadline_interval Hash[days: 30]
134
-
135
- # ==> Extending
136
- # Define any additional methods you want for the Rodauth object.
137
- # auth_class_eval do
138
- # def my_send_email(name, *args)
139
- # AuthenticationMailer.public_send(name, *args).deliver_later
140
- # end
141
- # end
142
- #
143
- # Then use the new custom method in configuration blocks.
144
- # send_reset_password_email do
145
- # my_send_email(:reset_password, email_to, reset_password_email_link)
146
- # end
147
139
  end
148
140
 
149
141
  # ==> Multiple configurations
@@ -103,14 +103,6 @@ module Rodauth
103
103
  list |= VIEWS[DEPENDENCIES[feature]] || []
104
104
  end
105
105
 
106
- if Rodauth::MAJOR == 1
107
- views -= %w[
108
- multi_phase_login _global_logout_field
109
- two_factor_manage two_factor_auth two_factor_disable
110
- webauthn_setup webauthn_auth webauthn_remove
111
- ]
112
- end
113
-
114
106
  views.each do |view|
115
107
  template "app/views/rodauth/#{view}.html.erb",
116
108
  "app/views/#{options[:directory].underscore}/#{view}.html.erb"
@@ -28,22 +28,14 @@ module Rodauth
28
28
  super
29
29
  end
30
30
 
31
- if Rodauth::MAJOR >= 2 && Rodauth::MINOR >= 1
32
- # Verify Rails' authenticity token.
33
- def check_csrf
34
- rails_check_csrf!
35
- end
31
+ # Verify Rails' authenticity token.
32
+ def check_csrf
33
+ rails_check_csrf!
34
+ end
36
35
 
37
- # Have Rodauth call #check_csrf automatically.
38
- def check_csrf?
39
- true
40
- end
41
- else
42
- # Verify Rails' authenticity token before each Rodauth route.
43
- def before_rodauth
44
- rails_check_csrf!
45
- super
46
- end
36
+ # Have Rodauth call #check_csrf automatically.
37
+ def check_csrf?
38
+ true
47
39
  end
48
40
 
49
41
  # Render Rails CSRF tags in Rodauth templates.
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "rodauth-rails"
3
- spec.version = "0.1.3"
3
+ spec.version = "0.2.0"
4
4
  spec.authors = ["Janko Marohnić"]
5
5
  spec.email = ["janko.marohnic@gmail.com"]
6
6
 
@@ -15,8 +15,8 @@ Gem::Specification.new do |spec|
15
15
  spec.require_paths = ["lib"]
16
16
 
17
17
  spec.add_dependency "railties", ">= 4.2", "< 7"
18
- spec.add_dependency "rodauth", ">= 1.23", "< 3"
19
- spec.add_dependency "sequel-activerecord_connection", "~> 0.2"
18
+ spec.add_dependency "rodauth", "~> 2.1"
19
+ spec.add_dependency "sequel-activerecord_connection", "~> 0.3"
20
20
  spec.add_dependency "tilt"
21
21
  spec.add_dependency "bcrypt"
22
22
  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: 0.1.3
4
+ version: 0.2.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: 2020-07-04 00:00:00.000000000 Z
11
+ date: 2020-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -34,36 +34,30 @@ dependencies:
34
34
  name: rodauth
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- version: '1.23'
40
- - - "<"
37
+ - - "~>"
41
38
  - !ruby/object:Gem::Version
42
- version: '3'
39
+ version: '2.1'
43
40
  type: :runtime
44
41
  prerelease: false
45
42
  version_requirements: !ruby/object:Gem::Requirement
46
43
  requirements:
47
- - - ">="
48
- - !ruby/object:Gem::Version
49
- version: '1.23'
50
- - - "<"
44
+ - - "~>"
51
45
  - !ruby/object:Gem::Version
52
- version: '3'
46
+ version: '2.1'
53
47
  - !ruby/object:Gem::Dependency
54
48
  name: sequel-activerecord_connection
55
49
  requirement: !ruby/object:Gem::Requirement
56
50
  requirements:
57
51
  - - "~>"
58
52
  - !ruby/object:Gem::Version
59
- version: '0.2'
53
+ version: '0.3'
60
54
  type: :runtime
61
55
  prerelease: false
62
56
  version_requirements: !ruby/object:Gem::Requirement
63
57
  requirements:
64
58
  - - "~>"
65
59
  - !ruby/object:Gem::Version
66
- version: '0.2'
60
+ version: '0.3'
67
61
  - !ruby/object:Gem::Dependency
68
62
  name: tilt
69
63
  requirement: !ruby/object:Gem::Requirement
@@ -99,6 +93,7 @@ executables: []
99
93
  extensions: []
100
94
  extra_rdoc_files: []
101
95
  files:
96
+ - CHANGELOG.md
102
97
  - LICENSE.txt
103
98
  - README.md
104
99
  - lib/generators/rodauth/install_generator.rb