Skip to content

Instantly share code, notes, and snippets.

@kenn
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kenn/1a1dcce5cf9424f2f37a to your computer and use it in GitHub Desktop.
Save kenn/1a1dcce5cf9424f2f37a to your computer and use it in GitHub Desktop.
#import "NSString+SHA1HMAC.h"
NSString *client_time = [NSString stringWithFormat:@"%f", NSDate.date.timeIntervalSince1970];
NSString *client_digest = [client_time SHA1HMACWithKey:kCliendSecret];
NSDictionary *parameters = @{@"grant_type":@"password",
@"client_id":kCliendId,
@"client_time":client_time,
@"client_digest":client_digest,
@"username":self.emailField.text,
@"password":self.passwordField.text};
module Doorkeeper
module OAuth
class Client
module Methods
def from_obfuscated_params(request)
client_id, client_time, client_digest = request.parameters.values_at(:client_id, :client_time, :client_digest)
if Time.at(client_time.to_f).between?(15.minutes.ago, 15.minutes.from_now) and app = Doorkeeper::Application.by_uid(client_id)
calculated_digest = OpenSSL::HMAC::hexdigest(OpenSSL::Digest::SHA1.new, app.secret, client_time)
if Rack::Utils.secure_compare(client_digest, calculated_digest)
return [client_id, app.secret]
end
end
[client_id, nil]
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment