authsignal-ruby 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/authsignal/version.rb +1 -1
- data/lib/authsignal.rb +7 -9
- 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: 553049be926d596da10a2e826338db41bd2a9a8a3fa2dbbf545b4b7d2850d828
|
4
|
+
data.tar.gz: 0d510dfa15063a1730f6490d93aed9614f4e88167eb44c76309460632d9cc499
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90bbb9bb3d7c738995816d34a1cdd7a251edb593dca9f87698d1bcddcbcc4da77d4eb529b17297ed322f2a6bd564909eeb8cf7b6722b4200acacd09e139c7877
|
7
|
+
data.tar.gz: 1dc7095f53fb925f7702207b34a13bd052e9d4b835ea4880968d54027b70254aa3b69332debbc8c407994d918eb3e653f96f58741fd0eeac77c338114d247021
|
data/Gemfile.lock
CHANGED
data/lib/authsignal/version.rb
CHANGED
data/lib/authsignal.rb
CHANGED
@@ -69,35 +69,33 @@ module Authsignal
|
|
69
69
|
false
|
70
70
|
end
|
71
71
|
|
72
|
-
def validate_challenge(
|
73
|
-
token = request[:token]
|
74
|
-
|
72
|
+
def validate_challenge(user_id:, token:)
|
75
73
|
begin
|
76
74
|
decoded_token = JWT.decode(token, Authsignal.configuration.api_secret_key)[0]
|
77
75
|
rescue JWT::DecodeError
|
78
76
|
puts 'Token verification failed'
|
79
77
|
end
|
80
78
|
|
81
|
-
|
79
|
+
decoded_user_id = decoded_token["other"]["userId"]
|
82
80
|
action_code = decoded_token["other"]["actionCode"]
|
83
81
|
idempotency_key = decoded_token["other"]["idempotencyKey"]
|
84
82
|
|
85
|
-
if
|
86
|
-
return { user_id:
|
83
|
+
if user_id != decoded_user_id
|
84
|
+
return { user_id: decoded_user_id, success: false, state: nil }
|
87
85
|
end
|
88
86
|
|
89
87
|
if action_code && idempotency_key
|
90
|
-
action_result = get_action(user_id:
|
88
|
+
action_result = get_action(user_id: decoded_user_id, action_code: action_code, idempotency_key: idempotency_key)
|
91
89
|
|
92
90
|
if action_result
|
93
91
|
state = action_result[:state]
|
94
92
|
success = state == "CHALLENGE_SUCCEEDED"
|
95
93
|
|
96
|
-
return { user_id:
|
94
|
+
return { user_id: decoded_user_id, success: success, state: state, action: action_code }
|
97
95
|
end
|
98
96
|
end
|
99
97
|
|
100
|
-
{ user_id:
|
98
|
+
{ user_id: decoded_user_id, success: false, state: nil }
|
101
99
|
end
|
102
100
|
|
103
101
|
private
|