-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Migration from old versions
The intent of this document is to make migration of breaking changes as easy as possible. Please note that all breaking changes may not be included here. Please check the NEWS.md for a full list of changes before finalizing the upgrade process.
Follow latest changes (specially backwards incompatible ones, we follow semantic versioning) in the NEWS: https://github.com/doorkeeper-gem/doorkeeper/blob/master/NEWS.md.
-
Doorkeeper::Application
now has a new boolean column namedconfidential
that istrue
by default and hasNOT NULL CONSTRAINT
. This column is required to allow creating Public & Private Clients as mentioned in Section 8.5 of draft-ietf-oauth-native-apps-12 of OAuth 2 RFC which was previously unavailable. If you are migrating from the Doorkeeper <= 5.0, then you can easily add this column by generating a proper migration file using the following command:rails g doorkeeper:confidential_applications
.[IMPORTANT]: all the applications (clients) starting from 5.0 / 4.4.x releases are considered as private by default. You need to manually change
confidential
column tofalse
if you are using public clients, otherwise your mobile or other applications will not be able to authorize. See #1142 for more details.
-
[IMPORTANT]: Doorkeeper JSON responses changed:
scopes
field was replaced withscope
,expires_in_seconds
toexpires_in
to be consistent and match the RFC. -
Doorkeeper#configured?
,Doorkeeper#database_installed?
, andDoorkeeper#installed?
methods were removed, so any Doorkeeper ORM extension doesn't need to support these methods starting from 5.0. - Many memoized and other instance variables (like
@token
indoorkeeper_token
method forDoorkeeper::Helpers::Controller
) were renamed during refactoring, so if you are using them — just don't do it and call the original methods (helpers, etc) in order to get the required value. - Test suite now has a refactored infrastructure:
spec_helper_integration
now renamed to industry-standardspec_helper
. -
custom_access_token_expires_in
option now provides aDoorkeeper::OAuth::Authorization::Context
object (|context|
) instead of raw params (|client, grant_type, scopes|
). The context object has all these variables and you can access them in the block (likecontext.grant_type
orcontext.client
). -
admin_authenticator
block now returns "403 Forbidden" response by default if developer didn't declare another behavior explicitly. - Previously authorization code response route was
/oauth/authorize/<code>
, now it isoauth/authorize/native?code=<code>
(in order to help applications to automatically find the code value).
- Bootstrap CSS was updated from 3.x to 4.0.
-
[IMPORTANT]: 4.4.x release includes backport security fix from 5.x for token revocation when using public clients, so starting from this version all the applications (clients) are considered as private by default. You need to manually change
confidential
column tofalse
if you are using public clients, otherwise your mobile (or other) applications will not be able to authorize. See #1142 for more details.
- FactoryGirl changed to FactoryBot.
- Previously authorization code response route was
/oauth/authorize/<code>
, now it isoauth/authorize/native?code=<code>
(in order to help applications to automatically find the code value).
- MongoDB adapter extracted to its own extension.
-
doorkeeper_unauthorized_render_options(error:)
anddoorkeeper_forbidden_render_options(error:)
now accepterror
keyword argument.
- Added
scopes
column to applications. Add it withrails generate doorkeeper:application_scopes
generator.
-
doorkeeper_for
DSL was changed tobefore_action :dorkeeper_authorize!
. -
test_redirect_uri
option renamed tonative_redirect_uri
. -
mount Doorkeeper::Engine
now replaced withuse_doorkeeper
routes helper.
Doorkeeper is not an isolated engine anymore. Which means that most of the paths and old related engine methods won't work. Here's a list of things that changed:
-
mount Doorkeeper::Engine
won't work. Replace it withuse_doorkeeper
in yourconfig/routes.rb
file. - All route paths have changed. If you generated all views, or use custom ones, you'll have to prepend
oauth_
to each of them:
# also applies to prefixes (edit_ and new_)
authorized_applications(_path|_url) => oauth_authorized_applications(_path|_url)
applications(_path|_url) => oauth_applications(_path|_url)
authorization(_path|_url) => oauth_authorization(_path|_url)
- The locale file has been updated. You'll need to reinstall the file with
rails g doorkeeper:install
(ignore other existing files) to ensure the gem works properly. - Authorization code is now configurable:
authorization_code_expires_in 10.minutes
The column resource_owner_id
accepts null values, since we now support the Client Credentials flow.
change_column :oauth_access_tokens, :resource_owner_id, :integer, :null => true
Two things were changed in scopes
- The configuration for scopes has changed. You now have to use
default_scopes
andoptional_scopes
instead of theauthorization_scopes
block:
Doorkeeper.configure do
default_scopes :public
optional_scopes :write, :update
end
- You have to translate your scopes in your application's locale file(s).
en:
doorkeeper:
scopes:
public: "Access your public data"
write: "Update your data"
Add indexes to database:
class UpgradeToVersion03 < ActiveRecord::Migration
def change
add_index :oauth_applications, :uid, :unique => true
add_index :oauth_access_grants, :token, :unique => true
add_index :oauth_access_tokens, :token, :unique => true
add_index :oauth_access_tokens, :resource_owner_id
add_index :oauth_access_tokens, :refresh_token, :unique => true
end
end
-
doorkeeper_for
does not accept the:all
option anymore. -
doorkeeper_for
only accepts:except
option when:all
was specified.
class UpgradeToVersion02 < ActiveRecord::Migration
def change
add_column :oauth_access_grants, :scopes, :string
# If you are upgrading from version 0.1.0, uncomment the line below.
# add_column :oauth_access_grants, :revoked_at, :datetime
add_column :oauth_access_tokens, :refresh_token, :string
add_column :oauth_access_tokens, :scopes, :string
add_column :oauth_access_tokens, :expires_in, :integer
remove_column :oauth_access_tokens, :expires_at
end
end