Module: Api::Vendor::V1::Concerns::Authentication
Instance Method Summary
collapse
#decrypt, #encrypt, #generate_signature
Instance Method Details
#authentication! ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'app/controllers/api/vendor/v1/concerns/authentication.rb', line 5
def authentication!
return true if valid_tagthai_user_info_request?
= request.['Authorization']
return render_error('Missing authorization header') if .blank?
hmac, token = .split
return render_error('Missing authentication token') unless hmac.downcase == 'hmac'
return render_error('Invalid authentication token format') unless token.match?(/\A[\w-]+:\d+:[a-f0-9]+\z/)
api_key, timestamp, client_signature = token.split(':')
= integration_test_vendor_name
return render_error('Vendor api key does not exist') unless valid_vendor_key?(api_key, )
return render_error('Vendor booking channel does not exist') if find_vendor_channel.blank?
return render_error('Invalid authentication token') unless valid_token?(api_key, timestamp, client_signature,
)
true
end
|
#find_vendor_channel ⇒ Object
35
36
37
|
# File 'app/controllers/api/vendor/v1/concerns/authentication.rb', line 35
def find_vendor_channel
@vendor_channel ||= Channel.find_by(oauth_application_id: vendor.id)
end
|