authentication-zero 2.16.25 → 2.16.27
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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +10 -6
- data/lib/authentication_zero/version.rb +1 -1
- data/lib/generators/authentication/authentication_generator.rb +58 -66
- data/lib/generators/authentication/templates/erb/home/index.html.erb.tt +2 -6
- data/lib/generators/authentication/templates/erb/invitations/new.html.erb.tt +6 -0
- data/lib/generators/authentication/templates/erb/two_factor_authentication/challenge/totps/new.html.erb.tt +1 -3
- data/lib/generators/authentication/templates/erb/two_factor_authentication/profile/recovery_codes/index.html.erb.tt +1 -1
- data/lib/generators/authentication/templates/erb/two_factor_authentication/profile/security_keys/index.html.erb.tt +9 -1
- data/lib/generators/authentication/templates/erb/two_factor_authentication/profile/totps/new.html.erb.tt +6 -0
- data/lib/generators/authentication/templates/erb/user_mailer/email_verification.html.erb.tt +1 -1
- data/lib/generators/authentication/templates/erb/user_mailer/passwordless.html.erb.tt +1 -1
- data/lib/generators/authentication/templates/javascript/controllers/{application.js.tt → application.js} +0 -4
- data/lib/generators/authentication/templates/test_unit/{users.yml.tt → users.yml} +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 396a7e8c26e49c9b91d5b349155eb5d2cb4dbbd2012bb2a89977cb66c7446e39
|
4
|
+
data.tar.gz: 11cdeee70ab80f387208315d585ed0dd0f9cee431b5405e67f77d009bdbfe80d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2be5682d873fdbc960630bc19f5210242813584f1af36667d8737944633436de50c1d72875a493a902dea041c062978805878cf4b4ef5d88b4dd20665d1ad393
|
7
|
+
data.tar.gz: 78d17cb5827821a1a30dff4133325d1fd46eab620c6785dfcae0e58c6ac815ff8d21fd3bfecf9b069ecf70f90e8146d6755d58b59863ad6e01d3f1208eafb5a8
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -20,19 +20,15 @@ Since Authentication Zero generates this code into your application instead of b
|
|
20
20
|
|
21
21
|
## Features
|
22
22
|
|
23
|
-
|
24
|
-
|
23
|
+
### Essential
|
24
|
+
|
25
25
|
- Sign up
|
26
26
|
- Email and password validations
|
27
27
|
- Checks if a password has been found in any data breach (--pwned)
|
28
28
|
- Authentication by cookie
|
29
29
|
- Authentication by token (--api)
|
30
|
-
- Passwordless authentication (--passwordless)
|
31
30
|
- Two factor authentication + recovery codes (--two-factor)
|
32
31
|
- Two factor authentication using a hardware security key (--webauthn)
|
33
|
-
- Social Login with OmniAuth (--omniauthable)
|
34
|
-
- Send invitations (--invitable)
|
35
|
-
- Sign-in as button functionallity (--masqueradable)
|
36
32
|
- Verify email using a link with token
|
37
33
|
- Ask password before sensitive data changes, aka: sudo (--sudoable)
|
38
34
|
- Reset the user password and send reset instructions
|
@@ -44,6 +40,14 @@ Since Authentication Zero generates this code into your application instead of b
|
|
44
40
|
- Activity log (--trackable)
|
45
41
|
- Log out
|
46
42
|
|
43
|
+
### More
|
44
|
+
|
45
|
+
- Social login with omni auth (--omniauthable)
|
46
|
+
- Passwordless authentication (--passwordless)
|
47
|
+
- Send invitations (--invitable)
|
48
|
+
- "Sign-in as" button functionallity (--masqueradable)
|
49
|
+
|
50
|
+
|
47
51
|
## Generated code
|
48
52
|
|
49
53
|
- [has_secure_password](https://api.rubyonrails.org/classes/ActiveModel/SecurePassword/ClassMethods.html#method-i-has_secure_password): Adds methods to set and authenticate against a bcrypt password.
|
@@ -26,7 +26,7 @@ class AuthenticationGenerator < Rails::Generators::Base
|
|
26
26
|
end
|
27
27
|
|
28
28
|
if redis?
|
29
|
-
gem "redis", "
|
29
|
+
gem "redis", "~> 4.0", comment: "Use Redis adapter to run additional authentication features"
|
30
30
|
gem "kredis", comment: "Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]"
|
31
31
|
end
|
32
32
|
|
@@ -62,68 +62,65 @@ class AuthenticationGenerator < Rails::Generators::Base
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def create_migrations
|
65
|
-
migration_template "migrations/create_users_migration.rb", "#{db_migrate_path}/create_users.rb"
|
66
|
-
migration_template "migrations/create_sessions_migration.rb", "#{db_migrate_path}/create_sessions.rb"
|
67
65
|
migration_template "migrations/create_email_verification_tokens_migration.rb", "#{db_migrate_path}/create_email_verification_tokens.rb"
|
68
|
-
migration_template "migrations/create_password_reset_tokens_migration.rb", "#{db_migrate_path}/create_password_reset_tokens.rb"
|
69
|
-
migration_template "migrations/create_sign_in_tokens_migration.rb", "#{db_migrate_path}/create_sign_in_tokens_migration.rb" if passwordless?
|
70
66
|
migration_template "migrations/create_events_migration.rb", "#{db_migrate_path}/create_events.rb" if options.trackable?
|
67
|
+
migration_template "migrations/create_password_reset_tokens_migration.rb", "#{db_migrate_path}/create_password_reset_tokens.rb"
|
71
68
|
migration_template "migrations/create_recovery_codes_migration.rb", "#{db_migrate_path}/create_recovery_codes.rb" if two_factor?
|
72
69
|
migration_template "migrations/create_security_keys_migration.rb", "#{db_migrate_path}/create_security_keys.rb" if webauthn?
|
70
|
+
migration_template "migrations/create_sessions_migration.rb", "#{db_migrate_path}/create_sessions.rb"
|
71
|
+
migration_template "migrations/create_sign_in_tokens_migration.rb", "#{db_migrate_path}/create_sign_in_tokens_migration.rb" if passwordless?
|
72
|
+
migration_template "migrations/create_users_migration.rb", "#{db_migrate_path}/create_users.rb"
|
73
73
|
end
|
74
74
|
|
75
75
|
def create_models
|
76
|
-
template "models/user.rb", "app/models/user.rb"
|
77
|
-
template "models/session.rb", "app/models/session.rb"
|
78
|
-
template "models/email_verification_token.rb", "app/models/email_verification_token.rb"
|
79
|
-
template "models/password_reset_token.rb", "app/models/password_reset_token.rb"
|
80
|
-
template "models/sign_in_token.rb", "app/models/sign_in_token.rb" if passwordless?
|
81
76
|
template "models/current.rb", "app/models/current.rb"
|
77
|
+
template "models/email_verification_token.rb", "app/models/email_verification_token.rb"
|
82
78
|
template "models/event.rb", "app/models/event.rb" if options.trackable?
|
79
|
+
template "models/password_reset_token.rb", "app/models/password_reset_token.rb"
|
83
80
|
template "models/recovery_code.rb", "app/models/recovery_code.rb" if two_factor?
|
84
81
|
template "models/security_key.rb", "app/models/security_key.rb" if webauthn?
|
82
|
+
template "models/session.rb", "app/models/session.rb"
|
83
|
+
template "models/sign_in_token.rb", "app/models/sign_in_token.rb" if passwordless?
|
84
|
+
template "models/user.rb", "app/models/user.rb"
|
85
85
|
end
|
86
86
|
|
87
87
|
def create_fixture_file
|
88
|
-
|
88
|
+
copy_file "test_unit/users.yml", "test/fixtures/users.yml"
|
89
89
|
end
|
90
90
|
|
91
91
|
def create_controllers
|
92
|
-
template
|
92
|
+
template "controllers/#{format}/authentications/events_controller.rb", "app/controllers/authentications/events_controller.rb" if options.trackable?
|
93
93
|
|
94
|
-
directory "controllers/#{
|
94
|
+
directory "controllers/#{format}/identity", "app/controllers/identity"
|
95
95
|
|
96
|
-
if
|
97
|
-
|
98
|
-
|
99
|
-
template "controllers/html/two_factor_authentication/profile/security_keys_controller.rb", "app/controllers/two_factor_authentication/profile/security_keys_controller.rb" if webauthn?
|
96
|
+
template "controllers/#{format}/sessions/omniauth_controller.rb", "app/controllers/sessions/omniauth_controller.rb" if omniauthable?
|
97
|
+
template "controllers/#{format}/sessions/passwordlesses_controller.rb", "app/controllers/sessions/passwordlesses_controller.rb" if passwordless?
|
98
|
+
template "controllers/#{format}/sessions/sudos_controller.rb", "app/controllers/sessions/sudos_controller.rb" if sudoable?
|
100
99
|
|
101
|
-
|
100
|
+
if two_factor?
|
102
101
|
template "controllers/html/two_factor_authentication/challenge/recovery_codes_controller.rb", "app/controllers/two_factor_authentication/challenge/recovery_codes_controller.rb"
|
103
102
|
template "controllers/html/two_factor_authentication/challenge/security_keys_controller.rb", "app/controllers/two_factor_authentication/challenge/security_keys_controller.rb" if webauthn?
|
103
|
+
template "controllers/html/two_factor_authentication/challenge/totps_controller.rb", "app/controllers/two_factor_authentication/challenge/totps_controller.rb"
|
104
|
+
|
105
|
+
template "controllers/html/two_factor_authentication/profile/recovery_codes_controller.rb", "app/controllers/two_factor_authentication/profile/recovery_codes_controller.rb"
|
106
|
+
template "controllers/html/two_factor_authentication/profile/security_keys_controller.rb", "app/controllers/two_factor_authentication/profile/security_keys_controller.rb" if webauthn?
|
107
|
+
template "controllers/html/two_factor_authentication/profile/totps_controller.rb", "app/controllers/two_factor_authentication/profile/totps_controller.rb"
|
104
108
|
end
|
105
109
|
|
106
|
-
template
|
107
|
-
template
|
108
|
-
template
|
109
|
-
template
|
110
|
-
template
|
111
|
-
template
|
112
|
-
template
|
113
|
-
template "controllers/#{format_folder}/sessions/omniauth_controller.rb", "app/controllers/sessions/omniauth_controller.rb" if omniauthable?
|
114
|
-
template "controllers/#{format_folder}/sessions/passwordlesses_controller.rb", "app/controllers/sessions/passwordlesses_controller.rb" if passwordless?
|
115
|
-
template "controllers/#{format_folder}/authentications/events_controller.rb", "app/controllers/authentications/events_controller.rb" if options.trackable?
|
110
|
+
template "controllers/#{format}/application_controller.rb", "app/controllers/application_controller.rb", force: true
|
111
|
+
template "controllers/#{format}/home_controller.rb", "app/controllers/home_controller.rb" unless options.api?
|
112
|
+
template "controllers/#{format}/invitations_controller.rb", "app/controllers/invitations_controller.rb" if invitable?
|
113
|
+
template "controllers/#{format}/masquerades_controller.rb", "app/controllers/masquerades_controller.rb" if masqueradable?
|
114
|
+
template "controllers/#{format}/passwords_controller.rb", "app/controllers/passwords_controller.rb"
|
115
|
+
template "controllers/#{format}/registrations_controller.rb", "app/controllers/registrations_controller.rb"
|
116
|
+
template "controllers/#{format}/sessions_controller.rb", "app/controllers/sessions_controller.rb"
|
116
117
|
end
|
117
118
|
|
118
|
-
def
|
119
|
-
return
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
if webauthn?
|
124
|
-
run "bin/importmap pin stimulus-web-authn" if importmaps?
|
125
|
-
run "yarn add stimulus-web-authn" if node?
|
126
|
-
end
|
119
|
+
def install_javascript
|
120
|
+
return unless webauthn?
|
121
|
+
copy_file "javascript/controllers/application.js", "app/javascript/controllers/application.js", force: true
|
122
|
+
run "bin/importmap pin stimulus-web-authn" if importmaps?
|
123
|
+
run "yarn add stimulus-web-authn" if node?
|
127
124
|
end
|
128
125
|
|
129
126
|
def create_views
|
@@ -131,37 +128,32 @@ class AuthenticationGenerator < Rails::Generators::Base
|
|
131
128
|
template "erb/user_mailer/email_verification.html.erb", "app/views/user_mailer/email_verification.html.erb"
|
132
129
|
template "erb/user_mailer/password_reset.html.erb", "app/views/user_mailer/password_reset.html.erb"
|
133
130
|
else
|
134
|
-
|
135
|
-
template "erb/user_mailer/password_reset.html.erb", "app/views/user_mailer/password_reset.html.erb"
|
136
|
-
template "erb/user_mailer/invitation_instructions.html.erb", "app/views/user_mailer/invitation_instructions.html.erb" if invitable?
|
137
|
-
template "erb/user_mailer/passwordless.html.erb", "app/views/user_mailer/passwordless.html.erb" if passwordless?
|
138
|
-
|
131
|
+
directory "erb/authentications/events", "app/views/authentications/events" if options.trackable?
|
139
132
|
directory "erb/home", "app/views/home"
|
140
|
-
|
141
133
|
directory "erb/identity", "app/views/identity"
|
134
|
+
directory "erb/invitations", "app/views/invitations" if invitable?
|
142
135
|
directory "erb/passwords", "app/views/passwords"
|
143
136
|
directory "erb/registrations", "app/views/registrations"
|
144
137
|
|
145
|
-
directory "erb/invitations", "app/views/invitations" if invitable?
|
146
|
-
|
147
|
-
template "erb/sessions/index.html.erb", "app/views/sessions/index.html.erb"
|
148
|
-
template "erb/sessions/new.html.erb", "app/views/sessions/new.html.erb"
|
149
|
-
|
150
|
-
directory "erb/sessions/sudos", "app/views/sessions/sudos" if sudoable?
|
151
|
-
|
152
138
|
directory "erb/sessions/passwordlesses", "app/views/sessions/passwordlesses" if passwordless?
|
153
|
-
|
154
|
-
|
139
|
+
directory "erb/sessions/sudos", "app/views/sessions/sudos" if sudoable?
|
140
|
+
template "erb/sessions/index.html.erb", "app/views/sessions/index.html.erb"
|
141
|
+
template "erb/sessions/new.html.erb", "app/views/sessions/new.html.erb"
|
155
142
|
|
156
143
|
if two_factor?
|
157
|
-
directory "erb/two_factor_authentication/profile/totps", "app/views/two_factor_authentication/profile/totps"
|
158
|
-
directory "erb/two_factor_authentication/profile/recovery_codes", "app/views/two_factor_authentication/profile/recovery_codes"
|
159
|
-
directory "erb/two_factor_authentication/profile/security_keys", "app/views/two_factor_authentication/profile/security_keys" if webauthn?
|
160
|
-
|
161
|
-
directory "erb/two_factor_authentication/challenge/totps", "app/views/two_factor_authentication/challenge/totps"
|
162
144
|
directory "erb/two_factor_authentication/challenge/recovery_codes", "app/views/two_factor_authentication/challenge/recovery_codes"
|
163
145
|
directory "erb/two_factor_authentication/challenge/security_keys", "app/views/two_factor_authentication/challenge/security_keys" if webauthn?
|
146
|
+
directory "erb/two_factor_authentication/challenge/totps", "app/views/two_factor_authentication/challenge/totps"
|
147
|
+
|
148
|
+
directory "erb/two_factor_authentication/profile/recovery_codes", "app/views/two_factor_authentication/profile/recovery_codes"
|
149
|
+
directory "erb/two_factor_authentication/profile/security_keys", "app/views/two_factor_authentication/profile/security_keys" if webauthn?
|
150
|
+
directory "erb/two_factor_authentication/profile/totps", "app/views/two_factor_authentication/profile/totps"
|
164
151
|
end
|
152
|
+
|
153
|
+
template "erb/user_mailer/email_verification.html.erb", "app/views/user_mailer/email_verification.html.erb"
|
154
|
+
template "erb/user_mailer/invitation_instructions.html.erb", "app/views/user_mailer/invitation_instructions.html.erb" if invitable?
|
155
|
+
template "erb/user_mailer/password_reset.html.erb", "app/views/user_mailer/password_reset.html.erb"
|
156
|
+
template "erb/user_mailer/passwordless.html.erb", "app/views/user_mailer/passwordless.html.erb" if passwordless?
|
165
157
|
end
|
166
158
|
end
|
167
159
|
|
@@ -223,7 +215,7 @@ class AuthenticationGenerator < Rails::Generators::Base
|
|
223
215
|
end
|
224
216
|
|
225
217
|
def create_test_files
|
226
|
-
directory "test_unit/controllers/#{
|
218
|
+
directory "test_unit/controllers/#{format}", "test/controllers"
|
227
219
|
directory "test_unit/mailers/", "test/mailers"
|
228
220
|
directory "test_unit/system", "test/system" unless options.api?
|
229
221
|
template "test_unit/test_helper.rb", "test/test_helper.rb", force: true
|
@@ -231,17 +223,10 @@ class AuthenticationGenerator < Rails::Generators::Base
|
|
231
223
|
end
|
232
224
|
|
233
225
|
private
|
234
|
-
def
|
226
|
+
def format
|
235
227
|
options.api? ? "api" : "html"
|
236
228
|
end
|
237
229
|
|
238
|
-
def ratelimit_block
|
239
|
-
<<~CODE
|
240
|
-
# Rate limit general requests by IP address in a rate of 1000 requests per minute
|
241
|
-
config.middleware.use(Rack::Ratelimit, name: "General", rate: [1000, 1.minute], redis: Redis.new, logger: Rails.logger) { |env| ActionDispatch::Request.new(env).ip }
|
242
|
-
CODE
|
243
|
-
end
|
244
|
-
|
245
230
|
def omniauthable?
|
246
231
|
options.omniauthable? && !options.api?
|
247
232
|
end
|
@@ -281,4 +266,11 @@ class AuthenticationGenerator < Rails::Generators::Base
|
|
281
266
|
def node?
|
282
267
|
Rails.root.join("package.json").exist?
|
283
268
|
end
|
269
|
+
|
270
|
+
def ratelimit_block
|
271
|
+
<<~CODE
|
272
|
+
# Rate limit general requests by IP address in a rate of 1000 requests per minute
|
273
|
+
config.middleware.use(Rack::Ratelimit, name: "General", rate: [1000, 1.minute], redis: Redis.new, logger: Rails.logger) { |env| ActionDispatch::Request.new(env).ip }
|
274
|
+
CODE
|
275
|
+
end
|
284
276
|
end
|
@@ -29,9 +29,7 @@
|
|
29
29
|
</div>
|
30
30
|
<%- end -%>
|
31
31
|
<%- if masqueradable? %>
|
32
|
-
|
33
|
-
<%%= button_to "Signin as last user", user_masquerade_path(User.last) %>
|
34
|
-
</div>
|
32
|
+
<%%= button_to "Signin as last user", user_masquerade_path(User.last) %>
|
35
33
|
<%- end -%>
|
36
34
|
|
37
35
|
<h2>Access history</h2>
|
@@ -47,6 +45,4 @@
|
|
47
45
|
|
48
46
|
<br>
|
49
47
|
|
50
|
-
|
51
|
-
<%%= button_to "Log out", Current.session, method: :delete %>
|
52
|
-
</div>
|
48
|
+
<%%= button_to "Log out", Current.session, method: :delete %>
|
@@ -15,9 +15,7 @@
|
|
15
15
|
|
16
16
|
<div>
|
17
17
|
<p><strong>Don't have your phone?</strong></p>
|
18
|
-
<div>
|
19
|
-
<%%= link_to "Use a recovery code to access your account.", new_two_factor_authentication_challenge_recovery_codes_path %>
|
20
|
-
</div>
|
18
|
+
<div><%%= link_to "Use a recovery code to access your account.", new_two_factor_authentication_challenge_recovery_codes_path %></div>
|
21
19
|
<%- if webauthn? %>
|
22
20
|
<%% if @user.security_keys.exists? %>
|
23
21
|
<div><%%= link_to "Use a security key to access your account.", new_two_factor_authentication_challenge_security_keys_path %></div>
|
@@ -7,4 +7,12 @@
|
|
7
7
|
|
8
8
|
<br>
|
9
9
|
|
10
|
-
|
10
|
+
<div>
|
11
|
+
<%%= link_to "Add security key", new_two_factor_authentication_profile_security_key_path %>
|
12
|
+
</div>
|
13
|
+
|
14
|
+
<br>
|
15
|
+
|
16
|
+
<div>
|
17
|
+
<%%= link_to "Back", root_path %>
|
18
|
+
</div>
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
<p><strong>You must hit the link below to confirm that you received this email.</strong></p>
|
6
6
|
|
7
|
-
|
7
|
+
<p><%%= link_to "Yes, use this email for my account", identity_email_verification_url(sid: @signed_id) %></p>
|
8
8
|
|
9
9
|
<hr>
|
10
10
|
|
@@ -1,12 +1,8 @@
|
|
1
1
|
import { Application } from "@hotwired/stimulus"
|
2
|
-
<%- if webauthn? -%>
|
3
2
|
import WebAuthnController from "stimulus-web-authn"
|
4
|
-
<%- end -%>
|
5
3
|
|
6
4
|
const application = Application.start()
|
7
|
-
<%- if webauthn? -%>
|
8
5
|
application.register("web-authn", WebAuthnController)
|
9
|
-
<%- end -%>
|
10
6
|
|
11
7
|
// Configure Stimulus development experience
|
12
8
|
application.debug = false
|
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: 2.16.
|
4
|
+
version: 2.16.27
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nixon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-04-
|
11
|
+
date: 2023-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -94,7 +94,7 @@ files:
|
|
94
94
|
- lib/generators/authentication/templates/erb/user_mailer/invitation_instructions.html.erb.tt
|
95
95
|
- lib/generators/authentication/templates/erb/user_mailer/password_reset.html.erb.tt
|
96
96
|
- lib/generators/authentication/templates/erb/user_mailer/passwordless.html.erb.tt
|
97
|
-
- lib/generators/authentication/templates/javascript/controllers/application.js
|
97
|
+
- lib/generators/authentication/templates/javascript/controllers/application.js
|
98
98
|
- lib/generators/authentication/templates/mailers/user_mailer.rb.tt
|
99
99
|
- lib/generators/authentication/templates/migrations/create_email_verification_tokens_migration.rb.tt
|
100
100
|
- lib/generators/authentication/templates/migrations/create_events_migration.rb.tt
|
@@ -133,7 +133,7 @@ files:
|
|
133
133
|
- lib/generators/authentication/templates/test_unit/system/registrations_test.rb.tt
|
134
134
|
- lib/generators/authentication/templates/test_unit/system/sessions_test.rb.tt
|
135
135
|
- lib/generators/authentication/templates/test_unit/test_helper.rb.tt
|
136
|
-
- lib/generators/authentication/templates/test_unit/users.yml
|
136
|
+
- lib/generators/authentication/templates/test_unit/users.yml
|
137
137
|
homepage: https://github.com/lazaronixon/authentication-zero
|
138
138
|
licenses:
|
139
139
|
- MIT
|