action_auth 0.2.2 → 0.2.4

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: 59ec4916e3c5419a6e41d09f0d3ae58f01622bdc338759ceb977afeaa8f94f82
4
- data.tar.gz: 6d4cb0b65288ba2963f3fad43aa9147d8e1e9c9139679c1378750cea74d3646a
3
+ metadata.gz: e0d4717c14c8a74f3c08552d11dadd6a709a9d7d23972b61f3627afa8ded5775
4
+ data.tar.gz: 9f5339e1e752f85e1136339805d04b7738b228f426846858dc5c596f6594a130
5
5
  SHA512:
6
- metadata.gz: b9a7183e95f4bdb6a0a8b6ec8924d67ebb945ed1510467c36b52c51550ba963d13bca21906fa7dd61bd3c90cf7087952ff9a162cecc0790bae4e3b6966fec5f8
7
- data.tar.gz: b8a4ff19fdb107fe75b4cf96a9ac5d2b8fe9d2600522cdc6647691af1c93c69c5eb299c6c85a17c5291e218222ba50124b0a63f19f796963bf610b46939630e8
6
+ metadata.gz: 9a1e71e5fa998a07f4bcd2c2db4be596b2d88da3a35545f53ad5242c7c51ee3c252a2be6086e727e6c5456426831a12608f9fe1c5c134f660057807ad363ef61
7
+ data.tar.gz: 80833cbffda59cf7335b3ab6fb9df49518ff510b391d450ec4805d09af3b6918f76f76800c495b4d4710be19bb9a66d324e8e6feec7deee8277f572f26936844
@@ -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.4"
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.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Kimura