doorkeeper 5.0.0.rc1 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +16 -0
- data/NEWS.md +36 -2
- data/README.md +9 -8
- data/UPGRADE.md +2 -0
- data/app/controllers/doorkeeper/authorizations_controller.rb +1 -1
- data/app/controllers/doorkeeper/authorized_applications_controller.rb +4 -1
- data/app/controllers/doorkeeper/tokens_controller.rb +9 -10
- data/app/views/doorkeeper/applications/index.html.erb +1 -1
- data/config/locales/en.yml +1 -0
- data/doorkeeper.gemspec +18 -18
- data/gemfiles/rails_master.gemfile +4 -1
- data/lib/doorkeeper/config.rb +18 -5
- data/lib/doorkeeper/models/access_grant_mixin.rb +15 -0
- data/lib/doorkeeper/models/access_token_mixin.rb +3 -3
- data/lib/doorkeeper/oauth/authorization/token.rb +24 -19
- data/lib/doorkeeper/oauth/base_request.rb +3 -2
- data/lib/doorkeeper/oauth/client.rb +0 -2
- data/lib/doorkeeper/oauth/client_credentials/creator.rb +2 -1
- data/lib/doorkeeper/oauth/client_credentials/issuer.rb +2 -4
- data/lib/doorkeeper/oauth/client_credentials/validation.rb +0 -4
- data/lib/doorkeeper/oauth/client_credentials_request.rb +0 -4
- data/lib/doorkeeper/oauth/refresh_token_request.rb +2 -2
- data/lib/doorkeeper/orm/active_record/application.rb +11 -0
- data/lib/doorkeeper/rails/routes.rb +4 -4
- data/lib/doorkeeper/request/authorization_code.rb +0 -2
- data/lib/doorkeeper/request/client_credentials.rb +0 -2
- data/lib/doorkeeper/request/code.rb +0 -2
- data/lib/doorkeeper/request/password.rb +0 -2
- data/lib/doorkeeper/request/refresh_token.rb +0 -2
- data/lib/doorkeeper/request/token.rb +0 -2
- data/lib/doorkeeper/request.rb +0 -7
- data/lib/doorkeeper/version.rb +1 -1
- data/lib/doorkeeper.rb +15 -0
- data/lib/generators/doorkeeper/templates/initializer.rb +18 -4
- data/spec/controllers/authorizations_controller_spec.rb +31 -4
- data/spec/controllers/tokens_controller_spec.rb +60 -8
- data/spec/dummy/config/initializers/doorkeeper.rb +5 -1
- data/spec/lib/config_spec.rb +29 -0
- data/spec/lib/oauth/base_request_spec.rb +24 -0
- data/spec/models/doorkeeper/access_grant_spec.rb +43 -0
- data/spec/models/doorkeeper/access_token_spec.rb +16 -6
- data/spec/models/doorkeeper/application_spec.rb +13 -0
- data/spec/requests/applications/applications_request_spec.rb +45 -0
- data/spec/requests/flows/authorization_code_spec.rb +4 -4
- data/spec/support/helpers/request_spec_helper.rb +8 -0
- metadata +10 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: db3333346ca1b82cd7aa332bb1e43f8d979534c0
|
|
4
|
+
data.tar.gz: 12511ea5d14b0bba28fef47893cc925c9e45ebcd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a5265ed62b206c4f9f117c3cbc8e6d905840636297a342ea952e5dfced01f7ce4bd6b59fc7efd6a4f0e6558475c566bf59ba4a793ef3f87942cf8935dde061ba
|
|
7
|
+
data.tar.gz: 18d2b90ae8e5f2e6e80f518fe0a251c49ba3187fda34c9213f14c0152f301dfd149d11db14dcd94a69bb8048352f8a945107c572cfb3fa03aeabc6d6383b706c
|
data/.gitlab-ci.yml
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
dependency_scanning:
|
|
2
|
+
image: docker:stable
|
|
3
|
+
variables:
|
|
4
|
+
DOCKER_DRIVER: overlay2
|
|
5
|
+
allow_failure: true
|
|
6
|
+
services:
|
|
7
|
+
- docker:stable-dind
|
|
8
|
+
script:
|
|
9
|
+
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
|
10
|
+
- docker run
|
|
11
|
+
--env DEP_SCAN_DISABLE_REMOTE_CHECKS="${DEP_SCAN_DISABLE_REMOTE_CHECKS:-false}"
|
|
12
|
+
--volume "$PWD:/code"
|
|
13
|
+
--volume /var/run/docker.sock:/var/run/docker.sock
|
|
14
|
+
"registry.gitlab.com/gitlab-org/security-products/dependency-scanning:$SP_VERSION" /code
|
|
15
|
+
artifacts:
|
|
16
|
+
paths: [gl-dependency-scanning-report.json]
|
data/NEWS.md
CHANGED
|
@@ -6,12 +6,33 @@ upgrade guides.
|
|
|
6
6
|
User-visible changes worth mentioning.
|
|
7
7
|
|
|
8
8
|
## master
|
|
9
|
+
|
|
10
|
+
- [#PR ID] Add PR description.
|
|
11
|
+
|
|
12
|
+
## 5.0.0
|
|
13
|
+
|
|
14
|
+
- [#1127] Change the token_type initials of the Banner Token to uppercase to comply with the RFC6750 specification.
|
|
15
|
+
|
|
16
|
+
## 5.0.0.rc2
|
|
17
|
+
|
|
18
|
+
- [#1106] Restrict access to AdminController with 'Forbidden 403' if admin_authenticator is not
|
|
19
|
+
configured by developers..
|
|
20
|
+
- [#1108] Simple formating of callback URLs when listing oauth applications
|
|
21
|
+
- [#1116] `AccessGrant`s will now be revoked along with `AccessToken`s when
|
|
22
|
+
hitting the `AuthorizedApplicationController#destroy` route.
|
|
23
|
+
- [#1114] Make token info endpoint's attributes consistent with token creation
|
|
24
|
+
- [#1119] Fix token revocation for OAuth apps using "implicit" grant flow
|
|
25
|
+
- [#1122] Fix AuthorizationsController#new error response to be in JSON format
|
|
26
|
+
|
|
27
|
+
## 5.0.0.rc1
|
|
28
|
+
|
|
29
|
+
- [#1103] Allow customizing use_refresh_token
|
|
9
30
|
- [#1089] Removed enable_pkce_without_secret configuration option
|
|
10
31
|
- [#1102] Expiration time based on scopes
|
|
11
32
|
- [#1099] All the configuration variables in `Doorkeeper.configuration` now
|
|
12
|
-
|
|
33
|
+
always return a non-nil value (`true` or `false`)
|
|
13
34
|
- [#1099] ORM / Query optimization: Do not revoke the refresh token if it is not enabled
|
|
14
|
-
|
|
35
|
+
in `doorkeeper.rb`
|
|
15
36
|
- [#996] Expiration Time Base On Grant Type
|
|
16
37
|
- [#997] Allow PKCE authorization_code flow as specified in RFC7636
|
|
17
38
|
- [#907] Fix lookup for matching tokens in certain edge-cases
|
|
@@ -39,6 +60,19 @@ User-visible changes worth mentioning.
|
|
|
39
60
|
- [#1076] Add config to enforce content type to application/x-www-form-urlencoded
|
|
40
61
|
- Fix bug with `force_ssl_in_redirect_uri` when it breaks existing applications with an
|
|
41
62
|
SSL redirect_uri.
|
|
63
|
+
|
|
64
|
+
## 4.4.2
|
|
65
|
+
|
|
66
|
+
- [#1130] Backport fix for native redirect_uri from 5.x.
|
|
67
|
+
|
|
68
|
+
## 4.4.1
|
|
69
|
+
|
|
70
|
+
- [#1127] Backport token type to comply with the RFC6750 specification.
|
|
71
|
+
- [#1125] Backport Quote surround I18n yes/no keys
|
|
72
|
+
|
|
73
|
+
## 4.4.0
|
|
74
|
+
|
|
75
|
+
- [#1120] Backport security fix from 5.x for token revocation when using public clients
|
|
42
76
|
|
|
43
77
|
## 4.3.2
|
|
44
78
|
|
data/README.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
# Doorkeeper
|
|
1
|
+
# Doorkeeper — awesome OAuth 2 provider for your Rails / Grape app.
|
|
2
2
|
|
|
3
3
|
[](https://rubygems.org/gems/doorkeeper)
|
|
4
4
|
[](https://travis-ci.org/doorkeeper-gem/doorkeeper)
|
|
5
|
-
[](https://gemnasium.com/doorkeeper-gem/doorkeeper)
|
|
6
5
|
[](https://codeclimate.com/github/doorkeeper-gem/doorkeeper)
|
|
7
6
|
[](https://coveralls.io/github/doorkeeper-gem/doorkeeper?branch=master)
|
|
8
7
|
[](https://hakiri.io/github/doorkeeper-gem/doorkeeper/master)
|
|
8
|
+
[](https://houndci.com)
|
|
9
9
|
|
|
10
|
-
Doorkeeper is a gem that makes it easy to introduce OAuth 2 provider
|
|
11
|
-
functionality to your Rails or Grape application.
|
|
10
|
+
Doorkeeper is a gem (Rails engine) that makes it easy to introduce OAuth 2 provider
|
|
11
|
+
functionality to your Ruby on Rails or Grape application.
|
|
12
12
|
|
|
13
13
|
Supported features:
|
|
14
14
|
|
|
@@ -28,7 +28,7 @@ Supported features:
|
|
|
28
28
|
Please check the documentation for the version of doorkeeper you are using in:
|
|
29
29
|
https://github.com/doorkeeper-gem/doorkeeper/releases
|
|
30
30
|
|
|
31
|
-
- See the [
|
|
31
|
+
- See the [Wiki](https://github.com/doorkeeper-gem/doorkeeper/wiki)
|
|
32
32
|
- See [upgrade guides](https://github.com/doorkeeper-gem/doorkeeper/wiki/Migration-from-old-versions)
|
|
33
33
|
- For general questions, please post in [Stack Overflow](http://stackoverflow.com/questions/tagged/doorkeeper)
|
|
34
34
|
- See [SECURITY.md](SECURITY.md) for this project's security disclose
|
|
@@ -180,8 +180,7 @@ end
|
|
|
180
180
|
```
|
|
181
181
|
|
|
182
182
|
Keep in mind, that in this mode you will not be able to access `Applications` or
|
|
183
|
-
`Authorized Applications` controllers because they will be skipped.
|
|
184
|
-
redirects will be returned as JSON response with corresponding locations.
|
|
183
|
+
`Authorized Applications` controllers because they will be skipped. CSRF protections (which are otherwise enabled) will be skipped, and all the redirects will be returned as JSON response with corresponding locations.
|
|
185
184
|
|
|
186
185
|
### Routes
|
|
187
186
|
|
|
@@ -276,7 +275,9 @@ protect. For example:
|
|
|
276
275
|
|
|
277
276
|
``` ruby
|
|
278
277
|
class Api::V1::ProductsController < Api::V1::ApiController
|
|
279
|
-
before_action :doorkeeper_authorize! #
|
|
278
|
+
before_action :doorkeeper_authorize! # Requires access token for all actions
|
|
279
|
+
|
|
280
|
+
# before_action -> { doorkeeper_authorize! :read, :write }
|
|
280
281
|
|
|
281
282
|
# your actions
|
|
282
283
|
end
|
data/UPGRADE.md
ADDED
|
@@ -56,16 +56,15 @@ module Doorkeeper
|
|
|
56
56
|
# https://tools.ietf.org/html/rfc6749#section-2.1
|
|
57
57
|
# https://tools.ietf.org/html/rfc7009
|
|
58
58
|
def authorized?
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
end
|
|
59
|
+
return unless token.present?
|
|
60
|
+
# Client is confidential, therefore client authentication & authorization
|
|
61
|
+
# is required
|
|
62
|
+
if token.application_id? && token.application.confidential?
|
|
63
|
+
# We authorize client by checking token's application
|
|
64
|
+
server.client && server.client.application == token.application
|
|
65
|
+
else
|
|
66
|
+
# Client is public, authentication unnecessary
|
|
67
|
+
true
|
|
69
68
|
end
|
|
70
69
|
end
|
|
71
70
|
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
<%= link_to application.name, oauth_application_path(application) %>
|
|
22
22
|
</td>
|
|
23
23
|
<td class="align-middle">
|
|
24
|
-
<%= application.redirect_uri %>
|
|
24
|
+
<%= simple_format(application.redirect_uri) %>
|
|
25
25
|
</td>
|
|
26
26
|
<td class="align-middle">
|
|
27
27
|
<%= application.confidential? ? t('doorkeeper.applications.index.confidentiality.yes') : t('doorkeeper.applications.index.confidentiality.no') %>
|
data/config/locales/en.yml
CHANGED
|
@@ -99,6 +99,7 @@ en:
|
|
|
99
99
|
# Configuration error messages
|
|
100
100
|
credential_flow_not_configured: 'Resource Owner Password Credentials flow failed due to Doorkeeper.configure.resource_owner_from_credentials being unconfigured.'
|
|
101
101
|
resource_owner_authenticator_not_configured: 'Resource Owner find failed due to Doorkeeper.configure.resource_owner_authenticator being unconfigured.'
|
|
102
|
+
admin_authenticator_not_configured: 'Access to admin panel is forbidden due to Doorkeeper.configure.admin_authenticator being unconfigured.'
|
|
102
103
|
|
|
103
104
|
# Access grant errors
|
|
104
105
|
unsupported_response_type: 'The authorization server does not support this response type.'
|
data/doorkeeper.gemspec
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
$LOAD_PATH.push File.expand_path(
|
|
1
|
+
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require 'doorkeeper/version'
|
|
4
4
|
|
|
5
5
|
Gem::Specification.new do |s|
|
|
6
|
-
s.name =
|
|
6
|
+
s.name = 'doorkeeper'
|
|
7
7
|
s.version = Doorkeeper.gem_version
|
|
8
|
-
s.authors = [
|
|
8
|
+
s.authors = ['Felipe Elias Philipp', 'Tute Costa', 'Jon Moss', 'Nikita Bulai']
|
|
9
9
|
s.email = %w(bulaj.nikita@gmail.com)
|
|
10
|
-
s.homepage =
|
|
11
|
-
s.summary =
|
|
12
|
-
s.description =
|
|
10
|
+
s.homepage = 'https://github.com/doorkeeper-gem/doorkeeper'
|
|
11
|
+
s.summary = 'OAuth 2 provider for Rails and Grape'
|
|
12
|
+
s.description = 'Doorkeeper is an OAuth 2 provider for Rails and Grape.'
|
|
13
13
|
s.license = 'MIT'
|
|
14
14
|
|
|
15
15
|
s.files = `git ls-files`.split("\n")
|
|
16
16
|
s.test_files = `git ls-files -- spec/*`.split("\n")
|
|
17
|
-
s.require_paths = [
|
|
17
|
+
s.require_paths = ['lib']
|
|
18
18
|
|
|
19
|
-
s.add_dependency
|
|
20
|
-
s.required_ruby_version =
|
|
19
|
+
s.add_dependency 'railties', '>= 4.2'
|
|
20
|
+
s.required_ruby_version = '>= 2.1'
|
|
21
21
|
|
|
22
|
-
s.add_development_dependency
|
|
23
|
-
s.add_development_dependency
|
|
24
|
-
s.add_development_dependency
|
|
25
|
-
s.add_development_dependency
|
|
26
|
-
s.add_development_dependency
|
|
27
|
-
s.add_development_dependency
|
|
28
|
-
s.add_development_dependency
|
|
29
|
-
s.add_development_dependency
|
|
22
|
+
s.add_development_dependency 'capybara', '~> 2.18'
|
|
23
|
+
s.add_development_dependency 'coveralls'
|
|
24
|
+
s.add_development_dependency 'grape'
|
|
25
|
+
s.add_development_dependency 'database_cleaner', '~> 1.6'
|
|
26
|
+
s.add_development_dependency 'factory_bot', '~> 4.8'
|
|
27
|
+
s.add_development_dependency 'generator_spec', '~> 0.9.3'
|
|
28
|
+
s.add_development_dependency 'rake', '>= 11.3.0'
|
|
29
|
+
s.add_development_dependency 'rspec-rails'
|
|
30
30
|
end
|
|
@@ -9,6 +9,9 @@ gem "appraisal"
|
|
|
9
9
|
gem "activerecord-jdbcsqlite3-adapter", platform: :jruby
|
|
10
10
|
gem "sqlite3", platform: [:ruby, :mswin, :mingw, :x64_mingw]
|
|
11
11
|
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw]
|
|
12
|
-
|
|
12
|
+
|
|
13
|
+
%w[rspec-core rspec-expectations rspec-mocks rspec-rails rspec-support].each do |lib|
|
|
14
|
+
gem lib, git: "https://github.com/rspec/#{lib}.git", branch: 'master'
|
|
15
|
+
end
|
|
13
16
|
|
|
14
17
|
gemspec path: "../"
|
data/lib/doorkeeper/config.rb
CHANGED
|
@@ -103,9 +103,12 @@ module Doorkeeper
|
|
|
103
103
|
@config.instance_variable_set(:@access_token_methods, methods)
|
|
104
104
|
end
|
|
105
105
|
|
|
106
|
-
# Issue access tokens with refresh token (disabled
|
|
107
|
-
def use_refresh_token
|
|
108
|
-
@config.instance_variable_set(
|
|
106
|
+
# Issue access tokens with refresh token (disabled if not set)
|
|
107
|
+
def use_refresh_token(enabled = true, &block)
|
|
108
|
+
@config.instance_variable_set(
|
|
109
|
+
:@refresh_token_enabled,
|
|
110
|
+
block ? block : enabled
|
|
111
|
+
)
|
|
109
112
|
end
|
|
110
113
|
|
|
111
114
|
# Reuse access token for the same resource owner within an application
|
|
@@ -207,7 +210,13 @@ module Doorkeeper
|
|
|
207
210
|
|
|
208
211
|
option :admin_authenticator,
|
|
209
212
|
as: :authenticate_admin,
|
|
210
|
-
default:
|
|
213
|
+
default: (lambda do |_routes|
|
|
214
|
+
::Rails.logger.warn(
|
|
215
|
+
I18n.t('doorkeeper.errors.messages.admin_authenticator_not_configured')
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
head :forbidden
|
|
219
|
+
end)
|
|
211
220
|
|
|
212
221
|
option :resource_owner_from_credentials,
|
|
213
222
|
default: (lambda do |_routes|
|
|
@@ -289,7 +298,11 @@ module Doorkeeper
|
|
|
289
298
|
end
|
|
290
299
|
|
|
291
300
|
def refresh_token_enabled?
|
|
292
|
-
|
|
301
|
+
if defined?(@refresh_token_enabled)
|
|
302
|
+
@refresh_token_enabled
|
|
303
|
+
else
|
|
304
|
+
false
|
|
305
|
+
end
|
|
293
306
|
end
|
|
294
307
|
|
|
295
308
|
def enforce_configured_scopes?
|
|
@@ -31,6 +31,21 @@ module Doorkeeper
|
|
|
31
31
|
find_by(token: token.to_s)
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
+
# Revokes AccessGrant records that have not been revoked and associated
|
|
35
|
+
# with the specific Application and Resource Owner.
|
|
36
|
+
#
|
|
37
|
+
# @param application_id [Integer]
|
|
38
|
+
# ID of the Application
|
|
39
|
+
# @param resource_owner [ActiveRecord::Base]
|
|
40
|
+
# instance of the Resource Owner model
|
|
41
|
+
#
|
|
42
|
+
def revoke_all_for(application_id, resource_owner, clock = Time)
|
|
43
|
+
where(application_id: application_id,
|
|
44
|
+
resource_owner_id: resource_owner.id,
|
|
45
|
+
revoked_at: nil).
|
|
46
|
+
update_all(revoked_at: clock.now.utc)
|
|
47
|
+
end
|
|
48
|
+
|
|
34
49
|
# Implements PKCE code_challenge encoding without base64 padding as described in the spec.
|
|
35
50
|
# https://tools.ietf.org/html/rfc7636#appendix-A
|
|
36
51
|
# Appendix A. Notes on Implementing Base64url Encoding without Padding
|
|
@@ -173,7 +173,7 @@ module Doorkeeper
|
|
|
173
173
|
# The OAuth 2.0 Authorization Framework: Bearer Token Usage
|
|
174
174
|
#
|
|
175
175
|
def token_type
|
|
176
|
-
'
|
|
176
|
+
'Bearer'
|
|
177
177
|
end
|
|
178
178
|
|
|
179
179
|
def use_refresh_token?
|
|
@@ -187,8 +187,8 @@ module Doorkeeper
|
|
|
187
187
|
def as_json(_options = {})
|
|
188
188
|
{
|
|
189
189
|
resource_owner_id: resource_owner_id,
|
|
190
|
-
|
|
191
|
-
|
|
190
|
+
scope: scopes,
|
|
191
|
+
expires_in: expires_in_seconds,
|
|
192
192
|
application: { uid: application.try(:uid) },
|
|
193
193
|
created_at: created_at.to_i
|
|
194
194
|
}
|
|
@@ -5,29 +5,34 @@ module Doorkeeper
|
|
|
5
5
|
attr_accessor :pre_auth, :resource_owner, :token
|
|
6
6
|
|
|
7
7
|
class << self
|
|
8
|
-
def
|
|
9
|
-
if (expiration = custom_expiration(server, pre_auth_or_oauth_client, grant_type, scopes))
|
|
10
|
-
expiration
|
|
11
|
-
else
|
|
12
|
-
server.access_token_expires_in
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
private
|
|
17
|
-
|
|
18
|
-
def custom_expiration(server, pre_auth_or_oauth_client, grant_type, scopes)
|
|
8
|
+
def build_context(pre_auth_or_oauth_client, grant_type, scopes)
|
|
19
9
|
oauth_client = if pre_auth_or_oauth_client.respond_to?(:client)
|
|
20
10
|
pre_auth_or_oauth_client.client
|
|
21
11
|
else
|
|
22
12
|
pre_auth_or_oauth_client
|
|
23
13
|
end
|
|
24
|
-
|
|
14
|
+
|
|
15
|
+
Doorkeeper::OAuth::Authorization::Context.new(
|
|
25
16
|
oauth_client,
|
|
26
17
|
grant_type,
|
|
27
18
|
scopes
|
|
28
19
|
)
|
|
20
|
+
end
|
|
29
21
|
|
|
30
|
-
|
|
22
|
+
def access_token_expires_in(server, context)
|
|
23
|
+
if (expiration = server.custom_access_token_expires_in.call(context))
|
|
24
|
+
expiration
|
|
25
|
+
else
|
|
26
|
+
server.access_token_expires_in
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def refresh_token_enabled?(server, context)
|
|
31
|
+
if server.refresh_token_enabled?.respond_to? :call
|
|
32
|
+
server.refresh_token_enabled?.call(context)
|
|
33
|
+
else
|
|
34
|
+
!!server.refresh_token_enabled?
|
|
35
|
+
end
|
|
31
36
|
end
|
|
32
37
|
end
|
|
33
38
|
|
|
@@ -37,16 +42,16 @@ module Doorkeeper
|
|
|
37
42
|
end
|
|
38
43
|
|
|
39
44
|
def issue_token
|
|
45
|
+
context = self.class.build_context(
|
|
46
|
+
pre_auth.client,
|
|
47
|
+
Doorkeeper::OAuth::IMPLICIT,
|
|
48
|
+
pre_auth.scopes
|
|
49
|
+
)
|
|
40
50
|
@token ||= AccessToken.find_or_create_for(
|
|
41
51
|
pre_auth.client,
|
|
42
52
|
resource_owner.id,
|
|
43
53
|
pre_auth.scopes,
|
|
44
|
-
self.class.access_token_expires_in(
|
|
45
|
-
configuration,
|
|
46
|
-
pre_auth,
|
|
47
|
-
Doorkeeper::OAuth::IMPLICIT,
|
|
48
|
-
pre_auth.scopes
|
|
49
|
-
),
|
|
54
|
+
self.class.access_token_expires_in(configuration, context),
|
|
50
55
|
false
|
|
51
56
|
)
|
|
52
57
|
end
|
|
@@ -31,12 +31,13 @@ module Doorkeeper
|
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
def find_or_create_access_token(client, resource_owner_id, scopes, server)
|
|
34
|
+
context = Authorization::Token.build_context(client, grant_type, scopes)
|
|
34
35
|
@access_token = AccessToken.find_or_create_for(
|
|
35
36
|
client,
|
|
36
37
|
resource_owner_id,
|
|
37
38
|
scopes,
|
|
38
|
-
Authorization::Token.access_token_expires_in(server,
|
|
39
|
-
|
|
39
|
+
Authorization::Token.access_token_expires_in(server, context),
|
|
40
|
+
Authorization::Token.refresh_token_enabled?(server, context)
|
|
40
41
|
)
|
|
41
42
|
end
|
|
42
43
|
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
require 'doorkeeper/oauth/client_credentials/validation'
|
|
2
|
-
|
|
3
1
|
module Doorkeeper
|
|
4
2
|
module OAuth
|
|
5
3
|
class ClientCredentialsRequest < BaseRequest
|
|
@@ -25,12 +23,12 @@ module Doorkeeper
|
|
|
25
23
|
private
|
|
26
24
|
|
|
27
25
|
def create_token(client, scopes, creator)
|
|
28
|
-
|
|
29
|
-
@server,
|
|
26
|
+
context = Authorization::Token.build_context(
|
|
30
27
|
client,
|
|
31
28
|
Doorkeeper::OAuth::CLIENT_CREDENTIALS,
|
|
32
29
|
scopes
|
|
33
30
|
)
|
|
31
|
+
ttl = Authorization::Token.access_token_expires_in(@server, context)
|
|
34
32
|
|
|
35
33
|
creator.call(
|
|
36
34
|
client,
|
|
@@ -65,12 +65,12 @@ module Doorkeeper
|
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
def access_token_expires_in
|
|
68
|
-
Authorization::Token.
|
|
69
|
-
server,
|
|
68
|
+
context = Authorization::Token.build_context(
|
|
70
69
|
client,
|
|
71
70
|
Doorkeeper::OAuth::REFRESH_TOKEN,
|
|
72
71
|
scopes
|
|
73
72
|
)
|
|
73
|
+
Authorization::Token.access_token_expires_in(server, context)
|
|
74
74
|
end
|
|
75
75
|
|
|
76
76
|
def validate_token_presence
|
|
@@ -34,6 +34,17 @@ module Doorkeeper
|
|
|
34
34
|
where(id: resource_access_tokens.select(:application_id).distinct)
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
+
# Revokes AccessToken and AccessGrant records that have not been revoked and
|
|
38
|
+
# associated with the specific Application and Resource Owner.
|
|
39
|
+
#
|
|
40
|
+
# @param resource_owner [ActiveRecord::Base]
|
|
41
|
+
# instance of the Resource Owner model
|
|
42
|
+
#
|
|
43
|
+
def self.revoke_tokens_and_grants_for(id, resource_owner)
|
|
44
|
+
AccessToken.revoke_all_for(id, resource_owner)
|
|
45
|
+
AccessGrant.revoke_all_for(id, resource_owner)
|
|
46
|
+
end
|
|
47
|
+
|
|
37
48
|
private
|
|
38
49
|
|
|
39
50
|
def generate_uid
|
|
@@ -44,11 +44,11 @@ module Doorkeeper
|
|
|
44
44
|
private
|
|
45
45
|
|
|
46
46
|
def map_route(name, method)
|
|
47
|
-
|
|
48
|
-
send(method, @mapping[name])
|
|
47
|
+
return if @mapping.skipped?(name)
|
|
49
48
|
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
send(method, @mapping[name])
|
|
50
|
+
|
|
51
|
+
mapping[name] = @mapping[name]
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
def authorization_routes(mapping)
|
data/lib/doorkeeper/request.rb
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
require 'doorkeeper/request/authorization_code'
|
|
2
|
-
require 'doorkeeper/request/client_credentials'
|
|
3
|
-
require 'doorkeeper/request/code'
|
|
4
|
-
require 'doorkeeper/request/password'
|
|
5
|
-
require 'doorkeeper/request/refresh_token'
|
|
6
|
-
require 'doorkeeper/request/token'
|
|
7
|
-
|
|
8
1
|
module Doorkeeper
|
|
9
2
|
module Request
|
|
10
3
|
class << self
|
data/lib/doorkeeper/version.rb
CHANGED
data/lib/doorkeeper.rb
CHANGED
|
@@ -2,6 +2,14 @@ require 'doorkeeper/version'
|
|
|
2
2
|
require 'doorkeeper/engine'
|
|
3
3
|
require 'doorkeeper/config'
|
|
4
4
|
|
|
5
|
+
require 'doorkeeper/request/strategy'
|
|
6
|
+
require 'doorkeeper/request/authorization_code'
|
|
7
|
+
require 'doorkeeper/request/client_credentials'
|
|
8
|
+
require 'doorkeeper/request/code'
|
|
9
|
+
require 'doorkeeper/request/password'
|
|
10
|
+
require 'doorkeeper/request/refresh_token'
|
|
11
|
+
require 'doorkeeper/request/token'
|
|
12
|
+
|
|
5
13
|
require 'doorkeeper/errors'
|
|
6
14
|
require 'doorkeeper/server'
|
|
7
15
|
require 'doorkeeper/request'
|
|
@@ -27,6 +35,13 @@ require 'doorkeeper/oauth/base_request'
|
|
|
27
35
|
require 'doorkeeper/oauth/authorization_code_request'
|
|
28
36
|
require 'doorkeeper/oauth/refresh_token_request'
|
|
29
37
|
require 'doorkeeper/oauth/password_access_token_request'
|
|
38
|
+
|
|
39
|
+
require 'doorkeeper/oauth/client_credentials/validation'
|
|
40
|
+
require 'doorkeeper/oauth/client_credentials/creator'
|
|
41
|
+
require 'doorkeeper/oauth/client_credentials/issuer'
|
|
42
|
+
require 'doorkeeper/oauth/client_credentials/validation'
|
|
43
|
+
require 'doorkeeper/oauth/client/credentials'
|
|
44
|
+
|
|
30
45
|
require 'doorkeeper/oauth/client_credentials_request'
|
|
31
46
|
require 'doorkeeper/oauth/code_request'
|
|
32
47
|
require 'doorkeeper/oauth/token_request'
|