action_auth 0.2.2 → 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: 59ec4916e3c5419a6e41d09f0d3ae58f01622bdc338759ceb977afeaa8f94f82
4
- data.tar.gz: 6d4cb0b65288ba2963f3fad43aa9147d8e1e9c9139679c1378750cea74d3646a
3
+ metadata.gz: 53e3c3e104dc46bd4e726f7513e1aecd04a4cbb45d5fb6f64c68cef215402283
4
+ data.tar.gz: 40c067a613238dcce61431c8ee8bdf70c013f4eccb4a9057531a9acfbd008119
5
5
  SHA512:
6
- metadata.gz: b9a7183e95f4bdb6a0a8b6ec8924d67ebb945ed1510467c36b52c51550ba963d13bca21906fa7dd61bd3c90cf7087952ff9a162cecc0790bae4e3b6966fec5f8
7
- data.tar.gz: b8a4ff19fdb107fe75b4cf96a9ac5d2b8fe9d2600522cdc6647691af1c93c69c5eb299c6c85a17c5291e218222ba50124b0a63f19f796963bf610b46939630e8
6
+ metadata.gz: 212ae2f001d0a7fd07bd77b51e69f625d77ec03a412083962614a4aa319dcba97f785e697a7797dfd794d84e80e6318791e5a3366f30b74eff87ead133af6ad6
7
+ data.tar.gz: 465003510e85a95bfc3cfc8a845b937c553b1023f7ee55f8204b2db3effd2fa3beefc2031f8c013d99cff439df5586657e42c192f246351f6903333a493d2963
@@ -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
  };
@@ -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.2"
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.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Kimura