omniauth-fishbrain 0.11.3 → 0.11.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 815a9d4e769ec9b9d05bb7cd0314395df844c3190b148960403207030b4b5cfc
4
- data.tar.gz: 29f2f2cde590788567aedfbb85ff569943f77a8068a3d78590a35876e2d762f6
3
+ metadata.gz: 58b986c338209b8d0078fe1575f66ebac4af360a662db67d0bfff5f3ee6a9dae
4
+ data.tar.gz: d111c45ee3100e0232bf0d5993b80430990bc39c20a7bc0cf7d97c33ec91de44
5
5
  SHA512:
6
- metadata.gz: 174826683c500756bc406c58e0bca176d9e43ded8eb65eaf4c445981e702dd6de42cf43a8e0a86bc64a29ba8b5d4ca621e9f6ccaf6524904b5acdef8054c3552
7
- data.tar.gz: c93625fad9bcc3ce07f51191992cc89cee90eef27b2593003ae807141a285c0ae963a40902bfdf2dbd006325af0c22edd75d63745782155d07432542a2788376
6
+ metadata.gz: 99441c0a1cf973b4a8a1ed557a3cf361ebbf54695f864bdcf0ad98ebc63d3798c70111a71dd77f262f1a64cd6743cad3ec5c65d544bd156c45a4eccb53e30c1e
7
+ data.tar.gz: e282f4cd037715c4e826938e33305f7d5b9a07784170fbb3d510599338683f2807aad4f6ad60307035e44000f37bebb6f6defd034f4534598b7fe316da04228f
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniAuth
4
4
  module Fishbrain
5
- VERSION = '0.11.3'
5
+ VERSION = '0.11.4'
6
6
  end
7
7
  end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'net/http'
4
+ require 'jwt'
5
+
6
+ module OmniAuth
7
+ module Fishbrain
8
+ class DecodeIdToken
9
+ AWS_REGION = 'eu-west-1'
10
+ USER_POOL_ID = 'eu-west-1_TKWveIcYu'
11
+
12
+ attr_reader :client_id, :aws_region, :user_pool_id, :jwt_leeway
13
+
14
+ def initialize(client_id, user_pool_id = USER_POOL_ID, aws_region = AWS_REGION)
15
+ @client_id = client_id
16
+ @user_pool_id = user_pool_id
17
+ @aws_region = aws_region
18
+ @jwt_leeway = 60
19
+ end
20
+
21
+ def decode(raw_id_token)
22
+ JWT.decode(raw_id_token, nil, true, decode_options).first
23
+ end
24
+
25
+ private
26
+
27
+ def decode_options
28
+ {
29
+ iss: iss,
30
+ aud: client_id,
31
+ verify_aud: true,
32
+ verify_expiration: true,
33
+ verify_iat: true,
34
+ verify_iss: true,
35
+ verify_not_before: true,
36
+ leeway: jwt_leeway,
37
+ algorithm: 'RS256',
38
+ jwks: jwks,
39
+ }
40
+ end
41
+
42
+ def iss
43
+ "https://cognito-idp.#{aws_region}.amazonaws.com/#{user_pool_id}"
44
+ end
45
+
46
+ def jwks
47
+ @_jwks ||= "#{iss}/.well-known/jwks.json"
48
+ .yield_self(&URI.method(:parse))
49
+ .yield_self(&Net::HTTP.method(:get))
50
+ .yield_self { |it| JSON.parse(it, symbolize_names: true) }
51
+ end
52
+ end
53
+ end
54
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-fishbrain
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.3
4
+ version: 0.11.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erik Dalen
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-05-28 00:00:00.000000000 Z
12
+ date: 2020-06-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jwt
@@ -51,6 +51,7 @@ files:
51
51
  - README.markdown
52
52
  - lib/omniauth-fishbrain.rb
53
53
  - lib/omniauth-fishbrain/version.rb
54
+ - lib/omniauth/fishbrain/decode_id_token.rb
54
55
  - lib/omniauth/fishbrain/premium_status.rb
55
56
  - lib/omniauth/fishbrain/verifies_id_token.rb
56
57
  - lib/omniauth/strategies/fishbrain.rb
@@ -74,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
75
  - !ruby/object:Gem::Version
75
76
  version: '0'
76
77
  requirements: []
77
- rubygems_version: 3.1.2
78
+ rubygems_version: 3.0.3
78
79
  signing_key:
79
80
  specification_version: 4
80
81
  summary: OmniAuth strategy for Fishbrain