Class: GSGraph::Auth::SignedRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/gs_graph/auth/signed_request.rb

Class Method Summary collapse

Class Method Details

.oauth_dialog_endpointObject



8
9
10
# File 'lib/gs_graph/auth/signed_request.rb', line 8

def self.oauth_dialog_endpoint
	return GSGraph.www_url + '/dialog/oauth'
end

.verify(client, signed_request) ⇒ Object

Raises:



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/gs_graph/auth/signed_request.rb', line 12

def self.verify(client, signed_request)
  signature, payload = signed_request.split('.')
  raise VerificationFailed.new('No Signature') if signature.blank?
  raise VerificationFailed.new('No Payload') if payload.blank?
  signature = base64_url_decode signature
  data = decode_json base64_url_decode(payload)
  raise VerificationFailed.new('Unexpected Signature Algorithm') unless data[:algorithm] == 'HMAC-SHA256'
  _signature_ = sign(client.secret, payload)
  raise VerificationFailed.new('Signature Invalid') unless signature == _signature_
  data
end