Search code examples
ruby-on-railsrubydoorkeeper

Doorkeeper jwt with RS encryption


I am using Doorkeeper for authorization and JWT to generate access token in my application. And enabled below option like

  • secret_key_path location to my private.pem file
  • encryption_method is RS256
  • use_application_secret false

using Doodkeeper::JWT configure block. Issue I am facing is once request hit for token generation in backend it prompts for Enter PEM pass phrase:

and not getting any response back because its waiting Pass phrase to enter once you provided phrase then you will get access token as response.

Note : I generate private.pem file for encryptions and using in JWT to generate access_token using private.pem.


Solution

  • Issue the secret is not passed to OpenSSL so I modified as below by reopened the JWT module and added to monkey patch

    module JWT
    class << self
      def rsa_key_file
        secret_key_file_open {|f| OpenSSL::PKey::RSA.new(f, Doorkeeper::JWT.configuration.secret_key)}
      end
    end
    end