Skip to content

Instantly share code, notes, and snippets.

@kenn

kenn/Login.m

Last active Aug 29, 2015
Embed
What would you like to do?
#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