doorkeeper 5.5.0.rc1 → 5.5.0.rc2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of doorkeeper might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1099136de2b2fe0f0443f88bdbe2260ebed52efb2aab31d1d35bb7aa9f801acd
4
- data.tar.gz: '09837820494b55d6bd26e2d997c203b221bc7951e74a6d1e2197122a86f0f1b2'
3
+ metadata.gz: 71ef97409e242e0609d9c327836e2f90f92af440c8f989047b83435f7f8b052d
4
+ data.tar.gz: f12a030d12ca321fbf1b0acd4534707afba6c584b77d307698943a879cd33500
5
5
  SHA512:
6
- metadata.gz: 9197207fe8db140d8658aa12cd7422bfd84a001227a9f0841ebf5d92da4be531cfd7dea26aad584fff3573bc066b8fadc4e9d4e70bcc6dd5978253d94a9d66a4
7
- data.tar.gz: 3b37c794027fcdbec12ef314bd6a927e111c2aed2044f3ead9f05893400e7221bf9adf98203efe7a225b395d5644326b943c144c13fb0caeccff5dff20a56ca5
6
+ metadata.gz: bdda34cda76caffdeaec38be0c06ba733cc15480970bd78b48267c66764a64643423d61a2adb6c1c65643d3df2061ab3d86ad82baf970676276d7b1655fb846b
7
+ data.tar.gz: 8218ad9ad8248192f93253940623564784f339b78594cf00c000c33f9a6a9bd06f6cc5ee9fbcc207d4af3b499712387d39756c7ef6c709e9a7afe991efdfa5af
@@ -9,6 +9,24 @@ User-visible changes worth mentioning.
9
9
 
10
10
  - [#PR ID] Add your PR description here.
11
11
 
12
+ ## 5.5.0.rc2
13
+
14
+ - [#1473] Enable `Applications` and `AuthorizedApplications` controllers in API mode.
15
+
16
+ **[IMPORTANT]** you can still skip these controllers using `skip_controllers` in
17
+ `use_doorkeeper` inside `routes.rb`. Please do it in case you don't need them.
18
+
19
+ - [#1472] Fix `establish_connection` configuration for custom defined models.
20
+ - [#1471] Add support for Ruby 3.0.
21
+ - [#1469] Check if `redirect_uri` exists.
22
+ - [#1465] Memoize nil doorkeeper_token.
23
+ - [#1459] Use built-in Ruby option to remove padding in PKCE code challenge value.
24
+ - [#1457] Make owner_id a bigint for newly-generated owner migrations
25
+ - [#1452] Empty previous_refresh_token only if present.
26
+ - [#1440] Validate empty host in redirect_uri.
27
+ - [#1438] Add form post response mode.
28
+ - [#1458] Make `config.skip_client_authentication_for_password_grant` a long term configuration option.
29
+
12
30
  ## 5.5.0.rc1
13
31
 
14
32
  - [#1435] Make error response not redirectable when client is unauthorized
@@ -19,12 +37,12 @@ User-visible changes worth mentioning.
19
37
  - [#1415] Ignore PKCE params for non-PKCE grants.
20
38
  - [#1418] Add ability to register custom OAuth Grant Flows.
21
39
  - [#1420] Require client authentication for Resource Owner Password Grant as stated in OAuth RFC.
22
-
23
- **[IMPORTANT]** you need to create a new OAuth client (`Doorkeeper::Application`) if yoo didn't
40
+
41
+ **[IMPORTANT]** you need to create a new OAuth client (`Doorkeeper::Application`) if you didn't
24
42
  have it before and use client credentials in HTTP Basic auth if you previously used this grant
25
- flow without client authentication. For migration purposes you could enable
26
- `skip_client_authentication_for_password_grant` configuration option to `true`, but such behavior
27
- (as well as configuration option) would be completely removed in a future version of Doorkeeper.
43
+ flow without client authentication. To opt out of this you could set the
44
+ `skip_client_authentication_for_password_grant` configuration option to `true`, but note that
45
+ this is in violation of the OAuth spec and represents a security risk.
28
46
  All the users of your provider application now need to include client credentials when they use
29
47
  this grant flow.
30
48
 
@@ -39,7 +57,7 @@ User-visible changes worth mentioning.
39
57
 
40
58
  - [#1371] Add `#as_json` method and attributes serialization restriction for Application model.
41
59
  Fixes information disclosure vulnerability (CVE-2020-10187).
42
-
60
+
43
61
  **[IMPORTANT]** you need to re-implement `#as_json` method for Doorkeeper Application model
44
62
  if you previously used `#to_json` serialization with custom options or attributes or rely on
45
63
  JSON response from /oauth/applications.json or /oauth/authorized_applications.json. This change
@@ -53,17 +71,17 @@ User-visible changes worth mentioning.
53
71
  - [#1402] Handle trying authorization with client credentials.
54
72
 
55
73
  ## 5.4.0.rc1
56
- - [#1366] Sets expiry of token generated using `refresh_token` to that of original token. (Fixes #1364)
74
+ - [#1366] Sets expiry of token generated using `refresh_token` to that of original token. (Fixes #1364)
57
75
  - [#1354] Add `authorize_resource_owner_for_client` option to authorize the calling user to access an application.
58
76
  - [#1355] Allow to enable polymorphic Resource Owner association for Access Token & Grant
59
77
  models (`use_polymorphic_resource_owner` configuration option).
60
-
78
+
61
79
  **[IMPORTANT]** Review your custom patches or extensions for Doorkeeper internals if you
62
80
  have such - since now Doorkeeper passes Resource Owner instance to every objects and not
63
81
  just it's ID. See PR description for details.
64
-
82
+
65
83
  - [#1356] Remove duplicated scopes from Access Tokens and Grants on attribute assignment.
66
- - [#1357] Fix `Doorkeeper::OAuth::PreAuthorization#as_json` method causing
84
+ - [#1357] Fix `Doorkeeper::OAuth::PreAuthorization#as_json` method causing
67
85
  `Stack level too deep` error with AMS (fix #1312).
68
86
  - [#1358] Deprecate `active_record_options` configuration option.
69
87
  - [#1359] Refactor Doorkeeper configuration options DSL to make it easy to reuse it
@@ -75,7 +93,7 @@ User-visible changes worth mentioning.
75
93
  **[IMPORTANT]** now fully according to RFC 7009 nobody can do a revocation request without `client_id`
76
94
  (for public clients) and `client_secret` (for private clients). Please update your apps to include that
77
95
  info in the revocation request payload.
78
-
96
+
79
97
  - [#1373] Make Doorkeeper routes mapper reusable in extensions.
80
98
  - [#1374] Revoke and issue client credentials token in a transaction with a row lock.
81
99
  - [#1384] Add context object with auth/pre_auth and issued_token for authorization hooks.
@@ -120,9 +138,9 @@ User-visible changes worth mentioning.
120
138
 
121
139
  - [#1371] Backport: add `#as_json` method and attributes serialization restriction for Application model.
122
140
  Fixes information disclosure vulnerability (CVE-2020-10187).
123
-
141
+
124
142
  ## 5.2.4
125
-
143
+
126
144
  - [#1360] Backport: Increase `matching_token_for` batch lookup size to 10 000 and make it configurable.
127
145
 
128
146
  ## 5.2.3
@@ -52,10 +52,19 @@ module Doorkeeper
52
52
  def redirect_or_render(auth)
53
53
  if auth.redirectable?
54
54
  if Doorkeeper.configuration.api_only
55
- render(
56
- json: { status: :redirect, redirect_uri: auth.redirect_uri },
57
- status: auth.status,
58
- )
55
+ if pre_auth.form_post_response?
56
+ render(
57
+ json: { status: :post, redirect_uri: pre_auth.redirect_uri, body: auth.body },
58
+ status: auth.status,
59
+ )
60
+ else
61
+ render(
62
+ json: { status: :redirect, redirect_uri: auth.redirect_uri },
63
+ status: auth.status,
64
+ )
65
+ end
66
+ elsif pre_auth.form_post_response?
67
+ render :form_post
59
68
  else
60
69
  redirect_to auth.redirect_uri
61
70
  end
@@ -82,6 +91,7 @@ module Doorkeeper
82
91
  code_challenge
83
92
  code_challenge_method
84
93
  response_type
94
+ response_mode
85
95
  redirect_uri
86
96
  scope
87
97
  state
@@ -2,6 +2,8 @@
2
2
 
3
3
  module Doorkeeper
4
4
  class TokensController < Doorkeeper::ApplicationMetalController
5
+ before_action :validate_presence_of_client, only: [:revoke]
6
+
5
7
  def create
6
8
  headers.merge!(authorize_response.headers)
7
9
  render json: authorize_response.body,
@@ -12,32 +14,6 @@ module Doorkeeper
12
14
 
13
15
  # OAuth 2.0 Token Revocation - http://tools.ietf.org/html/rfc7009
14
16
  def revoke
15
- # @see 2.1. Revocation Request
16
- #
17
- # The client constructs the request by including the following
18
- # parameters using the "application/x-www-form-urlencoded" format in
19
- # the HTTP request entity-body:
20
- # token REQUIRED.
21
- # token_type_hint OPTIONAL.
22
- #
23
- # The client also includes its authentication credentials as described
24
- # in Section 2.3. of [RFC6749].
25
- #
26
- # The authorization server first validates the client credentials (in
27
- # case of a confidential client) and then verifies whether the token
28
- # was issued to the client making the revocation request.
29
- unless server.client
30
- # If this validation [client credentials / token ownership] fails, the request is
31
- # refused and the client is informed of the error by the authorization server as
32
- # described below.
33
- #
34
- # @see 2.2.1. Error Response
35
- #
36
- # The error presentation conforms to the definition in Section 5.2 of [RFC6749].
37
- render json: revocation_error_response, status: :forbidden
38
- return
39
- end
40
-
41
17
  # The authorization server responds with HTTP status code 200 if the client
42
18
  # submitted an invalid token or the token has been revoked successfully.
43
19
  if token.blank?
@@ -68,6 +44,35 @@ module Doorkeeper
68
44
 
69
45
  private
70
46
 
47
+ def validate_presence_of_client
48
+ return if Doorkeeper.config.skip_client_authentication_for_password_grant
49
+
50
+ # @see 2.1. Revocation Request
51
+ #
52
+ # The client constructs the request by including the following
53
+ # parameters using the "application/x-www-form-urlencoded" format in
54
+ # the HTTP request entity-body:
55
+ # token REQUIRED.
56
+ # token_type_hint OPTIONAL.
57
+ #
58
+ # The client also includes its authentication credentials as described
59
+ # in Section 2.3. of [RFC6749].
60
+ #
61
+ # The authorization server first validates the client credentials (in
62
+ # case of a confidential client) and then verifies whether the token
63
+ # was issued to the client making the revocation request.
64
+ return if server.client
65
+
66
+ # If this validation [client credentials / token ownership] fails, the request is
67
+ # refused and the client is informed of the error by the authorization server as
68
+ # described below.
69
+ #
70
+ # @see 2.2.1. Error Response
71
+ #
72
+ # The error presentation conforms to the definition in Section 5.2 of [RFC6749].
73
+ render json: revocation_error_response, status: :forbidden
74
+ end
75
+
71
76
  # OAuth 2.0 Section 2.1 defines two client types, "public" & "confidential".
72
77
  #
73
78
  # RFC7009
@@ -35,18 +35,22 @@
35
35
 
36
36
  <h4><%= t('.callback_urls') %>:</h4>
37
37
 
38
- <table>
39
- <% @application.redirect_uri.split.each do |uri| %>
40
- <tr>
41
- <td>
42
- <code class="bg-light"><%= uri %></code>
43
- </td>
44
- <td>
45
- <%= link_to t('doorkeeper.applications.buttons.authorize'), oauth_authorization_path(client_id: @application.uid, redirect_uri: uri, response_type: 'code', scope: @application.scopes), class: 'btn btn-success', target: '_blank' %>
46
- </td>
47
- </tr>
48
- <% end %>
49
- </table>
38
+ <% if @application.redirect_uri.present? %>
39
+ <table>
40
+ <% @application.redirect_uri.split.each do |uri| %>
41
+ <tr>
42
+ <td>
43
+ <code class="bg-light"><%= uri %></code>
44
+ </td>
45
+ <td>
46
+ <%= link_to t('doorkeeper.applications.buttons.authorize'), oauth_authorization_path(client_id: @application.uid, redirect_uri: uri, response_type: 'code', scope: @application.scopes), class: 'btn btn-success', target: '_blank' %>
47
+ </td>
48
+ </tr>
49
+ <% end %>
50
+ </table>
51
+ <% else %>
52
+ <span class="bg-light font-italic text-uppercase text-muted"><%= t('.not_defined') %></span>
53
+ <% end %>
50
54
  </div>
51
55
 
52
56
  <div class="col-md-4">
@@ -0,0 +1,11 @@
1
+ <header class="page-header">
2
+ <h1><%= t('.title') %></h1>
3
+ </header>
4
+
5
+ <main role="main" onload="document.forms[0].submit()">
6
+ <%= form_tag @pre_auth.redirect_uri, method: :post do %>
7
+ <% @authorize_response.body.each do |key, value| %>
8
+ <%= hidden_field_tag key, value %>
9
+ <% end %>
10
+ <% end %>
11
+ </main>
@@ -72,6 +72,8 @@ en:
72
72
  able_to: 'This application will be able to'
73
73
  show:
74
74
  title: 'Authorization code'
75
+ form_post:
76
+ title: 'Submit this form'
75
77
 
76
78
  authorized_applications:
77
79
  confirmations:
@@ -109,6 +111,7 @@ en:
109
111
 
110
112
  # Access grant errors
111
113
  unsupported_response_type: 'The authorization server does not support this response type.'
114
+ unsupported_response_mode: 'The authorization server does not support this response mode.'
112
115
 
113
116
  # Access token errors
114
117
  invalid_client: 'Client authentication failed due to unknown client, no client authentication included, or unsupported authentication method.'
@@ -115,4 +115,8 @@ module Doorkeeper
115
115
  def self.authenticate(request, methods = Doorkeeper.config.access_token_methods)
116
116
  OAuth::Token.authenticate(request, *methods)
117
117
  end
118
+
119
+ def self.gem_version
120
+ ::Gem::Version.new(::Doorkeeper::VERSION::STRING)
121
+ end
118
122
  end
@@ -29,6 +29,8 @@ module Doorkeeper
29
29
  @config
30
30
  end
31
31
 
32
+ # @return [Doorkeeper::Config] configuration instance
33
+ #
32
34
  def configuration
33
35
  @config || (raise MissingConfiguration)
34
36
  end
@@ -276,10 +278,16 @@ module Doorkeeper
276
278
  # Rationale: https://github.com/doorkeeper-gem/doorkeeper/issues/1189
277
279
  option :token_reuse_limit, default: 100
278
280
 
279
- # [NOTE]: will be removed in a future version of Doorkeeper
281
+ # This is discouraged. Spec says that password grants always require a client.
282
+ #
283
+ # See https://github.com/doorkeeper-gem/doorkeeper/issues/1412#issuecomment-632750422
284
+ # and https://github.com/doorkeeper-gem/doorkeeper/pull/1420
285
+ #
286
+ # Since many applications use this unsafe behavior in the wild, this is kept as a
287
+ # not-recommended option. You should be aware that you are not following the OAuth
288
+ # spec, and understand the security implications of doing so.
280
289
  option :skip_client_authentication_for_password_grant,
281
- default: false,
282
- deprecated: { message: "OAuth RFC requires client authentication so you need at least to create one" }
290
+ default: false
283
291
 
284
292
  option :active_record_options,
285
293
  default: {},
@@ -11,12 +11,14 @@ module Doorkeeper
11
11
  register(
12
12
  :implicit,
13
13
  response_type_matches: "token",
14
+ response_mode_matches: %w[fragment form_post],
14
15
  response_type_strategy: Doorkeeper::Request::Token,
15
16
  )
16
17
 
17
18
  register(
18
19
  :authorization_code,
19
20
  response_type_matches: "code",
21
+ response_mode_matches: %w[query fragment form_post],
20
22
  response_type_strategy: Doorkeeper::Request::Code,
21
23
  grant_type_matches: "authorization_code",
22
24
  grant_type_strategy: Doorkeeper::Request::AuthorizationCode,
@@ -4,7 +4,8 @@ module Doorkeeper
4
4
  module GrantFlow
5
5
  class Flow
6
6
  attr_reader :name, :grant_type_matches, :grant_type_strategy,
7
- :response_type_matches, :response_type_strategy
7
+ :response_type_matches, :response_type_strategy,
8
+ :response_mode_matches
8
9
 
9
10
  def initialize(name, **options)
10
11
  @name = name
@@ -12,6 +13,7 @@ module Doorkeeper
12
13
  @grant_type_strategy = options[:grant_type_strategy]
13
14
  @response_type_matches = options[:response_type_matches]
14
15
  @response_type_strategy = options[:response_type_strategy]
16
+ @response_mode_matches = options[:response_mode_matches]
15
17
  end
16
18
 
17
19
  def handles_grant_type?
@@ -29,6 +31,14 @@ module Doorkeeper
29
31
  def matches_response_type?(value)
30
32
  response_type_matches === value
31
33
  end
34
+
35
+ def default_response_mode
36
+ response_mode_matches[0]
37
+ end
38
+
39
+ def matches_response_mode?(value)
40
+ response_mode_matches.include?(value)
41
+ end
32
42
  end
33
43
  end
34
44
  end
@@ -38,6 +38,8 @@ module Doorkeeper
38
38
 
39
39
  # :doc:
40
40
  def doorkeeper_token
41
+ return @doorkeeper_token if defined?(@doorkeeper_token)
42
+
41
43
  @doorkeeper_token ||= OAuth::Token.authenticate(request, *config_methods)
42
44
  end
43
45
 
@@ -89,8 +89,7 @@ module Doorkeeper
89
89
  # suitable for PKCE validation
90
90
  #
91
91
  def generate_code_challenge(code_verifier)
92
- padded_result = Base64.urlsafe_encode64(Digest::SHA256.digest(code_verifier))
93
- padded_result.split("=")[0] # Remove any trailing '='
92
+ Base64.urlsafe_encode64(Digest::SHA256.digest(code_verifier), padding: false)
94
93
  end
95
94
 
96
95
  def pkce_supported?
@@ -377,7 +377,7 @@ module Doorkeeper
377
377
  return unless self.class.refresh_token_revoked_on_use?
378
378
 
379
379
  old_refresh_token&.revoke
380
- update_attribute(:previous_refresh_token, "")
380
+ update_attribute(:previous_refresh_token, "") if previous_refresh_token.present?
381
381
  end
382
382
 
383
383
  private
@@ -21,6 +21,10 @@ module Doorkeeper
21
21
  { action: :show, code: token.plaintext_token }
22
22
  end
23
23
 
24
+ def access_grant?
25
+ true
26
+ end
27
+
24
28
  private
25
29
 
26
30
  def authorization_code_expires_in
@@ -76,6 +76,10 @@ module Doorkeeper
76
76
  }
77
77
  end
78
78
 
79
+ def access_token?
80
+ true
81
+ end
82
+
79
83
  private
80
84
 
81
85
  def controller
@@ -21,35 +21,31 @@ module Doorkeeper
21
21
  auth.token
22
22
  end
23
23
 
24
+ def body
25
+ if auth.try(:access_token?)
26
+ {
27
+ access_token: auth.token.plaintext_token,
28
+ token_type: auth.token.token_type,
29
+ expires_in: auth.token.expires_in_seconds,
30
+ state: pre_auth.state,
31
+ }
32
+ elsif auth.try(:access_grant?)
33
+ {
34
+ code: auth.token.plaintext_token,
35
+ state: pre_auth.state,
36
+ }
37
+ end
38
+ end
39
+
24
40
  def redirect_uri
25
41
  if URIChecker.oob_uri?(pre_auth.redirect_uri)
26
42
  auth.oob_redirect
27
43
  elsif response_on_fragment
28
- uri_with_fragment
44
+ Authorization::URIBuilder.uri_with_fragment(pre_auth.redirect_uri, body)
29
45
  else
30
- uri_with_query
46
+ Authorization::URIBuilder.uri_with_query(pre_auth.redirect_uri, body)
31
47
  end
32
48
  end
33
-
34
- private
35
-
36
- def uri_with_fragment
37
- Authorization::URIBuilder.uri_with_fragment(
38
- pre_auth.redirect_uri,
39
- access_token: auth.token.plaintext_token,
40
- token_type: auth.token.token_type,
41
- expires_in: auth.token.expires_in_seconds,
42
- state: pre_auth.state,
43
- )
44
- end
45
-
46
- def uri_with_query
47
- Authorization::URIBuilder.uri_with_query(
48
- pre_auth.redirect_uri,
49
- code: auth.token.plaintext_token,
50
- state: pre_auth.state,
51
- )
52
- end
53
49
  end
54
50
  end
55
51
  end
@@ -12,16 +12,19 @@ module Doorkeeper
12
12
  validate :redirect_uri, error: :invalid_redirect_uri
13
13
  validate :params, error: :invalid_request
14
14
  validate :response_type, error: :unsupported_response_type
15
+ validate :response_mode, error: :unsupported_response_mode
15
16
  validate :scopes, error: :invalid_scope
16
17
  validate :code_challenge_method, error: :invalid_code_challenge_method
17
18
 
18
19
  attr_reader :client, :code_challenge, :code_challenge_method, :missing_param,
19
- :redirect_uri, :resource_owner, :response_type, :state
20
+ :redirect_uri, :resource_owner, :response_type, :state,
21
+ :authorization_response_flow, :response_mode
20
22
 
21
23
  def initialize(server, parameters = {}, resource_owner = nil)
22
24
  @server = server
23
25
  @client_id = parameters[:client_id]
24
26
  @response_type = parameters[:response_type]
27
+ @response_mode = parameters[:response_mode]
25
28
  @redirect_uri = parameters[:redirect_uri]
26
29
  @scope = parameters[:scope]
27
30
  @state = parameters[:state]
@@ -57,6 +60,10 @@ module Doorkeeper
57
60
  pre_auth_hash
58
61
  end
59
62
 
63
+ def form_post_response?
64
+ response_mode == "form_post"
65
+ end
66
+
60
67
  private
61
68
 
62
69
  attr_reader :client_id, :server
@@ -110,10 +117,22 @@ module Doorkeeper
110
117
 
111
118
  def validate_response_type
112
119
  server.authorization_response_flows.any? do |flow|
113
- flow.matches_response_type?(response_type)
120
+ if flow.matches_response_type?(response_type)
121
+ @authorization_response_flow = flow
122
+ true
123
+ end
114
124
  end
115
125
  end
116
126
 
127
+ def validate_response_mode
128
+ if response_mode.blank?
129
+ @response_mode = authorization_response_flow.default_response_mode
130
+ return true
131
+ end
132
+
133
+ authorization_response_flow.matches_response_mode?(response_mode)
134
+ end
135
+
117
136
  def validate_scopes
118
137
  Helpers::ScopeChecker.valid?(
119
138
  scope_str: scope,
@@ -131,7 +150,9 @@ module Doorkeeper
131
150
  end
132
151
 
133
152
  def response_on_fragment?
134
- response_type == "token"
153
+ return response_type == "token" if response_mode.nil?
154
+
155
+ response_mode == "fragment"
135
156
  end
136
157
 
137
158
  def grant_type
@@ -20,9 +20,8 @@ module Doorkeeper
20
20
  require "doorkeeper/orm/active_record/access_token"
21
21
  require "doorkeeper/orm/active_record/application"
22
22
 
23
- if Doorkeeper.config.active_record_options[:establish_connection]
23
+ if (options = Doorkeeper.config.active_record_options[:establish_connection])
24
24
  Doorkeeper::Orm::ActiveRecord.models.each do |model|
25
- options = Doorkeeper.config.active_record_options[:establish_connection]
26
25
  model.establish_connection(options)
27
26
  end
28
27
  end
@@ -51,9 +50,9 @@ module Doorkeeper
51
50
 
52
51
  def self.models
53
52
  [
54
- Doorkeeper::AccessGrant,
55
- Doorkeeper::AccessToken,
56
- Doorkeeper::Application,
53
+ Doorkeeper.config.access_grant_model,
54
+ Doorkeeper.config.access_token_model,
55
+ Doorkeeper.config.application_model,
57
56
  ]
58
57
  end
59
58
  end
@@ -137,9 +137,9 @@ module Doorkeeper::Orm::ActiveRecord::Mixins
137
137
  only = Array.wrap(opts[:only]).map(&:to_s)
138
138
 
139
139
  only = if only.blank?
140
- serializable_attributes
140
+ client_serializable_attributes
141
141
  else
142
- only & serializable_attributes
142
+ only & client_serializable_attributes
143
143
  end
144
144
 
145
145
  only -= Array.wrap(opts[:except]).map(&:to_s) if opts.key?(:except)
@@ -150,7 +150,10 @@ module Doorkeeper::Orm::ActiveRecord::Mixins
150
150
  # Override this method if you need additional attributes to be serialized.
151
151
  #
152
152
  # @return [Array<String>] collection of serializable attributes
153
- def serializable_attributes
153
+ #
154
+ # NOTE: `serializable_attributes` method already taken by Rails >= 6
155
+ #
156
+ def client_serializable_attributes
154
157
  attributes = %w[id name created_at]
155
158
  attributes << "uid" unless confidential?
156
159
  attributes
@@ -21,6 +21,7 @@ module Doorkeeper
21
21
  record.errors.add(attribute, :unspecified_scheme) if unspecified_scheme?(uri)
22
22
  record.errors.add(attribute, :relative_uri) if relative_uri?(uri)
23
23
  record.errors.add(attribute, :secured_uri) if invalid_ssl_uri?(uri)
24
+ record.errors.add(attribute, :invalid_uri) if unspecified_host?(uri)
24
25
  end
25
26
  end
26
27
  rescue URI::InvalidURIError
@@ -43,6 +44,10 @@ module Doorkeeper
43
44
  %w[localhost].include?(uri.try(:scheme))
44
45
  end
45
46
 
47
+ def unspecified_host?(uri)
48
+ uri.is_a?(URI::HTTP) && uri.host.nil?
49
+ end
50
+
46
51
  def relative_uri?(uri)
47
52
  uri.scheme.nil? && uri.host.nil?
48
53
  end
@@ -29,8 +29,6 @@ module Doorkeeper
29
29
 
30
30
  def initialize(routes, mapper = Mapper.new, &block)
31
31
  super
32
-
33
- @mapping.skips.push(:applications, :authorized_applications) if Doorkeeper.config.api_only
34
32
  end
35
33
 
36
34
  def generate_routes!(options)
@@ -1,16 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Doorkeeper
4
- def self.gem_version
5
- Gem::Version.new VERSION::STRING
6
- end
7
-
8
4
  module VERSION
9
5
  # Semantic versioning
10
6
  MAJOR = 5
11
7
  MINOR = 5
12
8
  TINY = 0
13
- PRE = "rc1"
9
+ PRE = "rc2"
14
10
 
15
11
  # Full version number
16
12
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
@@ -2,7 +2,7 @@
2
2
 
3
3
  class AddOwnerToApplication < ActiveRecord::Migration<%= migration_version %>
4
4
  def change
5
- add_column :oauth_applications, :owner_id, :integer, null: true
5
+ add_column :oauth_applications, :owner_id, :bigint, null: true
6
6
  add_column :oauth_applications, :owner_type, :string, null: true
7
7
  add_index :oauth_applications, [:owner_id, :owner_type]
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doorkeeper
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.5.0.rc1
4
+ version: 5.5.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felipe Elias Philipp
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2020-08-04 00:00:00.000000000 Z
14
+ date: 2021-01-21 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: railties
@@ -194,6 +194,7 @@ files:
194
194
  - app/views/doorkeeper/applications/new.html.erb
195
195
  - app/views/doorkeeper/applications/show.html.erb
196
196
  - app/views/doorkeeper/authorizations/error.html.erb
197
+ - app/views/doorkeeper/authorizations/form_post.html.erb
197
198
  - app/views/doorkeeper/authorizations/new.html.erb
198
199
  - app/views/doorkeeper/authorizations/show.html.erb
199
200
  - app/views/doorkeeper/authorized_applications/_delete_form.html.erb
@@ -321,7 +322,14 @@ metadata:
321
322
  source_code_uri: https://github.com/doorkeeper-gem/doorkeeper
322
323
  bug_tracker_uri: https://github.com/doorkeeper-gem/doorkeeper/issues
323
324
  documentation_uri: https://doorkeeper.gitbook.io/guides/
324
- post_install_message:
325
+ post_install_message: "Starting from 5.5.0.rc1 Doorkeeper requires client authentication
326
+ for Resource Owner Password Grant\nas stated in the OAuth RFC. You have to create
327
+ a new OAuth client (Doorkeeper::Application) if you didn't\nhave it before and use
328
+ client credentials in HTTP Basic auth if you previously used this grant flow without\nclient
329
+ authentication. \n\nTo opt out of this you could set the \"skip_client_authentication_for_password_grant\"
330
+ configuration option\nto \"true\", but note that this is in violation of the OAuth
331
+ spec and represents a security risk.\n\nRead https://github.com/doorkeeper-gem/doorkeeper/issues/561#issuecomment-612857163
332
+ for more details."
325
333
  rdoc_options: []
326
334
  require_paths:
327
335
  - lib
@@ -336,7 +344,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
336
344
  - !ruby/object:Gem::Version
337
345
  version: 1.3.1
338
346
  requirements: []
339
- rubygems_version: 3.0.2
347
+ rubygems_version: 3.1.2
340
348
  signing_key:
341
349
  specification_version: 4
342
350
  summary: OAuth 2 provider for Rails and Grape