mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-22 10:10:12 +01:00
Fix CloudMailin signature digest calculation
Adopt current (deprecated) code from http://docs.cloudmailin.com/receiving_email/securing_your_email_url_target/ Fixes #1402
This commit is contained in:
parent
5f98697210
commit
45232cd2dd
1 changed files with 15 additions and 1 deletions
|
|
@ -53,10 +53,24 @@ class IntegrationsController < ApplicationController
|
||||||
|
|
||||||
def verify_cloudmailin_signature
|
def verify_cloudmailin_signature
|
||||||
provided = request.request_parameters.delete(:signature)
|
provided = request.request_parameters.delete(:signature)
|
||||||
signature = Digest::MD5.hexdigest(request.request_parameters.sort{|a,b| a[0].to_s <=> b[0].to_s}.map{|k,v| v}.join + SITE_CONFIG['cloudmailin'])
|
signature = Digest::MD5.hexdigest(flatten_params(request.request_parameters).sort.map{|k,v| v}.join + SITE_CONFIG['cloudmailin'])
|
||||||
return provided == signature
|
return provided == signature
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def flatten_params(params, title = nil, result = {})
|
||||||
|
params.each do |key, value|
|
||||||
|
if value.kind_of?(Hash)
|
||||||
|
key_name = title ? "#{title}[#{key}]" : key
|
||||||
|
flatten_params(value, key_name, result)
|
||||||
|
else
|
||||||
|
key_name = title ? "#{title}[#{key}]" : key
|
||||||
|
result[key_name] = value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
def get_applescript(partial_name)
|
def get_applescript(partial_name)
|
||||||
context = current_user.contexts.find params[:context_id]
|
context = current_user.contexts.find params[:context_id]
|
||||||
render :partial => partial_name, :locals => { :context => context }
|
render :partial => partial_name, :locals => { :context => context }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue