lib/doorkeeper-jwt.rb in doorkeeper-jwt-0.1.3 vs lib/doorkeeper-jwt.rb in doorkeeper-jwt-0.1.4

- old
+ new

@@ -17,11 +17,13 @@ def self.token_payload(opts = {}) Doorkeeper::JWT.configuration.token_payload.call opts end def self.secret_key - secret_key_file || Doorkeeper::JWT.configuration.secret_key + return secret_key_file if !secret_key_file.nil? + return rsa_key if rsa_encryption? + Doorkeeper::JWT.configuration.secret_key end def self.secret_key_file return nil if Doorkeeper::JWT.configuration.secret_key_path.nil? OpenSSL::PKey::RSA.new( @@ -30,8 +32,16 @@ end def self.encryption_method return nil unless Doorkeeper::JWT.configuration.encryption_method Doorkeeper::JWT.configuration.encryption_method.to_s.upcase + end + + def self.rsa_encryption? + /RS\d{3}/ =~ encryption_method + end + + def self.rsa_key + OpenSSL::PKey::RSA.new(Doorkeeper::JWT.configuration.secret_key) end end end