action_auth 1.4.2 → 1.5.1

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: bd82e71b203279a24d5a44196f1e9df519ef646f611f4b1ff3ad7e6b8bc043a9
4
- data.tar.gz: d4df3340ffdcaa481b49f5e8518a2720b7bec664d2daf47a3c3d594e8a06215a
3
+ metadata.gz: 4d991a1cd381778da7c3ed0b5ef0878790e81bdd668098eff84937cd4831c0ea
4
+ data.tar.gz: 82e3f14dc10fc5b67311ef397fd155d92102bab8ef51b6a3494e760f9ff9463d
5
5
  SHA512:
6
- metadata.gz: 4c02bbf9ea57e5361291a20c6c36a1ad994dfec332eecb50c562380041388f74923b2bb7f227ed835e03e5317e7668485c4229349cb752d94b7585830341ac1e
7
- data.tar.gz: a6cce71017754f203e43c231a3e604836c904475d899f8a02347a347dcd77b1f3ee27de50a78b1f5c8f6c19eb8bbc54f62e83fab3beb5c596318dfb88fd9d0b6
6
+ metadata.gz: 77dd6d551f7891f62fb2dd10f1fcc17bd6daca8660edf25e232e05b6e2ca6c4ad83b9e4ce73c1f247c2b770d9e4430eb5d681466844ca09a593f77f2c0e79c24
7
+ data.tar.gz: b6247d918574f799757b41345c234dd8cd78545ff81dd49c57528d7994c62d46adf7c0e9c5e6275c4bbf5eb28be27cba4df5cf5d5e1043256b8b317c59b93e43
data/README.md CHANGED
@@ -61,6 +61,23 @@ add_foreign_key :nfcs, :users, column: :user_id unless foreign_key_exists?(:nfcs
61
61
  ```
62
62
 
63
63
  ## Installation
64
+
65
+ ### Automatic Installation
66
+
67
+ Add this line to your application's Gemfile:
68
+
69
+ ```ruby
70
+ bundle add action_auth
71
+ ```
72
+
73
+ Then run the rake task to copy over the migrations, config and routes.
74
+
75
+ ```bash
76
+ bin/rails action_auth:install
77
+ ```
78
+
79
+ ### Manual Installation
80
+
64
81
  Add this line to your application's Gemfile:
65
82
 
66
83
  ```ruby
@@ -103,8 +120,9 @@ ActionAuth.configure do |config|
103
120
  config.default_from_email = "from@example.com"
104
121
  config.magic_link_enabled = true
105
122
  config.passkey_only = true # Allows sign in with only a passkey
123
+ config.pwned_enabled = true # defined?(Pwned)
106
124
  config.verify_email_on_sign_in = true
107
- config.webauthn_enabled = true
125
+ config.webauthn_enabled = true # defined?(WebAuthn)
108
126
  config.webauthn_origin = "http://localhost:3000" # or "https://example.com"
109
127
  config.webauthn_rp_name = Rails.application.class.to_s.deconstantize
110
128
  end
@@ -171,3 +171,78 @@ input[type="password"] {
171
171
  .action-auth--text-center {
172
172
  text-align: center !important;
173
173
  }
174
+
175
+ @media (prefers-color-scheme: dark) {
176
+ body {
177
+ color: #d5c4a1;
178
+ background-color: #282828 !important;
179
+ }
180
+
181
+ .container,
182
+ .container-fluid {
183
+ background-color: #3c3836 !important;
184
+ border-color: #3c3836 !important;
185
+ }
186
+
187
+ input[type="text"],
188
+ input[type="email"],
189
+ input[type="password"] {
190
+ color: #d5c4a1;
191
+ background-color: #282828;
192
+ border-color: #3c3836;
193
+ }
194
+
195
+ .btn {
196
+ color: #fbf1c7;
197
+ background-color: #d65d0e;
198
+ border-color: #d65d0e;
199
+ }
200
+
201
+ .btn:hover {
202
+ background-color: #cc241d;
203
+ border-color: #cc241d;
204
+ }
205
+
206
+ .btn:focus {
207
+ box-shadow: 0 0 0 0.25rem rgba(214, 93, 14, .5);
208
+ }
209
+
210
+ .btn:disabled {
211
+ background-color: #d65d0e;
212
+ border-color: #d65d0e;
213
+ color: #fbf1c7;
214
+ }
215
+
216
+ .action-auth--table {
217
+ background-color: #3c3836;
218
+ color: #d5c4a1;
219
+ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
220
+ }
221
+
222
+ .action-auth--table thead {
223
+ background-color: #d79921;
224
+ color: #282828;
225
+ }
226
+
227
+ .action-auth--table th,
228
+ .action-auth--table td {
229
+ border-bottom: 1px solid #504945;
230
+ }
231
+
232
+ .action-auth--table tbody tr:hover {
233
+ background-color: #282828;
234
+ }
235
+
236
+ a {
237
+ color: #83a598;
238
+ text-decoration: none;
239
+ }
240
+
241
+ a:visited {
242
+ color: #d3869b;
243
+ }
244
+
245
+ a:hover {
246
+ color: #fabd2f;
247
+ }
248
+ }
@@ -38,7 +38,8 @@ class ActionAuth::WebauthnCredentialsController < ApplicationController
38
38
  external_id: webauthn_credential.id,
39
39
  nickname: params[:credential_nickname],
40
40
  public_key: webauthn_credential.public_key,
41
- sign_count: webauthn_credential.sign_count
41
+ sign_count: webauthn_credential.sign_count,
42
+ key_type: key_type
42
43
  )
43
44
 
44
45
  if credential.save
@@ -57,4 +58,27 @@ class ActionAuth::WebauthnCredentialsController < ApplicationController
57
58
 
58
59
  redirect_to sessions_path
59
60
  end
61
+
62
+ private
63
+
64
+ def key_type
65
+ transports = params.dig(:response, :transports)
66
+ return :unknown unless transports.present?
67
+
68
+ transport_types = {
69
+ ["internal", "hybrid"] => :passkey,
70
+ ["usb", "nfc"] => :hardware,
71
+ ["bluetooth", "wireless"] => :wireless,
72
+ }.freeze
73
+
74
+ transport_types.each do |keys, type|
75
+ if transports.is_a?(String)
76
+ return type if keys.include?(transports)
77
+ elsif transports.is_a?(Array)
78
+ return type if (keys & transports).any?
79
+ end
80
+ end
81
+
82
+ :unknown
83
+ end
60
84
  end
@@ -10,5 +10,12 @@ module ActionAuth
10
10
  greater_than_or_equal_to: 0,
11
11
  less_than_or_equal_to: 2**32 - 1
12
12
  }
13
+
14
+ enum :key_type, {
15
+ unknown: 0,
16
+ passkey: 1,
17
+ hardware: 2,
18
+ wireless: 3
19
+ }
13
20
  end
14
21
  end
@@ -36,6 +36,7 @@
36
36
  <thead>
37
37
  <tr>
38
38
  <th>Key</th>
39
+ <th>Type</th>
39
40
  <th nowrap>Registered On</th>
40
41
  <th nowrap></th>
41
42
  </tr>
@@ -44,6 +45,7 @@
44
45
  <% current_user.webauthn_credentials.each do |credential| %>
45
46
  <%= content_tag :tr, id: dom_id(credential) do %>
46
47
  <td><%= credential.nickname %></td>
48
+ <td><%= credential.key_type %></td>
47
49
  <td nowrap><%= credential.created_at.strftime('%B %d, %Y') %></td>
48
50
  <td nowrap><%= button_to "Delete", credential, method: :delete, class: "btn btn-primary" %></td>
49
51
  <% end %>
@@ -10,7 +10,7 @@
10
10
  class: "action-auth--text-center" do %>
11
11
 
12
12
  <div class="mb-3 action-auth--text-center">
13
- Insert a USB key, if necessary, and tap it.
13
+ You must use a passkey, not a hardware key, to sign in.
14
14
  An account with a matching passkey is required.
15
15
  </div>
16
16
  <% end %>
@@ -0,0 +1,5 @@
1
+ class AddTypeToWebauthnCredentials < ActiveRecord::Migration[7.2]
2
+ def change
3
+ add_column :webauthn_credentials, :key_type, :integer, default: 0, limit: 2
4
+ end
5
+ end
@@ -4,6 +4,8 @@ module ActionAuth
4
4
  attr_accessor :allow_user_deletion
5
5
  attr_accessor :default_from_email
6
6
  attr_accessor :magic_link_enabled
7
+ attr_accessor :passkey_only
8
+ attr_accessor :pwned_enabled
7
9
  attr_accessor :verify_email_on_sign_in
8
10
  attr_accessor :webauthn_enabled
9
11
  attr_accessor :webauthn_origin
@@ -1,3 +1,3 @@
1
1
  module ActionAuth
2
- VERSION = "1.4.2"
2
+ VERSION = "1.5.1"
3
3
  end
@@ -1,4 +1,49 @@
1
- # desc "Explaining what the task does"
2
- # task :action_auth do
3
- # # Task goes here
4
- # end
1
+ desc "Installs Configs, Migrations, and Routes for ActionAuth"
2
+ namespace :action_auth do
3
+ task :install do
4
+ # Copies to config/initializers/action_auth.rb
5
+ puts "Installing ActionAuth Configs"
6
+ config_file_path = Rails.root.join('config', 'initializers', 'action_auth.rb')
7
+ unless File.exist?(config_file_path)
8
+ File.open(config_file_path, 'w') do |file|
9
+ file.puts <<~RUBY
10
+ # ActionAuth.configure do |config|
11
+ # config.allow_user_deletion = true
12
+ # config.default_from_email = "from@example.com"
13
+ # config.magic_link_enabled = true
14
+ # config.passkey_only = true # Allows sign in with only a passkey
15
+ # config.pwned_enabled = true # defined?(Pwned)
16
+ # config.verify_email_on_sign_in = true
17
+ # config.webauthn_enabled = true # defined?(WebAuthn)
18
+ # config.webauthn_origin = "http://localhost:3000" # or "https://example.com"
19
+ # config.webauthn_rp_name = Rails.application.class.to_s.deconstantize
20
+ # end
21
+ RUBY
22
+ end
23
+ puts "Created config/initializers/action_auth.rb"
24
+ else
25
+ puts "Config file already exists at config/initializers/action_auth.rb"
26
+ end
27
+
28
+ # Installs the ActionAuth Migrations
29
+ puts "Installing ActionAuth Migrations"
30
+ Rake::Task["action_auth:install:migrations"].invoke
31
+
32
+ # Add ActionAuth routes to config/routes.rb
33
+ puts "Installing ActionAuth Routes"
34
+ routes_file_path = Rails.root.join('config', 'routes.rb')
35
+ route_line = "mount ActionAuth::Engine => \"/action_auth\""
36
+ routes_content = File.read(routes_file_path)
37
+ unless routes_content.include?(route_line)
38
+ insert_after = "Rails.application.routes.draw do"
39
+ new_routes_content = routes_content.sub(/(#{insert_after})/i, "\\1\n #{route_line}\n")
40
+ File.open(routes_file_path, 'w') do |file|
41
+ file.puts new_routes_content
42
+ end
43
+ puts "Added ActionAuth route to config/routes.rb"
44
+ else
45
+ puts "ActionAuth route already present in config/routes.rb"
46
+ end
47
+
48
+ end
49
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Kimura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-16 00:00:00.000000000 Z
11
+ date: 2024-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -98,6 +98,7 @@ files:
98
98
  - db/migrate/20231107170349_create_action_auth_sessions.rb
99
99
  - db/migrate/20240111125859_add_webauthn_credentials.rb
100
100
  - db/migrate/20240111142545_add_webauthn_id_to_users.rb
101
+ - db/migrate/20240818032321_add_type_to_webauthn_credentials.rb
101
102
  - lib/action_auth.rb
102
103
  - lib/action_auth/configuration.rb
103
104
  - lib/action_auth/controllers/helpers.rb