omniauth-facebook2 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d869a7ba2cd2246e67ee9bf54357d49dac8f98b2a923e54b4f7b5958e4b5f3e3
4
- data.tar.gz: e4c61f6ae8e9ee156a3683cb0d46731f2963497965865224bfe873cbcd40e119
3
+ metadata.gz: c2fed6fe78aaec447b3ef10186c6b09e5af585c7362887b1ab2a690e6a494d92
4
+ data.tar.gz: b9419b8295724e0ed582c78c2b5275b4aa40897ff0e81ef04a046b495da89f89
5
5
  SHA512:
6
- metadata.gz: 5c078bbeb1a197d0a4f41aae96af96b315e8da4ebe95fbdc3eeb30fcd53beb5bee538cfae299e21dc6043836619c4e435fa171ca3f9b5be8fb39b8a790020183
7
- data.tar.gz: e08a6b86e68247f5220f703c68ace0b8acdafaa4350ec93cf173506db47a86e83b427bb9203ccc4907ef79513534d7c1243ea14541a5ac0ce7f0a65ef0dfac6a
6
+ metadata.gz: 15478c0698d021ac155fca06623a826999362b3a161bcd839ec65bbd731887e477767c8504a107ce87c8bca38bf8dba6f004c07d47106a1a3050d528db97d4c3
7
+ data.tar.gz: 671e5abb1f82d17f267fa972eb01e2cd5cbfb194651f5aac4c98f0306bc10c3af6329bc97388df45ab2708a2ede7897d03d1f58c8318d30de63d2af4bf57698f
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # OmniAuth Facebook2 Strategy
1
+ # OmniAuth Facebook Strategy
2
2
 
3
3
  [![Test](https://github.com/icoretech/omniauth-facebook2/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/icoretech/omniauth-facebook2/actions/workflows/test.yml?query=branch%3Amain)
4
4
  [![Gem Version](https://badge.fury.io/rb/omniauth-facebook2.svg)](https://badge.fury.io/rb/omniauth-facebook2)
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'base64'
4
- require 'json'
5
- require 'openssl'
3
+ require "base64"
4
+ require "json"
5
+ require "openssl"
6
6
 
7
7
  module OmniAuth
8
8
  module Facebook2
@@ -10,7 +10,7 @@ module OmniAuth
10
10
  class SignedRequest
11
11
  class UnknownSignatureAlgorithmError < NotImplementedError; end
12
12
 
13
- SUPPORTED_ALGORITHM = 'HMAC-SHA256'
13
+ SUPPORTED_ALGORITHM = "HMAC-SHA256"
14
14
 
15
15
  attr_reader :value, :secret
16
16
 
@@ -30,26 +30,26 @@ module OmniAuth
30
30
  private
31
31
 
32
32
  def parse_signed_request
33
- signature, encoded_payload = value.to_s.split('.', 2)
33
+ signature, encoded_payload = value.to_s.split(".", 2)
34
34
  return if blank?(signature) || blank?(encoded_payload)
35
35
 
36
36
  decoded_signature = base64_decode_url(signature)
37
37
  decoded_payload = JSON.parse(base64_decode_url(encoded_payload))
38
38
 
39
- unless decoded_payload['algorithm'] == SUPPORTED_ALGORITHM
40
- raise UnknownSignatureAlgorithmError, "unknown algorithm: #{decoded_payload['algorithm']}"
39
+ unless decoded_payload["algorithm"] == SUPPORTED_ALGORITHM
40
+ raise UnknownSignatureAlgorithmError, "unknown algorithm: #{decoded_payload["algorithm"]}"
41
41
  end
42
42
 
43
43
  decoded_payload if valid_signature?(decoded_signature, encoded_payload)
44
44
  end
45
45
 
46
- def valid_signature?(signature, payload, algorithm = OpenSSL::Digest.new('SHA256'))
46
+ def valid_signature?(signature, payload, algorithm = OpenSSL::Digest.new("SHA256"))
47
47
  OpenSSL::HMAC.digest(algorithm, secret, payload) == signature
48
48
  end
49
49
 
50
50
  def base64_decode_url(value)
51
- value += '=' * ((4 - value.size.modulo(4)) % 4)
52
- Base64.decode64(value.tr('-_', '+/'))
51
+ value += "=" * ((4 - value.size.modulo(4)) % 4)
52
+ Base64.decode64(value.tr("-_", "+/"))
53
53
  end
54
54
 
55
55
  def blank?(value)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniAuth
4
4
  module Facebook2
5
- VERSION = '0.1.2'
5
+ VERSION = "0.1.3"
6
6
  end
7
7
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'omniauth/facebook2/version'
4
- require 'omniauth/facebook2/signed_request'
5
- require 'omniauth/strategies/facebook2'
3
+ require "omniauth/facebook2/version"
4
+ require "omniauth/facebook2/signed_request"
5
+ require "omniauth/strategies/facebook2"
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'omniauth-oauth2'
4
- require 'openssl'
5
- require 'rack/utils'
6
- require 'uri'
3
+ require "omniauth-oauth2"
4
+ require "openssl"
5
+ require "rack/utils"
6
+ require "uri"
7
7
 
8
8
  module OmniAuth
9
9
  module Strategies
@@ -11,12 +11,12 @@ module OmniAuth
11
11
  class Facebook2 < OmniAuth::Strategies::OAuth2
12
12
  class NoAuthorizationCodeError < StandardError; end
13
13
 
14
- DEFAULT_SCOPE = 'email'
15
- DEFAULT_FACEBOOK_API_VERSION = 'v25.0'
16
- DEFAULT_INFO_FIELDS = 'name,email'
17
- DEFAULT_TOKEN_URL = 'oauth/access_token'
14
+ DEFAULT_SCOPE = "email"
15
+ DEFAULT_FACEBOOK_API_VERSION = "v25.0"
16
+ DEFAULT_INFO_FIELDS = "name,email"
17
+ DEFAULT_TOKEN_URL = "oauth/access_token"
18
18
 
19
- option :name, 'facebook2'
19
+ option :name, "facebook2"
20
20
  option :scope, DEFAULT_SCOPE
21
21
  option :api_version, DEFAULT_FACEBOOK_API_VERSION
22
22
  option :authorize_options, %i[scope display auth_type config_id redirect_uri]
@@ -25,61 +25,61 @@ module OmniAuth
25
25
  option :authorization_code_from_signed_request_in_cookie, nil
26
26
 
27
27
  option :client_options,
28
- site: "https://graph.facebook.com/#{DEFAULT_FACEBOOK_API_VERSION}",
29
- authorize_url: "https://www.facebook.com/#{DEFAULT_FACEBOOK_API_VERSION}/dialog/oauth",
30
- token_url: DEFAULT_TOKEN_URL,
31
- connection_opts: {
32
- headers: {
33
- user_agent: 'icoretech-omniauth-facebook2 gem',
34
- accept: 'application/json',
35
- content_type: 'application/json'
36
- }
37
- }
28
+ site: "https://graph.facebook.com/#{DEFAULT_FACEBOOK_API_VERSION}",
29
+ authorize_url: "https://www.facebook.com/#{DEFAULT_FACEBOOK_API_VERSION}/dialog/oauth",
30
+ token_url: DEFAULT_TOKEN_URL,
31
+ connection_opts: {
32
+ headers: {
33
+ user_agent: "icoretech-omniauth-facebook2 gem",
34
+ accept: "application/json",
35
+ content_type: "application/json"
36
+ }
37
+ }
38
38
 
39
39
  option :access_token_options,
40
- header_format: 'OAuth %s',
41
- param_name: 'access_token'
40
+ header_format: "OAuth %s",
41
+ param_name: "access_token"
42
42
 
43
- uid { raw_info['id'] }
43
+ uid { raw_info["id"] }
44
44
 
45
45
  info do
46
46
  prune(
47
47
  {
48
- 'nickname' => raw_info['username'],
49
- 'email' => raw_info['email'],
50
- 'name' => raw_info['name'],
51
- 'first_name' => raw_info['first_name'],
52
- 'last_name' => raw_info['last_name'],
53
- 'image' => image_url(uid),
54
- 'description' => raw_info['bio'],
55
- 'urls' => {
56
- 'Facebook' => raw_info['link'],
57
- 'Website' => raw_info['website']
48
+ "nickname" => raw_info["username"],
49
+ "email" => raw_info["email"],
50
+ "name" => raw_info["name"],
51
+ "first_name" => raw_info["first_name"],
52
+ "last_name" => raw_info["last_name"],
53
+ "image" => image_url(uid),
54
+ "description" => raw_info["bio"],
55
+ "urls" => {
56
+ "Facebook" => raw_info["link"],
57
+ "Website" => raw_info["website"]
58
58
  },
59
- 'location' => raw_info.dig('location', 'name'),
60
- 'verified' => raw_info['verified']
59
+ "location" => raw_info.dig("location", "name"),
60
+ "verified" => raw_info["verified"]
61
61
  }
62
62
  )
63
63
  end
64
64
 
65
65
  credentials do
66
66
  {
67
- 'token' => access_token.token,
68
- 'refresh_token' => access_token.refresh_token,
69
- 'expires_at' => access_token.expires_at,
70
- 'expires' => access_token.expires?,
71
- 'scope' => token_scope
67
+ "token" => access_token.token,
68
+ "refresh_token" => access_token.refresh_token,
69
+ "expires_at" => access_token.expires_at,
70
+ "expires" => access_token.expires?,
71
+ "scope" => token_scope
72
72
  }.compact
73
73
  end
74
74
 
75
75
  extra do
76
76
  data = {}
77
- data['raw_info'] = raw_info unless skip_info?
77
+ data["raw_info"] = raw_info unless skip_info?
78
78
  prune(data)
79
79
  end
80
80
 
81
81
  def raw_info
82
- @raw_info ||= access_token.get('me', info_options).parsed || {}
82
+ @raw_info ||= access_token.get("me", info_options).parsed || {}
83
83
  end
84
84
 
85
85
  def info_options
@@ -89,7 +89,7 @@ module OmniAuth
89
89
  params[:appsecret_proof] = appsecret_proof if options[:appsecret_proof]
90
90
  params[:locale] = options[:locale] if options[:locale]
91
91
 
92
- { params: params }
92
+ {params: params}
93
93
  end
94
94
 
95
95
  def callback_phase
@@ -115,13 +115,13 @@ module OmniAuth
115
115
  end
116
116
 
117
117
  def callback_url
118
- return '' if options.authorization_code_from_signed_request_in_cookie
118
+ return "" if options.authorization_code_from_signed_request_in_cookie
119
119
 
120
120
  options[:callback_url] || super
121
121
  end
122
122
 
123
123
  def query_string
124
- return '' if request.params['code']
124
+ return "" if request.params["code"]
125
125
 
126
126
  super
127
127
  end
@@ -163,10 +163,10 @@ module OmniAuth
163
163
  end
164
164
 
165
165
  def with_authorization_code!
166
- if request.params.key?('code') && !blank?(request.params['code'])
166
+ if request.params.key?("code") && !blank?(request.params["code"])
167
167
  yield
168
- elsif (code_from_signed_request = signed_request_from_cookie && signed_request_from_cookie['code'])
169
- request.params['code'] = code_from_signed_request
168
+ elsif (code_from_signed_request = signed_request_from_cookie && signed_request_from_cookie["code"])
169
+ request.params["code"] = code_from_signed_request
170
170
  options.authorization_code_from_signed_request_in_cookie = true
171
171
  original_provider_ignores_state = options.provider_ignores_state
172
172
  options.provider_ignores_state = true
@@ -174,13 +174,13 @@ module OmniAuth
174
174
  begin
175
175
  yield
176
176
  ensure
177
- request.params.delete('code')
177
+ request.params.delete("code")
178
178
  options.authorization_code_from_signed_request_in_cookie = false
179
179
  options.provider_ignores_state = original_provider_ignores_state
180
180
  end
181
181
  else
182
182
  raise NoAuthorizationCodeError,
183
- 'must pass either a `code` (query param) or an `fbsr_<app_id>` signed request cookie'
183
+ "must pass either a `code` (query param) or an `fbsr_<app_id>` signed request cookie"
184
184
  end
185
185
  end
186
186
 
@@ -199,26 +199,26 @@ module OmniAuth
199
199
  url = uri_class.build(host: site_uri.host, path: "#{site_uri.path}/#{user_id}/picture")
200
200
 
201
201
  query = if options[:image_size].is_a?(String) || options[:image_size].is_a?(Symbol)
202
- { type: options[:image_size] }
203
- elsif options[:image_size].is_a?(Hash)
204
- options[:image_size]
205
- end
202
+ {type: options[:image_size]}
203
+ elsif options[:image_size].is_a?(Hash)
204
+ options[:image_size]
205
+ end
206
206
  url.query = Rack::Utils.build_query(query) if query
207
207
 
208
208
  url.to_s
209
209
  end
210
210
 
211
211
  def appsecret_proof
212
- @appsecret_proof ||= OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('SHA256'), client.secret, access_token.token)
212
+ @appsecret_proof ||= OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new("SHA256"), client.secret, access_token.token)
213
213
  end
214
214
 
215
215
  def token_scope
216
216
  token_params = access_token.respond_to?(:params) ? access_token.params : {}
217
- token_params['scope'] || (access_token['scope'] if access_token.respond_to?(:[]))
217
+ token_params["scope"] || (access_token["scope"] if access_token.respond_to?(:[]))
218
218
  end
219
219
 
220
220
  def missing_session_state?
221
- present?(request.params['state']) && blank?(session['omniauth.state'])
221
+ present?(request.params["state"]) && blank?(session["omniauth.state"])
222
222
  end
223
223
 
224
224
  def oauth_state_nil_compare_error?(error)
@@ -228,7 +228,7 @@ module OmniAuth
228
228
  def fail_state_mismatch
229
229
  fail!(
230
230
  :csrf_detected,
231
- OmniAuth::Strategies::OAuth2::CallbackError.new(:csrf_detected, 'OAuth state was missing or mismatched')
231
+ OmniAuth::Strategies::OAuth2::CallbackError.new(:csrf_detected, "OAuth state was missing or mismatched")
232
232
  )
233
233
  end
234
234
 
@@ -275,10 +275,10 @@ module OmniAuth
275
275
 
276
276
  # Backward-compatible strategy name for existing `facebook` callback paths.
277
277
  class Facebook < Facebook2
278
- option :name, 'facebook'
278
+ option :name, "facebook"
279
279
  end
280
280
  end
281
281
  end
282
282
 
283
- OmniAuth.config.add_camelization 'facebook2', 'Facebook2'
284
- OmniAuth.config.add_camelization 'facebook', 'Facebook'
283
+ OmniAuth.config.add_camelization "facebook2", "Facebook2"
284
+ OmniAuth.config.add_camelization "facebook", "Facebook"
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'omniauth/facebook2'
3
+ require "omniauth/facebook2"
@@ -1,36 +1,36 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- lib = File.expand_path('lib', __dir__)
3
+ lib = File.expand_path("lib", __dir__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require 'omniauth/facebook2/version'
5
+ require "omniauth/facebook2/version"
6
6
 
7
7
  Gem::Specification.new do |spec|
8
- spec.name = 'omniauth-facebook2'
8
+ spec.name = "omniauth-facebook2"
9
9
  spec.version = OmniAuth::Facebook2::VERSION
10
- spec.authors = ['Claudio Poli']
11
- spec.email = ['masterkain@gmail.com']
10
+ spec.authors = ["Claudio Poli"]
11
+ spec.email = ["masterkain@gmail.com"]
12
12
 
13
- spec.summary = 'OmniAuth strategy for Facebook OAuth2 authentication.'
13
+ spec.summary = "OmniAuth strategy for Facebook OAuth2 authentication."
14
14
  spec.description =
15
- 'OAuth2 strategy for OmniAuth that authenticates users with Facebook ' \
16
- 'and exposes profile metadata from the Graph API.'
17
- spec.homepage = 'https://github.com/icoretech/omniauth-facebook2'
18
- spec.license = 'MIT'
19
- spec.required_ruby_version = '>= 3.2'
15
+ "OAuth2 strategy for OmniAuth that authenticates users with Facebook " \
16
+ "and exposes profile metadata from the Graph API."
17
+ spec.homepage = "https://github.com/icoretech/omniauth-facebook2"
18
+ spec.license = "MIT"
19
+ spec.required_ruby_version = ">= 3.2"
20
20
 
21
- spec.metadata['source_code_uri'] = 'https://github.com/icoretech/omniauth-facebook2'
22
- spec.metadata['bug_tracker_uri'] = 'https://github.com/icoretech/omniauth-facebook2/issues'
23
- spec.metadata['changelog_uri'] = 'https://github.com/icoretech/omniauth-facebook2/releases'
24
- spec.metadata['rubygems_mfa_required'] = 'true'
21
+ spec.metadata["source_code_uri"] = "https://github.com/icoretech/omniauth-facebook2"
22
+ spec.metadata["bug_tracker_uri"] = "https://github.com/icoretech/omniauth-facebook2/issues"
23
+ spec.metadata["changelog_uri"] = "https://github.com/icoretech/omniauth-facebook2/releases"
24
+ spec.metadata["rubygems_mfa_required"] = "true"
25
25
 
26
26
  spec.files = Dir[
27
- 'lib/**/*.rb',
28
- 'README*',
29
- 'LICENSE*',
30
- '*.gemspec'
27
+ "lib/**/*.rb",
28
+ "README*",
29
+ "LICENSE*",
30
+ "*.gemspec"
31
31
  ]
32
- spec.require_paths = ['lib']
32
+ spec.require_paths = ["lib"]
33
33
 
34
- spec.add_dependency 'cgi', '>= 0.3.6'
35
- spec.add_dependency 'omniauth-oauth2', '>= 1.8', '< 2.0'
34
+ spec.add_dependency "cgi", ">= 0.3.6"
35
+ spec.add_dependency "omniauth-oauth2", ">= 1.8", "< 2.0"
36
36
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-facebook2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claudio Poli