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 +4 -4
- data/app/assets/javascripts/action_auth/application.js +6 -4
- data/app/assets/stylesheets/action_auth/application.css +4 -0
- data/app/controllers/action_auth/webauthn_credential_authentications_controller.rb +1 -1
- data/app/controllers/action_auth/webauthn_credentials_controller.rb +1 -1
- data/app/views/action_auth/webauthn_credential_authentications/new.html.erb +11 -5
- data/app/views/action_auth/webauthn_credentials/new.html.erb +8 -4
- data/app/views/layouts/action_auth/application-full-width.html.erb +1 -0
- data/app/views/layouts/action_auth/application.html.erb +8 -0
- data/lib/action_auth/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53e3c3e104dc46bd4e726f7513e1aecd04a4cbb45d5fb6f64c68cef215402283
|
4
|
+
data.tar.gz: 40c067a613238dcce61431c8ee8bdf70c013f4eccb4a9057531a9acfbd008119
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
};
|
@@ -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
|
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,12 +1,18 @@
|
|
1
|
-
<h2 class="">Use
|
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: {
|
6
|
-
|
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
|
-
|
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
|
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
|
-
|
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>
|
data/lib/action_auth/version.rb
CHANGED