omniauth-humanid 0.0.15 → 0.0.20
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 +4 -4
- data/Gemfile.lock +1 -1
- data/bin/update +9 -1
- data/lib/omniauth-humanid.rb +59 -5
- data/omniauth-humanid.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73bac9396336b430957d2055ecf42bc2beeb9e8dc074bfdd724ec25241ceb146
|
4
|
+
data.tar.gz: fc808758428d8d81e06da8351afbb600fb38dfc32c026a8fae456f9836cbb9bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c534d28064f18c63b75141400ff9bb0f6a388450a696b30a8d99850f4850a3b6b6cd876cb035aa59573be40cb9f1610c248562d22f51aebf5675926c7376e87
|
7
|
+
data.tar.gz: 1d86533a039f20ddeaf992e748cd18940d1cafda30d1ad285ca67dac402349fba4076c35688dae70fffed0d6e5daad29b7d7c2cfac18b3c700ca8c403b0f3a4c
|
data/Gemfile.lock
CHANGED
data/bin/update
CHANGED
@@ -26,8 +26,16 @@ x = x.join("\n")
|
|
26
26
|
puts x
|
27
27
|
File.write('./omniauth-humanid.gemspec', x)
|
28
28
|
puts "_______________________________________________"
|
29
|
+
puts "BUNDLE UPDATE"
|
30
|
+
puts `bundle update`
|
31
|
+
puts "_______________________________________________"
|
32
|
+
puts "GIT ADD"
|
29
33
|
puts `git add *`
|
30
34
|
puts "_______________________________________________"
|
35
|
+
puts "GIT COMMIT"
|
31
36
|
puts `git commit -m 'minor changes to version #{version_new}'`
|
32
37
|
puts "_______________________________________________"
|
33
|
-
puts
|
38
|
+
puts "INSTALL GEM LOCALLY"
|
39
|
+
puts `bundle exec rake install`
|
40
|
+
puts "_______________________________________________"
|
41
|
+
puts "info: write 'bundle exec rake release' to release the current version to the interwebz"
|
data/lib/omniauth-humanid.rb
CHANGED
@@ -5,11 +5,8 @@ module OmniAuth
|
|
5
5
|
class Humanid
|
6
6
|
include OmniAuth::Strategy
|
7
7
|
#Omniauth strategy creation guide be useful
|
8
|
-
|
9
|
-
|
10
|
-
#then this guy created another useful blog 🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥
|
11
|
-
#🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥
|
12
|
-
#https://dev.to/vvo/devise-create-a-local-omniauth-strategy-for-slack-4066
|
8
|
+
#- https://github.com/omniauth/omniauth/wiki/Strategy-Contribution-Guide
|
9
|
+
#- note the request_phase and the callback_phase
|
13
10
|
|
14
11
|
#note the image in the below documentation, I will try to reference back to it below
|
15
12
|
#https://docs.human-id.org/web-sdk-integration-guide#api-request-web-log-in-session
|
@@ -22,6 +19,7 @@ module OmniAuth
|
|
22
19
|
option :priority_country, nil #this is an option in the docs, but they dont give an example value (otherwise I would set to united_states, or us, or 1)
|
23
20
|
option :client_secret, nil
|
24
21
|
option :client_id, nil
|
22
|
+
option :exchange_url, "https://core.human-id.org/[HUMANID_VERSION]/server/users/exchange"
|
25
23
|
|
26
24
|
# def self.humanid_button
|
27
25
|
# #see https://docs.human-id.org/web-sdk-integration-guide
|
@@ -94,6 +92,62 @@ module OmniAuth
|
|
94
92
|
request_phase_err(res)
|
95
93
|
end
|
96
94
|
end
|
95
|
+
#callback phase area
|
96
|
+
|
97
|
+
def get_exchange_uri
|
98
|
+
uri = URI(options.exchange_url.gsub('[HUMANID_VERSION]', options.humanid_version))
|
99
|
+
return uri
|
100
|
+
end
|
101
|
+
|
102
|
+
def callback_phase
|
103
|
+
#when the callback returns from humanID we still need to:
|
104
|
+
# 1. verify it is humanID who sent this request
|
105
|
+
# 2. get the uid and country code
|
106
|
+
#this is done in the verify exchange token step in the humanID docs.
|
107
|
+
|
108
|
+
#get the exchange_token from the humanID callback
|
109
|
+
Rails.logger.info("CALLBACK PHASE")
|
110
|
+
exchange_token = request.params['et']
|
111
|
+
Rails.logger.info("EXCHANGE TOKEN: #{exchange_token}")
|
112
|
+
|
113
|
+
#create the request (as per the humanID docs)
|
114
|
+
uri = get_exchange_uri
|
115
|
+
post_request = Net::HTTP::Post.new(uri)
|
116
|
+
post_request['client-id'] = get_client_id
|
117
|
+
post_request['client-secret'] = get_client_secret
|
118
|
+
post_request['Content-Type'] = 'application/json'
|
119
|
+
post_request.body = {"exchangeToken" => exchange_token}.to_json
|
120
|
+
#send the request, get the response.
|
121
|
+
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true){|http| http.request(post_request)}
|
122
|
+
Rails.logger.info("RESPONSE: #{res}")
|
123
|
+
if res.code == "200"
|
124
|
+
request.env['omniauth.auth'] = JSON.parse(res.body)
|
125
|
+
Rails.logger.info(request.env['omniauth.auth'])
|
126
|
+
else
|
127
|
+
str = "Issue with the callback_phase of humanid omniauth, response from human id has code: #{res.code}, and body: #{res.body}"
|
128
|
+
Rails.logger.error str
|
129
|
+
raise StandardError.new(str)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def uid
|
134
|
+
request.env['omniauth.auth']['data']['userAppId']
|
135
|
+
end
|
136
|
+
alias userAppId uid
|
137
|
+
|
138
|
+
def countryCide
|
139
|
+
request.env['omniauth.auth']['data']['countryCide']
|
140
|
+
end
|
141
|
+
alias country_cide countryCide
|
142
|
+
alias country_code countryCide
|
143
|
+
|
144
|
+
def info
|
145
|
+
request.env['omniauth.auth']['data']
|
146
|
+
end
|
147
|
+
|
148
|
+
def extra
|
149
|
+
request.env['omniauth.auth']
|
150
|
+
end
|
97
151
|
end
|
98
152
|
end
|
99
153
|
end
|
data/omniauth-humanid.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-humanid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luke Clancy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-08-
|
11
|
+
date: 2022-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|