omniauth-humanid 0.0.15 → 0.0.16
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/omniauth-humanid.rb +54 -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: 5a5ed99c0d238cd9c3afee8189db26ec6456234db59c5dbbd281d465aabe8067
|
4
|
+
data.tar.gz: 43c4d45f752b92f53336e7738f4d63ada4cffa98e15f3c57c8228dcf302bc0d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4af2cb6d650f53d5f5f1b483390c2f52e4cdce861f865d5645e92418ec60840b69fc2fb397f4dfae21a3f12c20f710ec3981e2cb8d9c4bdde9b8e260b4f9328e
|
7
|
+
data.tar.gz: bd0a85c43dd29624fb7fe77c00bb3d2d26131c44801b815dbc1dad413b341729326f6786b9f1589f37dff9f1aec51e57013c2dd9b33b41e2acf0f1863fd056ea
|
data/Gemfile.lock
CHANGED
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,57 @@ 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
|
+
|
112
|
+
#create the request (as per the humanID docs)
|
113
|
+
uri = get_exchange_uri
|
114
|
+
post_request = Net::HTTP::Post.new(uri)
|
115
|
+
post_request['client-id'] = get_client_id
|
116
|
+
post_request['client-secret'] = get_client_secret
|
117
|
+
post_request['Content-Type'] = 'application/json'
|
118
|
+
post_request.body = {"exchangeToken" => exchange_token}.to_json
|
119
|
+
#send the request, get the response.
|
120
|
+
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true){|http| http.request(post_request)}
|
121
|
+
if res.code == "200"
|
122
|
+
request.env['omniauth.auth'] = JSON.parse(res.body)
|
123
|
+
else
|
124
|
+
raise StandardError.new("Issue with the callback_phase of humanid omniauth, response from human id has code: #{res.code}, and body: #{res.body}")
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def uid
|
129
|
+
request.env['omniauth.auth']['data']['userAppId']
|
130
|
+
end
|
131
|
+
alias userAppId uid
|
132
|
+
|
133
|
+
def countryCide
|
134
|
+
request.env['omniauth.auth']['data']['countryCide']
|
135
|
+
end
|
136
|
+
alias country_cide countryCide
|
137
|
+
alias country_code countryCide
|
138
|
+
|
139
|
+
def info
|
140
|
+
request.env['omniauth.auth']['data']
|
141
|
+
end
|
142
|
+
|
143
|
+
def extra
|
144
|
+
request.env['omniauth.auth']
|
145
|
+
end
|
97
146
|
end
|
98
147
|
end
|
99
148
|
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.16
|
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:
|