omniauth-doximity-oauth2 1.2.0.pre → 1.2.0.pre.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -1
- data/Gemfile.lock +1 -1
- data/lib/omniauth/strategies/doximity_oauth2.rb +1 -1
- data/lib/omniauth-doximity-oauth2/crypto.rb +19 -17
- data/lib/omniauth-doximity-oauth2/version.rb +1 -1
- 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: 6125c48f6bde54da8c8d37acce9d03017b818c4024ba45a77eedb08dc6ced957
|
4
|
+
data.tar.gz: 6dbbfd75beab8b9e88e67d99a54bbe9a6be837f4d5ed5b0228934804ab6e58f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70aa3ebad66b71b82d49c798589e1cd67412853dcde60a80fe7311e3be3df646da34020e7fdc143a9742cc92c0dd08be9802a198abb95f7d816e1dffc4eec79c
|
7
|
+
data.tar.gz: 3e3ca067a61109392048de65e1e76a100e7373edc34c08633cc638282b8c0082af2909ecb35f5f74ec4d49423eabf84df96877239be4e270fb6723d8a861cd63
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -102,7 +102,7 @@ module OmniAuth
|
|
102
102
|
keys = request_keys
|
103
103
|
|
104
104
|
public_key_params = keys.find { |key| key["kid"] == header["kid"] }
|
105
|
-
rsa_key = Crypto.create_rsa_key(public_key_params["n"], public_key_params["e"])
|
105
|
+
rsa_key = OmniAuth::DoximityOauth2::Crypto.create_rsa_key(public_key_params["n"], public_key_params["e"])
|
106
106
|
|
107
107
|
body, = JWT.decode(token, rsa_key.public_key, true, { algorithm: header["alg"] })
|
108
108
|
body
|
@@ -4,26 +4,28 @@ module Omniauth
|
|
4
4
|
module DoximityOauth2
|
5
5
|
# Static crypto methods
|
6
6
|
class Crypto
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
7
|
+
class << self
|
8
|
+
def create_rsa_key(n, e)
|
9
|
+
data_sequence = OpenSSL::ASN1::Sequence([
|
10
|
+
OpenSSL::ASN1::Integer(base64_to_long(n)),
|
11
|
+
OpenSSL::ASN1::Integer(base64_to_long(e))
|
12
|
+
])
|
13
|
+
asn1 = OpenSSL::ASN1::Sequence(data_sequence)
|
14
|
+
OpenSSL::PKey::RSA.new(asn1.to_der)
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
+
private
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
def base64_to_long(data)
|
20
|
+
decoded_with_padding = Base64.urlsafe_decode64(data) + Base64.decode64("==")
|
21
|
+
decoded_with_padding.to_s.unpack("C*").map do |byte|
|
22
|
+
byte_to_hex(byte)
|
23
|
+
end.join.to_i(16)
|
24
|
+
end
|
24
25
|
|
25
|
-
|
26
|
-
|
26
|
+
def byte_to_hex(int)
|
27
|
+
int < 16 ? "0#{int.to_s(16)}" : int.to_s(16)
|
28
|
+
end
|
27
29
|
end
|
28
30
|
end
|
29
31
|
end
|