action_auth 0.2.1 → 0.2.3

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: 5dfe867ff71fdec35c9997e465f8cb471a8ea57733373cec378c6117cf643a6b
4
- data.tar.gz: 16182c5888a401678b3d2637c3b0396e8730d06d4bef1da260c34b524a3fd296
3
+ metadata.gz: 53e3c3e104dc46bd4e726f7513e1aecd04a4cbb45d5fb6f64c68cef215402283
4
+ data.tar.gz: 40c067a613238dcce61431c8ee8bdf70c013f4eccb4a9057531a9acfbd008119
5
5
  SHA512:
6
- metadata.gz: e2fefbcc78596506ec864843444c196aa4e580b874f73fe53676409dba0d065a57527ae92cdc7a9fc061a3da498b15af24c8618389264dcac3ba32b39461e685
7
- data.tar.gz: 78dd9cd3b739ed973c506b94f83d6cbbfa8c228d025376b571a4f4c156a4be80b085fd9fe44ba6823cd687c926b4936869410fc1e7db0adc02ac8dd396668819
6
+ metadata.gz: 212ae2f001d0a7fd07bd77b51e69f625d77ec03a412083962614a4aa319dcba97f785e697a7797dfd794d84e80e6318791e5a3366f30b74eff87ead133af6ad6
7
+ data.tar.gz: 465003510e85a95bfc3cfc8a845b937c553b1023f7ee55f8204b2db3effd2fa3beefc2031f8c013d99cff439df5586657e42c192f246351f6903333a493d2963
data/README.md CHANGED
@@ -167,6 +167,13 @@ ActionAuth.configure do |config|
167
167
  end
168
168
  ```
169
169
 
170
+ ### Demo
171
+
172
+ Here's a view of the experience with WebAuthn
173
+
174
+ ![action_auth](https://github.com/kobaltz/action_auth/assets/635114/fa88d83c-5af5-471b-a094-ec9785ea2f87)
175
+
176
+
170
177
  ## License
171
178
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
172
179
 
@@ -12,7 +12,7 @@ const Credential = {
12
12
  }
13
13
  },
14
14
 
15
- callback: function (url, body) {
15
+ callback: function (url, body, redirectUrl) {
16
16
  const token = this.getCRFSToken();
17
17
  fetch(url, {
18
18
  method: "POST",
@@ -25,7 +25,8 @@ const Credential = {
25
25
  credentials: 'same-origin'
26
26
  }).then(function (response) {
27
27
  if (response.ok) {
28
- window.location.replace("/");
28
+ console.log("Credential created", response);
29
+ window.location.replace(redirectUrl);
29
30
  } else if (response.status < 500) {
30
31
  response.text();
31
32
  }
@@ -34,8 +35,9 @@ const Credential = {
34
35
 
35
36
  create: function (callbackUrl, credentialOptions) {
36
37
  const self = this;
38
+ const webauthnRedirectUrl = document.querySelector('meta[name="webauthn_redirect_url"]').getAttribute("content");
37
39
  WebAuthnJSON.create({ "publicKey": credentialOptions }).then(function (credential) {
38
- self.callback(callbackUrl, credential);
40
+ self.callback(callbackUrl, credential, webauthnRedirectUrl);
39
41
  });
40
42
  },
41
43
 
@@ -43,7 +45,7 @@ const Credential = {
43
45
  const self = this;
44
46
  const webauthnUrl = document.querySelector('meta[name="webauthn_auth_url"]').getAttribute("content");
45
47
  WebAuthnJSON.get({ "publicKey": credentialOptions }).then(function (credential) {
46
- self.callback(webauthnUrl, credential);
48
+ self.callback(webauthnUrl, credential, "/");
47
49
  });
48
50
  }
49
51
  };
@@ -67,7 +69,6 @@ Stimulus.register(
67
69
  class extends Controller {
68
70
  static values = { options: Object }
69
71
  connect() {
70
- console.log(this.optionsValue);
71
72
  if (this.hasOptionsValue) {
72
73
  Credential.get(this.optionsValue);
73
74
  }
@@ -154,3 +154,7 @@ input[type="password"] {
154
154
  .action-auth--table td {
155
155
  transition: background-color 0.3s;
156
156
  }
157
+
158
+ .action-auth--text-center {
159
+ text-align: center !important;
160
+ }
@@ -1,7 +1,7 @@
1
1
  class ActionAuth::WebauthnCredentialAuthenticationsController < ApplicationController
2
2
  before_action :ensure_user_not_authenticated
3
3
  before_action :ensure_login_initiated
4
- layout "action_auth/application-full-width"
4
+ layout "action_auth/application"
5
5
 
6
6
  def new
7
7
  get_options = WebAuthn::Credential.options_for_get(allow: user.action_auth_webauthn_credentials.pluck(:external_id))
@@ -1,6 +1,6 @@
1
1
  class ActionAuth::WebauthnCredentialsController < ApplicationController
2
2
  before_action :authenticate_user!
3
- layout "action_auth/application-full-width"
3
+ layout "action_auth/application"
4
4
 
5
5
  def new
6
6
  end
@@ -1,12 +1,18 @@
1
- <h2 class="">Use one of your security keys to sign in</h2>
1
+ <h2 class="action-auth--text-center">Use a passkey to sign in</h2>
2
2
 
3
3
  <%= content_tag :div,
4
4
  id: "webauthn_credential_form",
5
- data: { controller: "credential-authenticator",
6
- "credential-authenticator-options-value": @options } do %>
5
+ data: {
6
+ controller: "credential-authenticator",
7
+ "credential-authenticator-options-value": @options
8
+ },
9
+ class: "action-auth--text-center" do %>
7
10
 
8
- <div class="mb-3">
9
- If it's an USB key be sure to insert it and, if necessary, tap it.
11
+ <div class="mb-3 action-auth--text-center">
12
+ Insert a USB key, if necessary, and tap it.
10
13
  </div>
11
14
  <% end %>
12
15
 
16
+ <%= content_for :cancel_path do %>
17
+ <%= link_to "Cancel", action_auth.sign_in_path %>
18
+ <% end %>
@@ -1,4 +1,4 @@
1
- <h2 class="">Add a security key:</h2>
1
+ <h2 class="action-auth--text-center">Add a security key</h2>
2
2
  <%= form_with scope: :webauthn_credential,
3
3
  url: options_for_webauthn_credentials_path,
4
4
  id: "webauthn_credential_form",
@@ -11,11 +11,15 @@
11
11
  <%= form.text_field :nickname, autofocus: true, placeholder: "New Security Key nickname", required: true %>
12
12
  </div>
13
13
 
14
- <div class="mb-3">
14
+ <div class="mb-3 action-auth--text-center">
15
15
  <%= form.submit "Add Security Key", class: "btn btn-primary" %>
16
16
  </div>
17
17
 
18
- <div class="">
19
- <span class="">If it's an USB key be sure to insert it and, if necessary, tap it.</span>
18
+ <div class="mb-3 action-auth--text-center">
19
+ Insert a USB key, if necessary, and tap it.
20
20
  </div>
21
21
  <% end %>
22
+
23
+ <%= content_for :cancel_path do %>
24
+ <%= link_to "Cancel", action_auth.sessions_path %>
25
+ <% end %>
@@ -9,6 +9,7 @@
9
9
  <% if ActionAuth.configuration.webauthn_enabled? %>
10
10
  <%= tag :meta, name: :webauthn_auth_url, content: action_auth.webauthn_credential_authentications_url %>
11
11
  <%= tag :meta, name: :webauthn_cred_url, content: action_auth.webauthn_credentials_url %>
12
+ <%= tag :meta, name: :webauthn_redirect_url, content: action_auth.sessions_url %>
12
13
  <% end %>
13
14
  </head>
14
15
  <body class="bg-light">
@@ -6,10 +6,18 @@
6
6
  <%= csp_meta_tag %>
7
7
  <%= stylesheet_link_tag "action_auth/application", media: "all" %>
8
8
  <%= javascript_include_tag "action_auth/application", "data-turbo-track": "reload", type: "module" %>
9
+ <% if ActionAuth.configuration.webauthn_enabled? %>
10
+ <%= tag :meta, name: :webauthn_auth_url, content: action_auth.webauthn_credential_authentications_url %>
11
+ <%= tag :meta, name: :webauthn_cred_url, content: action_auth.webauthn_credentials_url %>
12
+ <%= tag :meta, name: :webauthn_redirect_url, content: action_auth.sessions_url %>
13
+ <% end %>
9
14
  </head>
10
15
  <body class="bg-light">
11
16
  <div class="container bg-white border pb-3">
12
17
  <%= yield %>
13
18
  </div>
19
+ <div class="action-auth--text-center">
20
+ <%= yield(:cancel_path) %>
21
+ </div>
14
22
  </body>
15
23
  </html>
@@ -1,3 +1,3 @@
1
1
  module ActionAuth
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Kimura