authsignal-ruby 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/Rakefile +1 -1
- data/RakefileRelease +16 -0
- data/lib/authsignal/version.rb +1 -1
- data/lib/authsignal.rb +31 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f77d1646d619436a3c5e25b76be690252c3f4bf2dcb7588ea09cae4c11283017
|
4
|
+
data.tar.gz: 67ad78b10cb51e07b2f2726a4a8ad74ba094eacd37b0acd6436a4e89f9b7d306
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a02302caa711e51e25877b73e2b83c074ebd868e9f43eec42d0b29046f0f62a99ec07a930e73eb4204cffab72992831395e36b8f6d6a6a01e010536e2c550286
|
7
|
+
data.tar.gz: 5791b35e320bc81ca7f7137f736f847f7b2eae79073afe9eed0c91376e557dd63c2e0d952bf42d2d15dd04eac3c6827e003283e63e0f95f3cb681d4d3714ee3e
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
authsignal-ruby (0.1.
|
4
|
+
authsignal-ruby (0.1.5)
|
5
5
|
httparty (~> 0.21.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -16,7 +16,7 @@ GEM
|
|
16
16
|
httparty (0.21.0)
|
17
17
|
mini_mime (>= 1.0.0)
|
18
18
|
multi_xml (>= 0.5.2)
|
19
|
-
mini_mime (1.1.
|
19
|
+
mini_mime (1.1.5)
|
20
20
|
multi_xml (0.6.0)
|
21
21
|
public_suffix (4.0.7)
|
22
22
|
rake (13.0.6)
|
data/Rakefile
CHANGED
data/RakefileRelease
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rspec/core/rake_task"
|
5
|
+
require_relative 'lib/authsignal/version'
|
6
|
+
|
7
|
+
task default: :build_and_push_gem
|
8
|
+
|
9
|
+
RSpec::Core::RakeTask.new(:build_and_push_gem) do |task|
|
10
|
+
version = Authsignal::VERSION
|
11
|
+
puts "Building gem..."
|
12
|
+
sh "gem build authsignal-ruby.gemspec"
|
13
|
+
puts "Pushing authsignal-ruby-#{version} gem..."
|
14
|
+
sh "gem push authsignal-ruby-#{version}.gem"
|
15
|
+
puts "Gem authsignal-ruby-#{version} has been pushed."
|
16
|
+
end
|
data/lib/authsignal/version.rb
CHANGED
data/lib/authsignal.rb
CHANGED
@@ -69,6 +69,37 @@ module Authsignal
|
|
69
69
|
false
|
70
70
|
end
|
71
71
|
|
72
|
+
def validate_challenge(request)
|
73
|
+
token = request[:token]
|
74
|
+
|
75
|
+
begin
|
76
|
+
decoded_token = JWT.decode(token, Authsignal.configuration.api_secret_key)[0]
|
77
|
+
rescue JWT::DecodeError
|
78
|
+
puts 'Token verification failed'
|
79
|
+
end
|
80
|
+
|
81
|
+
user_id = decoded_token["other"]["userId"]
|
82
|
+
action_code = decoded_token["other"]["actionCode"]
|
83
|
+
idempotency_key = decoded_token["other"]["idempotencyKey"]
|
84
|
+
|
85
|
+
if request[:userId] && request[:userId] != user_id
|
86
|
+
return { user_id: user_id, success: false, state: nil }
|
87
|
+
end
|
88
|
+
|
89
|
+
if action_code && idempotency_key
|
90
|
+
action_result = get_action(user_id: user_id, action_code: action_code, idempotency_key: idempotency_key)
|
91
|
+
|
92
|
+
if action_result
|
93
|
+
state = action_result[:state]
|
94
|
+
success = state == "CHALLENGE_SUCCEEDED"
|
95
|
+
|
96
|
+
return { user_id: user_id, success: success, state: state, action: action_code }
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
{ user_id: user_id, success: false, state: nil }
|
101
|
+
end
|
102
|
+
|
72
103
|
private
|
73
104
|
def underscore(string)
|
74
105
|
string.gsub(/::/, '/').
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authsignal-ruby
|
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
|
- justinsoong
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-08-
|
11
|
+
date: 2023-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -81,6 +81,7 @@ files:
|
|
81
81
|
- LICENSE.txt
|
82
82
|
- README.md
|
83
83
|
- Rakefile
|
84
|
+
- RakefileRelease
|
84
85
|
- bin/console
|
85
86
|
- bin/setup
|
86
87
|
- lib/authsignal.rb
|
@@ -108,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
109
|
- !ruby/object:Gem::Version
|
109
110
|
version: '0'
|
110
111
|
requirements: []
|
111
|
-
rubygems_version: 3.
|
112
|
+
rubygems_version: 3.4.10
|
112
113
|
signing_key:
|
113
114
|
specification_version: 4
|
114
115
|
summary: The Authsignal ruby server side signal API.
|