passkeys-rails 0.1.4 → 0.1.5
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1967aeb595e4864973402bf8108fe5a56b668678b8ed56aafbc403b164c628d
|
4
|
+
data.tar.gz: c96c2cd39bedbc138c1cd35248432d9cf7626c5a96007b91981741eb6f56e478
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3eb9182122196e3c94b5ebb78b0984785c39fb194b6d7f5f95432eb63e53482be0190fe24bc2af914a38377ee1a82df80932b11c16f918d155fdbaa731b5a052
|
7
|
+
data.tar.gz: e16475967c805796248fb3188667456e31fd833f841b98d16c28a6b5964e59170d349a018580a5e1ab312f18f7a9f7f16693b612d70d97f6ce91a5a77a9e5db4
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
[](https://badge.fury.io/rb/passkeys-rails)
|
2
2
|
[](https://travis-ci.org/alliedcode/passkeys-rails)
|
3
3
|
[](https://codecov.io/gh/alliedcode/passkeys-rails)
|
4
4
|
|
@@ -9,21 +9,22 @@ module PasskeysRails
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def current_agent
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
@current_agent ||= (request.headers['HTTP_X_AUTH'].present? &&
|
13
|
+
passkey_authentication_result.success? &&
|
14
|
+
passkey_authentication_result.agent.registered? &&
|
15
|
+
passkey_authentication_result.agent) || nil
|
15
16
|
end
|
16
17
|
|
17
18
|
def authenticate_passkey!
|
18
|
-
return if
|
19
|
+
return if current_agent.present?
|
19
20
|
|
20
21
|
raise PasskeysRails::Error.new(:authentication,
|
21
22
|
code: :unauthorized,
|
22
23
|
message: "You are not authorized to access this resource.")
|
23
24
|
end
|
24
25
|
|
25
|
-
def
|
26
|
-
@
|
26
|
+
def passkey_authentication_result
|
27
|
+
@passkey_authentication_result ||= PasskeysRails::ValidateAuthToken.call(auth_token: request.headers['HTTP_X_AUTH'])
|
27
28
|
end
|
28
29
|
end
|
29
30
|
end
|
@@ -5,14 +5,16 @@ module PasskeysRails
|
|
5
5
|
delegate :username, to: :context
|
6
6
|
|
7
7
|
def call
|
8
|
-
agent =
|
8
|
+
agent = create_or_replace_unregistered_agent
|
9
9
|
|
10
10
|
context.options = WebAuthn::Credential.options_for_create(user: { id: agent.webauthn_identifier, name: agent.username })
|
11
11
|
end
|
12
12
|
|
13
13
|
private
|
14
14
|
|
15
|
-
def
|
15
|
+
def create_or_replace_unregistered_agent
|
16
|
+
Agent.unregistered.where(username:).destroy_all
|
17
|
+
|
16
18
|
agent = Agent.create(username:, webauthn_identifier: WebAuthn.generate_user_id)
|
17
19
|
|
18
20
|
context.fail!(code: :validation_errors, message: agent.errors.full_messages.to_sentence) unless agent.valid?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: passkeys-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Troy Anderson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-07-
|
11
|
+
date: 2023-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|