diff --git a/Gemfile b/Gemfile index 46a524f7c..ad3d78c4b 100644 --- a/Gemfile +++ b/Gemfile @@ -28,7 +28,7 @@ gem "ddtrace", "~> 0.45.0" # ddtrace is Datadog’s tracing client for Ruby. gem "devise", "~> 4.7" # Flexible authentication solution for Rails gem "devise_invitable", "~> 2.0.3" # Allows invitations to be sent for joining gem "dogstatsd-ruby", "~> 4.8" # A client for DogStatsD, an extension of the StatsD metric server for Datadog -gem "doorkeeper", "~> 5.4" # Oauth 2 provider +gem "doorkeeper", "~> 5.5" # Oauth 2 provider gem "elasticsearch", "~> 7.11" # Powers DEVs core search functionality gem "email_validator", "~> 2.2" # Email validator for Rails and ActiveModel gem "emoji_regex", "~> 3.2" # A pair of Ruby regular expressions for matching Unicode Emoji symbols diff --git a/Gemfile.lock b/Gemfile.lock index 5d2adcac1..b8250d9d6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -243,7 +243,7 @@ GEM dogstatsd-ruby (4.8.2) domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) - doorkeeper (5.4.0) + doorkeeper (5.5.0) railties (>= 5) dotenv (2.7.6) dotenv-rails (2.7.6) @@ -872,7 +872,7 @@ DEPENDENCIES devise (~> 4.7) devise_invitable (~> 2.0.3) dogstatsd-ruby (~> 4.8) - doorkeeper (~> 5.4) + doorkeeper (~> 5.5) dotenv-rails (~> 2.7.6) elasticsearch (~> 7.11) email_validator (~> 2.2) diff --git a/config/initializers/doorkeeper.rb b/config/initializers/doorkeeper.rb index aa6c1c005..bac14c835 100644 --- a/config/initializers/doorkeeper.rb +++ b/config/initializers/doorkeeper.rb @@ -58,6 +58,23 @@ Doorkeeper.configure do # end # end + # Enables polymorphic Resource Owner association for Access Tokens and Access Grants. + # By default this option is disabled. + # + # Make sure you properly setup you database and have all the required columns (run + # `bundle exec rails generate doorkeeper:enable_polymorphic_resource_owner` and execute Rails + # migrations). + # + # If this option enabled, Doorkeeper will store not only Resource Owner primary key + # value, but also it's type (class name). See "Polymorphic Associations" section of + # Rails guides: https://guides.rubyonrails.org/association_basics.html#polymorphic-associations + # + # [NOTE] If you apply this option on already existing project don't forget to manually + # update `resource_owner_type` column in the database and fix migration template as it will + # set NOT NULL constraint for Access Grants table. + # + # use_polymorphic_resource_owner + # If you are planning to use Doorkeeper in Rails 5 API-only application, then you might # want to use API mode that will skip all the views management and change the way how # Doorkeeper responds to a requests. @@ -86,12 +103,13 @@ Doorkeeper.configure do # # `context` has the following properties available: # - # `client` - the OAuth client application (see Doorkeeper::OAuth::Client) - # `grant_type` - the grant type of the request (see Doorkeeper::OAuth) - # `scopes` - the requested scopes (see Doorkeeper::OAuth::Scopes) + # * `client` - the OAuth client application (see Doorkeeper::OAuth::Client) + # * `grant_type` - the grant type of the request (see Doorkeeper::OAuth) + # * `scopes` - the requested scopes (see Doorkeeper::OAuth::Scopes) + # * `resource_owner` - authorized resource owner instance (if present) # # custom_access_token_expires_in do |context| - # context.client.application.additional_settings.implicit_oauth_expiration + # context.client.additional_settings.implicit_oauth_expiration # end # Use a custom class for generating the access token. @@ -150,8 +168,7 @@ Doorkeeper.configure do # since plain values can no longer be retrieved. # # Note: If you are already a user of doorkeeper and have existing tokens - # in your installation, they will be invalid without enabling the additional - # setting `fallback_to_plain_secrets` below. + # in your installation, they will be invalid without adding 'fallback: :plain'. # hash_token_secrets # By default, token secrets will be hashed using the @@ -185,7 +202,9 @@ Doorkeeper.configure do # This will ensure that old access tokens and secrets # will remain valid even if the hashing above is enabled. # - # fallback_to_plain_secrets + # This can be done by adding 'fallback: plain', e.g. : + # + # hash_application_secrets using: '::Doorkeeper::SecretStoring::BCrypt', fallback: :plain # Issue access tokens with refresh token (disabled by default), you may also # pass a block which accepts `context` to customize when to give a refresh @@ -257,7 +276,7 @@ Doorkeeper.configure do # force_ssl_in_redirect_uri { |uri| uri.host != 'localhost' } # Specify what redirect URI's you want to block during Application creation. - # Any redirect URI is enabled by default. + # Any redirect URI is whitelisted by default. # # You can use this option in order to forbid URI's with 'javascript' scheme # for example. @@ -360,6 +379,17 @@ Doorkeeper.configure do # client.grant_flows.include?(grant_flow) # end + # If you need arbitrary Resource Owner-Client authorization you can enable this option + # and implement the check your need. Config option must respond to #call and return + # true in case resource owner authorized for the specific application or false in other + # cases. + # + # Be default all Resource Owners are authorized to any Client (application). + # + # authorize_resource_owner_for_client do |client, resource_owner| + # resource_owner.admin? || client.owners_whitelist.include?(resource_owner) + # end + # Hook into the strategies' request & response life-cycle in case your # application needs advanced customization or logging: # @@ -372,17 +402,25 @@ Doorkeeper.configure do # end # Hook into Authorization flow in order to implement Single Sign Out - # or add any other functionality. + # or add any other functionality. Inside the block you have an access + # to `controller` (authorizations controller instance) and `context` + # (Doorkeeper::OAuth::Hooks::Context instance) which provides pre auth + # or auth objects with issued token based on hook type (before or after). # - # before_successful_authorization do |controller| + # before_successful_authorization do |controller, context| # Rails.logger.info(controller.request.params.inspect) + # + # Rails.logger.info(context.pre_auth.inspect) # end # - # after_successful_authorization do |controller| + # after_successful_authorization do |controller, context| # controller.session[:logout_urls] << # Doorkeeper::Application # .find_by(controller.request.params.slice(:redirect_uri)) # .logout_uri + # + # Rails.logger.info(context.auth.inspect) + # Rails.logger.info(context.issued_token) # end # Under some circumstances you might want to have applications auto-approved, diff --git a/config/locales/doorkeeper.en.yml b/config/locales/doorkeeper.en.yml index e7139ef56..998645c83 100644 --- a/config/locales/doorkeeper.en.yml +++ b/config/locales/doorkeeper.en.yml @@ -56,12 +56,14 @@ en: title: 'New Application' show: title: 'Application: %{name}' - application_id: 'Application UID' + application_id: 'UID' secret: 'Secret' + secret_hashed: 'Secret hashed' scopes: 'Scopes' confidential: 'Confidential' callback_urls: 'Callback urls' actions: 'Actions' + not_defined: 'Not defined' authorizations: buttons: @@ -75,7 +77,8 @@ en: able_to: 'This application will be able to' show: title: 'Authorization code' - + form_post: + title: 'Submit this form' authorized_applications: confirmations: revoke: 'Are you sure?' @@ -96,7 +99,6 @@ en: invalid_request: unknown: 'The request is missing a required parameter, includes an unsupported parameter value, or is otherwise malformed.' missing_param: 'Missing required parameter: %{value}.' - not_support_pkce: 'Invalid code_verifier parameter. Server does not support pkce.' request_not_authorized: 'Request need to be authorized. Required parameter for authorizing request is missing or invalid.' invalid_redirect_uri: "The requested redirect uri is malformed or doesn't match client redirect URI." unauthorized_client: 'The client is not authorized to perform this request using this method.' @@ -113,6 +115,7 @@ en: # Access grant errors unsupported_response_type: 'The authorization server does not support this response type.' + unsupported_response_mode: 'The authorization server does not support this response mode.' # Access token errors invalid_client: 'Client authentication failed due to unknown client, no client authentication included, or unsupported authentication method.' @@ -142,7 +145,7 @@ en: admin: title: 'Doorkeeper' nav: - oauth2_provider: 'DEV OAuth2 Provider' + oauth2_provider: 'OAuth2 Provider' applications: 'Applications' home: 'Home' application: diff --git a/vendor/cache/doorkeeper-5.4.0.gem b/vendor/cache/doorkeeper-5.4.0.gem deleted file mode 100644 index eece68281..000000000 Binary files a/vendor/cache/doorkeeper-5.4.0.gem and /dev/null differ diff --git a/vendor/cache/doorkeeper-5.5.0.gem b/vendor/cache/doorkeeper-5.5.0.gem new file mode 100644 index 000000000..f61e8522c Binary files /dev/null and b/vendor/cache/doorkeeper-5.5.0.gem differ