-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add non-breaking backwards compatibility for 4.x and CVE-2018-1000211
Instructs users via a post-install message on what they should do. If they ignore and do not run the migration generator, they'll simply not take advatange of the security fix (Doorkeeper will continue to assume all apps are confidential).
- Loading branch information
Justin Bull
committed
Jul 11, 2018
1 parent
337d4c2
commit 36dc99b
Showing
4 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
lib/generators/doorkeeper/add_client_confidentiality_generator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require 'rails/generators/active_record' | ||
|
||
class Doorkeeper::AddClientConfidentialityGenerator < ::Rails::Generators::Base | ||
include Rails::Generators::Migration | ||
source_root File.expand_path('../templates', __FILE__) | ||
desc 'Adds a migration to fix CVE-2018-1000211.' | ||
|
||
def install | ||
migration_template( | ||
'add_confidential_to_application_migration.rb.erb', | ||
'db/migrate/add_confidential_to_doorkeeper_application.rb', | ||
migration_version: migration_version | ||
) | ||
end | ||
|
||
def self.next_migration_number(dirname) | ||
ActiveRecord::Generators::Base.next_migration_number(dirname) | ||
end | ||
|
||
private | ||
|
||
def migration_version | ||
if ActiveRecord::VERSION::MAJOR >= 5 | ||
"[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]" | ||
end | ||
end | ||
end |
11 changes: 11 additions & 0 deletions
11
lib/generators/doorkeeper/templates/add_confidential_to_application_migration.rb.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class AddConfidentialToDoorkeeperApplication < ActiveRecord::Migration<%= migration_version %> | ||
def change | ||
add_column( | ||
:oauth_applications, | ||
:confidential, | ||
:boolean, | ||
null: false, | ||
default: true # maintaining backwards compatibility: require secrets | ||
) | ||
end | ||
end |