authentication-zero 4.0.1 → 4.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 84ff6a85acc17f4561f1362e2e7fa15ad27c434cee6191f57dd7623f49b506ff
4
- data.tar.gz: 75fef66fa0926ba2c2a797db8a7d85cb58cdbf90891f0cb50e3cb318873fff10
3
+ metadata.gz: a20860b4e4e996ed12ee1f8627c322cee71785051bb58569e8d3694bd8d46860
4
+ data.tar.gz: da8ceac9a2cd8d53028b446fd988b9604bbc6a72ab8f89dfe4cc0442cd0facd7
5
5
  SHA512:
6
- metadata.gz: b80db262196da2d9107246f47949c88a73110f58298a9d29eb6c94eba2b8e255a9206f09539b3bad6702156e96fbfd1960ae789530d595e303858b36f92364b8
7
- data.tar.gz: c234410b5f2458a41be599d2529b377ed62436ff071eb87bc8bb49479d06d7382ac835ff7e82be7caf9f4b173ea45007362fc1836cedc27cc836e82f6cc71c4b
6
+ metadata.gz: 03ba76dae5a7ae6862a45525d43bcbf1ca566b5e5bd1738a743f52a62d5af8c31838381e183d3eb2fd2776a7f909430c6a57746999c9bd4f4ead57bd67ccf6a1
7
+ data.tar.gz: 1d8aad9fc172635ba87cc4f154a25a1da38470967cd8a8e82f344318bf54e95e5a759f0956b38a48092d08ae29d6a626750d6076c45f40f84d96918db5c54f75
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  ## New version
2
2
 
3
+ ## Authentication Zero 4.0.3 ##
4
+
5
+ * We don't need to add `config.action_mailer.default_url_options` anymore
6
+ * Make gem add bcrypt more resilient
7
+
8
+ ## Authentication Zero 4.0.2 ##
9
+
10
+ * Remove dependency on redis / kredis for sudoable
11
+ * Fix --webauthn option. (add @github/webauthn-json)
12
+ * Update application_controller to rails 8
13
+ * Remove --ratelimit option
14
+
15
+ ## Authentication Zero 4.0.1 ##
16
+
3
17
  * Remove rate limit from api generator
4
18
 
5
19
  ## Authentication Zero 4.0.0 ##
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- authentication-zero (4.0.1)
4
+ authentication-zero (4.0.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -46,7 +46,6 @@ Since Authentication Zero generates this code into your application instead of b
46
46
  - Reset the user password and send reset instructions
47
47
  - Reset the user password only from verified emails
48
48
  - Lock mechanism to prevent email bombing (--lockable)
49
- - Rate limiting for your app, 1000 reqs/minute (--ratelimit)
50
49
  - Send e-mail confirmation when your email has been changed
51
50
  - Manage multiple sessions & devices
52
51
  - Activity log (--trackable)
@@ -1,3 +1,3 @@
1
1
  module AuthenticationZero
2
- VERSION = "4.0.1"
2
+ VERSION = "4.0.3"
3
3
  end
@@ -7,7 +7,6 @@ class AuthenticationGenerator < Rails::Generators::Base
7
7
  class_option :pwned, type: :boolean, desc: "Add pwned password validation"
8
8
  class_option :sudoable, type: :boolean, desc: "Add password request before sensitive data changes"
9
9
  class_option :lockable, type: :boolean, desc: "Add password reset locking"
10
- class_option :ratelimit, type: :boolean, desc: "Add request rate limiting"
11
10
  class_option :passwordless, type: :boolean, desc: "Add passwordless sign in"
12
11
  class_option :omniauthable, type: :boolean, desc: "Add social login support"
13
12
  class_option :trackable, type: :boolean, desc: "Add activity log support"
@@ -20,15 +19,10 @@ class AuthenticationGenerator < Rails::Generators::Base
20
19
  source_root File.expand_path("templates", __dir__)
21
20
 
22
21
  def add_gems
23
- gem "bcrypt", "~> 3.1.7", comment: "Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]"
24
-
25
- if options.ratelimit?
26
- gem "rack-ratelimit", group: :production, comment: "Use Rack::Ratelimit to rate limit requests [https://github.com/jeremy/rack-ratelimit]"
27
- end
28
-
29
- if redis?
30
- gem "redis", "~> 4.0", comment: "Use Redis adapter to run additional authentication features"
31
- gem "kredis", comment: "Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]"
22
+ if bcrypt_present?
23
+ uncomment_lines "Gemfile", /gem "bcrypt"/
24
+ else
25
+ gem "bcrypt", "~> 3.1.7", comment: "Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]"
32
26
  end
33
27
 
34
28
  if options.pwned?
@@ -50,14 +44,7 @@ class AuthenticationGenerator < Rails::Generators::Base
50
44
  end
51
45
  end
52
46
 
53
- def add_environment_configurations
54
- application "config.action_mailer.default_url_options = { host: \"localhost\", port: 3000 }", env: "development"
55
- application "config.action_mailer.default_url_options = { host: \"localhost\", port: 3000 }", env: "test"
56
- environment ratelimit_block, env: "production" if options.ratelimit?
57
- end
58
-
59
47
  def create_configuration_files
60
- copy_file "config/redis/shared.yml" if redis?
61
48
  copy_file "config/initializers/omniauth.rb" if omniauthable?
62
49
  copy_file "config/initializers/webauthn.rb" if webauthn?
63
50
  end
@@ -124,8 +111,8 @@ class AuthenticationGenerator < Rails::Generators::Base
124
111
  def install_javascript
125
112
  return unless webauthn?
126
113
  copy_file "javascript/controllers/web_authn_controller.js", "app/javascript/controllers/web_authn_controller.js"
127
- run "bin/importmap pin @rails/request.js" if importmaps?
128
- run "yarn add @rails/request.js" if node?
114
+ run "bin/importmap pin @rails/request.js @github/webauthn-json" if importmaps?
115
+ run "yarn add @rails/request.js @github/webauthn-json" if node?
129
116
  end
130
117
 
131
118
  def create_views
@@ -258,8 +245,8 @@ class AuthenticationGenerator < Rails::Generators::Base
258
245
  options.sudoable? && !options.api?
259
246
  end
260
247
 
261
- def redis?
262
- options.ratelimit? || sudoable?
248
+ def bcrypt_present?
249
+ File.read("Gemfile").include?('gem "bcrypt"')
263
250
  end
264
251
 
265
252
  def importmaps?
@@ -269,11 +256,4 @@ class AuthenticationGenerator < Rails::Generators::Base
269
256
  def node?
270
257
  Rails.root.join("package.json").exist?
271
258
  end
272
-
273
- def ratelimit_block
274
- <<~CODE
275
- # Rate limit general requests by IP address in a rate of 1000 requests per minute
276
- config.middleware.use(Rack::Ratelimit, name: "General", rate: [1000, 1.minute], redis: Redis.new, logger: Rails.logger) { |env| ActionDispatch::Request.new(env).ip }
277
- CODE
278
- end
279
259
  end
@@ -1,4 +1,7 @@
1
1
  class ApplicationController < ActionController::Base
2
+ # Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has.
3
+ allow_browser versions: :modern
4
+
2
5
  before_action :set_current_request_details
3
6
  before_action :authenticate
4
7
 
@@ -6,7 +6,7 @@ class Sessions::SudosController < ApplicationController
6
6
  session_record = Current.session
7
7
 
8
8
  if session_record.user.authenticate(params[:password])
9
- session_record.sudo.mark; redirect_to(params[:proceed_to_url])
9
+ session_record.touch(:sudo_at); redirect_to(params[:proceed_to_url])
10
10
  else
11
11
  redirect_to new_sessions_sudo_path(proceed_to_url: params[:proceed_to_url]), alert: "The password you entered is incorrect"
12
12
  end
@@ -4,6 +4,9 @@ class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Mi
4
4
  t.references :user, null: false, foreign_key: true
5
5
  t.string :user_agent
6
6
  t.string :ip_address
7
+ <%- if sudoable? %>
8
+ t.datetime :sudo_at, null: false
9
+ <%- end -%>
7
10
 
8
11
  t.timestamps
9
12
  end
@@ -1,18 +1,21 @@
1
1
  class Session < ApplicationRecord
2
2
  belongs_to :user
3
- <%- if sudoable? %>
4
- kredis_flag :sudo, expires_in: 30.minutes
5
- <%- end -%>
6
3
 
7
4
  before_create do
8
5
  self.user_agent = Current.user_agent
9
6
  self.ip_address = Current.ip_address
7
+ <%- if sudoable? %>
8
+ self.sudo_at = Time.current
9
+ <%- end -%>
10
10
  end
11
- <%- if sudoable? %>
12
- after_create { sudo.mark }
13
- <%- end -%>
14
11
  <%- if options.trackable? %>
15
12
  after_create { user.events.create! action: "signed_in" }
16
13
  after_destroy { user.events.create! action: "signed_out" }
17
14
  <%- end -%>
15
+ <%- if sudoable? %>
16
+
17
+ def sudo?
18
+ sudo_at > 30.minutes.ago
19
+ end
20
+ <%- end -%>
18
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authentication-zero
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nixon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-08 00:00:00.000000000 Z
11
+ date: 2024-10-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -37,7 +37,6 @@ files:
37
37
  - lib/generators/authentication/authentication_generator.rb
38
38
  - lib/generators/authentication/templates/config/initializers/omniauth.rb
39
39
  - lib/generators/authentication/templates/config/initializers/webauthn.rb
40
- - lib/generators/authentication/templates/config/redis/shared.yml
41
40
  - lib/generators/authentication/templates/controllers/api/application_controller.rb.tt
42
41
  - lib/generators/authentication/templates/controllers/api/authentications/events_controller.rb.tt
43
42
  - lib/generators/authentication/templates/controllers/api/identity/email_verifications_controller.rb.tt
@@ -1,10 +0,0 @@
1
- production: &production
2
- url: <%= ENV.fetch("REDIS_URL", "redis://127.0.0.1:6379/0") %>
3
- timeout: 1
4
-
5
- development: &development
6
- url: <%= ENV.fetch("REDIS_URL", "redis://127.0.0.1:6379/0") %>
7
- timeout: 1
8
-
9
- test:
10
- <<: *development