class OmniAuth::Strategies::Traity
Constants
- DEFAULT_SCOPE
Public Instance Methods
appsecret_proof()
click to toggle source
# File lib/omniauth/strategies/traity.rb, line 79 def appsecret_proof @appsecret_proof ||= OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA256.new, client.secret, access_token.token) end
callback_phase()
click to toggle source
Calls superclass method
# File lib/omniauth/strategies/traity.rb, line 42 def callback_phase with_authorization_code! do super end rescue NoAuthorizationCodeError => e fail!(:no_authorization_code, e) end
callback_url()
click to toggle source
Calls superclass method
# File lib/omniauth/strategies/traity.rb, line 38 def callback_url options[:callback_url] || super end
info_options()
click to toggle source
# File lib/omniauth/strategies/traity.rb, line 66 def info_options params = {:appsecret_proof => appsecret_proof} params.merge!({:locale => options[:locale]}) if options[:locale] { :params => params } end
prune!(hash)
click to toggle source
# File lib/omniauth/strategies/traity.rb, line 72 def prune!(hash) hash.delete_if do |_, value| prune!(value) if value.is_a?(Hash) value.nil? || (value.respond_to?(:empty?) && value.empty?) end end
raw_info()
click to toggle source
# File lib/omniauth/strategies/traity.rb, line 62 def raw_info @raw_info ||= access_token.get('1.0/me', info_options).parsed || {} end
Private Instance Methods
base64_decode_url(value)
click to toggle source
# File lib/omniauth/strategies/traity.rb, line 128 def base64_decode_url(value) value += '=' * (4 - value.size.modulo(4)) Base64.decode64(value.tr('-_', '+/')) end
parse_signed_request(value)
click to toggle source
# File lib/omniauth/strategies/traity.rb, line 112 def parse_signed_request(value) signature, encoded_payload = value.split('.') return if signature.nil? decoded_hex_signature = base64_decode_url(signature) decoded_payload = MultiJson.decode(base64_decode_url(encoded_payload)) if valid_signature?(client.secret, decoded_hex_signature, encoded_payload) decoded_payload end end
valid_signature?(secret, signature, payload)
click to toggle source
# File lib/omniauth/strategies/traity.rb, line 124 def valid_signature?(secret, signature, payload) Digest::SHA256.hexdigest("#{payload}-#{secret}") == signature end