Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doorkeeper Application not saving

I have Doorkeeper working locally but once deployed to production I am getting a strange issue. I am not able to create new applications, please see below:

$> app = Doorkeeper::Application.new :name => 'test', :redirect_uri => 'http://test.com'
=> #<Doorkeeper::Application id: nil, name: "test", uid: nil, secret: nil, redirect_uri: "http://test.com", scopes: "", created_at: nil, updated_at: nil>

$> app.save
   (0.8ms)  BEGIN
   (0.8ms)  BEGIN
  Doorkeeper::Application Exists (0.7ms)  SELECT  1 AS one FROM `oauth_applications` WHERE `oauth_applications`.`uid` = BINARY '56bf468e5a1d116e3daef75ecc49b6b6ba313a9a79815b5b4683d56851880c49' LIMIT 1
  Doorkeeper::Application Exists (0.7ms)  SELECT  1 AS one FROM `oauth_applications` WHERE `oauth_applications`.`uid` = BINARY '56bf468e5a1d116e3daef75ecc49b6b6ba313a9a79815b5b4683d56851880c49' LIMIT 1
   (0.4ms)  ROLLBACK
   (0.4ms)  ROLLBACK
=> false

The oauth_applications table is 100% empty.

I am running this on the server (locally it works as expected), please let me know if you need any more information.

EDIT:

I have also tried:

$>app.save!    

and get the following error:

ActiveRecord::RecordInvalid: Validation failed: Redirect URI must be an HTTPS/SSL URI.
like image 419
gregwinn Avatar asked Apr 05 '16 21:04

gregwinn


2 Answers

I have a solution for NON https uri's. In the doorkeeper.rb config file you have the option to set force_ssl_in_redirect_uri to false.

# config/initalizers/doorkeeper.rb

force_ssl_in_redirect_uri false

Turns out this is not an issue but by design :)

like image 109
gregwinn Avatar answered Sep 29 '22 08:09

gregwinn


From the following component of the error:

Redirect URI must be an HTTPS/SSL URI

it seems you are using a nonsecure (http, not https) endpoint for the uri. For some platforms (like Heroku), HTTPS support is automatically enabled, so placing https:// in the uri should suffice.

For ElasticBeanstalk, it shouldn't be a terribly cumbersome process. See their docs to get started. You'll need to purchase a SSL cert from your domain name provider and then find the option in the ElasticBeanstalk web configuration to upload and use a certificate (I think the option may be in the load balancer section).

like image 39
max pleaner Avatar answered Sep 29 '22 08:09

max pleaner