Sha256: ab03081cfdc4ba03db3ba967d1fb5826863db7066c9601e5a483c011a91dd74a
Contents?: true
Size: 1.1 KB
Versions: 1
Compression:
Stored size: 1.1 KB
Contents
require "doorkeeper-jwt/version" require "doorkeeper-jwt/config" require 'jwt' module Doorkeeper module JWT def self.generate(opts = {}) ::JWT.encode( token_payload(opts), secret_key, encryption_method ) end private def self.token_payload(opts = {}) Doorkeeper::JWT.configuration.token_payload.call opts end def self.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( File.open(Doorkeeper::JWT.configuration.secret_key_path) ) 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
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
doorkeeper-jwt-0.1.4 | lib/doorkeeper-jwt.rb |