doorkeeper 3.0.0 → 4.0.0
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 +4 -4
- data/.hound.yml +4 -0
- data/.travis.yml +9 -7
- data/CONTRIBUTING.md +2 -0
- data/Gemfile +10 -3
- data/NEWS.md +79 -2
- data/README.md +56 -51
- data/RELEASING.md +2 -2
- data/Rakefile +1 -1
- data/app/assets/stylesheets/doorkeeper/admin/application.css +1 -5
- data/app/controllers/doorkeeper/application_metal_controller.rb +1 -2
- data/app/controllers/doorkeeper/applications_controller.rb +2 -2
- data/app/controllers/doorkeeper/authorizations_controller.rb +1 -1
- data/app/controllers/doorkeeper/authorized_applications_controller.rb +1 -1
- data/app/controllers/doorkeeper/tokens_controller.rb +1 -1
- data/app/helpers/doorkeeper/dashboard_helper.rb +13 -11
- data/app/views/doorkeeper/applications/show.html.erb +1 -1
- data/app/views/doorkeeper/authorizations/new.html.erb +1 -1
- data/app/views/layouts/doorkeeper/admin.html.erb +5 -2
- data/config/locales/en.yml +1 -0
- data/doorkeeper.gemspec +7 -7
- data/lib/doorkeeper/config.rb +10 -15
- data/lib/doorkeeper/engine.rb +11 -7
- data/lib/doorkeeper/errors.rb +6 -0
- data/lib/doorkeeper/helpers/controller.rb +7 -1
- data/lib/doorkeeper/models/access_grant_mixin.rb +9 -5
- data/lib/doorkeeper/models/access_token_mixin.rb +28 -22
- data/lib/doorkeeper/models/application_mixin.rb +3 -7
- data/lib/doorkeeper/models/concerns/expirable.rb +2 -2
- data/lib/doorkeeper/models/concerns/ownership.rb +6 -1
- data/lib/doorkeeper/models/concerns/revocable.rb +19 -2
- data/lib/doorkeeper/oauth/authorization/uri_builder.rb +1 -1
- data/lib/doorkeeper/oauth/authorization_code_request.rb +10 -5
- data/lib/doorkeeper/oauth/client/credentials.rb +1 -1
- data/lib/doorkeeper/oauth/client_credentials/creator.rb +3 -4
- data/lib/doorkeeper/oauth/client_credentials/issuer.rb +2 -1
- data/lib/doorkeeper/oauth/client_credentials_request.rb +7 -4
- data/lib/doorkeeper/oauth/code_response.rb +13 -14
- data/lib/doorkeeper/oauth/error.rb +5 -1
- data/lib/doorkeeper/oauth/helpers/scope_checker.rb +1 -1
- data/lib/doorkeeper/oauth/helpers/uri_checker.rb +2 -1
- data/lib/doorkeeper/oauth/password_access_token_request.rb +6 -10
- data/lib/doorkeeper/oauth/refresh_token_request.rb +29 -12
- data/lib/doorkeeper/oauth/scopes.rb +2 -2
- data/lib/doorkeeper/oauth/token.rb +6 -5
- data/lib/doorkeeper/oauth/token_response.rb +1 -1
- data/lib/doorkeeper/orm/active_record/access_grant.rb +2 -2
- data/lib/doorkeeper/orm/active_record/access_token.rb +10 -2
- data/lib/doorkeeper/orm/active_record/application.rb +4 -9
- data/lib/doorkeeper/orm/active_record.rb +0 -15
- data/lib/doorkeeper/rails/helpers.rb +13 -3
- data/lib/doorkeeper/rails/routes/mapper.rb +1 -1
- data/lib/doorkeeper/rails/routes.rb +2 -1
- data/lib/doorkeeper/request/authorization_code.rb +10 -15
- data/lib/doorkeeper/request/client_credentials.rb +9 -15
- data/lib/doorkeeper/request/code.rb +7 -13
- data/lib/doorkeeper/request/password.rb +18 -13
- data/lib/doorkeeper/request/refresh_token.rb +11 -13
- data/lib/doorkeeper/request/strategy.rb +17 -0
- data/lib/doorkeeper/request/token.rb +7 -13
- data/lib/doorkeeper/request.rb +18 -8
- data/lib/doorkeeper/server.rb +2 -2
- data/lib/doorkeeper/version.rb +1 -1
- data/lib/doorkeeper.rb +1 -1
- data/lib/generators/doorkeeper/previous_refresh_token_generator.rb +29 -0
- data/lib/generators/doorkeeper/templates/add_owner_to_application_migration.rb +1 -1
- data/lib/generators/doorkeeper/templates/add_previous_refresh_token_to_access_tokens.rb +11 -0
- data/lib/generators/doorkeeper/templates/initializer.rb +2 -2
- data/lib/generators/doorkeeper/templates/migration.rb +23 -5
- data/spec/controllers/authorizations_controller_spec.rb +0 -14
- data/spec/controllers/protected_resources_controller_spec.rb +138 -15
- data/spec/controllers/tokens_controller_spec.rb +30 -0
- data/spec/dummy/app/controllers/full_protected_resources_controller.rb +4 -4
- data/spec/dummy/app/controllers/home_controller.rb +1 -1
- data/spec/dummy/app/controllers/metal_controller.rb +1 -1
- data/spec/dummy/app/controllers/semi_protected_resources_controller.rb +3 -3
- data/spec/dummy/app/models/user.rb +0 -4
- data/spec/dummy/config/application.rb +2 -36
- data/spec/dummy/config/environment.rb +1 -1
- data/spec/dummy/config/environments/test.rb +4 -15
- data/spec/dummy/config/initializers/active_record_belongs_to_required_by_default.rb +6 -0
- data/spec/dummy/config/initializers/doorkeeper.rb +2 -2
- data/spec/dummy/db/migrate/{20130902165751_create_doorkeeper_tables.rb → 20151223192035_create_doorkeeper_tables.rb} +24 -5
- data/spec/dummy/db/migrate/20160320211015_add_previous_refresh_token_to_access_tokens.rb +11 -0
- data/spec/dummy/db/schema.rb +23 -22
- data/spec/lib/config_spec.rb +2 -2
- data/spec/lib/models/revocable_spec.rb +27 -4
- data/spec/lib/oauth/authorization_code_request_spec.rb +1 -1
- data/spec/lib/oauth/client_credentials/creator_spec.rb +25 -1
- data/spec/lib/oauth/code_response_spec.rb +34 -0
- data/spec/lib/oauth/error_response_spec.rb +7 -7
- data/spec/lib/oauth/error_spec.rb +9 -5
- data/spec/lib/oauth/password_access_token_request_spec.rb +5 -5
- data/spec/lib/oauth/refresh_token_request_spec.rb +34 -3
- data/spec/lib/oauth/scopes_spec.rb +1 -2
- data/spec/lib/oauth/token_spec.rb +12 -5
- data/spec/lib/request/strategy_spec.rb +53 -0
- data/spec/lib/server_spec.rb +1 -1
- data/spec/models/doorkeeper/access_grant_spec.rb +5 -5
- data/spec/models/doorkeeper/access_token_spec.rb +49 -5
- data/spec/models/doorkeeper/application_spec.rb +2 -10
- data/spec/requests/flows/authorization_code_spec.rb +26 -0
- data/spec/requests/flows/password_spec.rb +26 -5
- data/spec/requests/flows/refresh_token_spec.rb +95 -17
- data/spec/spec_helper_integration.rb +10 -0
- data/spec/support/helpers/model_helper.rb +27 -5
- data/spec/support/http_method_shim.rb +24 -0
- data/spec/support/shared/controllers_shared_context.rb +13 -4
- data/spec/support/shared/models_shared_examples.rb +1 -1
- metadata +46 -38
- data/lib/generators/doorkeeper/application_scopes_generator.rb +0 -34
- data/lib/generators/doorkeeper/templates/add_scopes_to_oauth_applications.rb +0 -5
- data/spec/dummy/db/migrate/20141209001746_add_scopes_to_oauth_applications.rb +0 -5
- /data/spec/dummy/db/migrate/{20130902175349_add_owner_to_application.rb → 20151223200000_add_owner_to_application.rb} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68df4a2a59a456f294e58416fb229932a8ea08c3
|
4
|
+
data.tar.gz: 30ff755d1ec25a53119b419ad1d0be3a69bedd7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df0bc1f0075ede4a575d2c007806ae887ef11d746204df8bda6345b73abf504911fd8bde1c22e6cbf55066553a3c7f9f10653d127a79ead3c2b5fa204dc9b0d1
|
7
|
+
data.tar.gz: becadfd542de1ee8c6863f4dcb4a53db12ea737687942f0699519eb5299a7c22ecac9beb8026a9833dd3dd166810cf6bf0213602fa5696def66fefe6cc5dbb38
|
data/.hound.yml
CHANGED
data/.travis.yml
CHANGED
@@ -1,18 +1,20 @@
|
|
1
|
+
cache: bundler
|
1
2
|
language: ruby
|
2
3
|
sudo: false
|
3
|
-
cache: bundler
|
4
4
|
|
5
5
|
rvm:
|
6
|
-
- 2.0
|
7
6
|
- 2.1
|
8
|
-
- 2.2
|
7
|
+
- 2.2.4
|
8
|
+
- 2.3.0
|
9
|
+
|
10
|
+
before_install:
|
11
|
+
- gem install bundler -v '~> 1.10'
|
9
12
|
|
10
13
|
env:
|
11
|
-
- rails=3.2.0
|
12
|
-
- rails=4.1.0
|
13
14
|
- rails=4.2.0
|
15
|
+
- rails=5.0.0
|
14
16
|
|
15
17
|
matrix:
|
16
18
|
exclude:
|
17
|
-
- env: rails=
|
18
|
-
rvm: 2.
|
19
|
+
- env: rails=5.0.0
|
20
|
+
rvm: 2.1
|
data/CONTRIBUTING.md
CHANGED
data/Gemfile
CHANGED
@@ -1,7 +1,14 @@
|
|
1
|
-
ENV[
|
1
|
+
ENV["rails"] ||= "4.2.0"
|
2
2
|
|
3
|
-
source
|
3
|
+
source "https://rubygems.org"
|
4
4
|
|
5
|
-
gem
|
5
|
+
gem "rails", "~> #{ENV["rails"]}"
|
6
|
+
|
7
|
+
if ENV['rails'].start_with?('5')
|
8
|
+
gem 'rspec-rails', '3.5.0.beta3'
|
9
|
+
end
|
10
|
+
|
11
|
+
gem "activerecord-jdbcsqlite3-adapter", platform: :jruby
|
12
|
+
gem "sqlite3", platform: [:ruby, :mswin, :mingw]
|
6
13
|
|
7
14
|
gemspec
|
data/NEWS.md
CHANGED
@@ -2,7 +2,84 @@
|
|
2
2
|
|
3
3
|
User-visible changes worth mentioning.
|
4
4
|
|
5
|
-
|
5
|
+
## master
|
6
|
+
|
7
|
+
## 4.0.0
|
8
|
+
|
9
|
+
- [#834] Fix AssetNotPrecompiled error with Sprockets 4
|
10
|
+
- [#843] Revert "Fix validation error messages"
|
11
|
+
- [#847] Specify Null option to timestamps
|
12
|
+
|
13
|
+
## 4.0.0.rc4
|
14
|
+
|
15
|
+
- [#777] Add support for public client in password grant flow
|
16
|
+
- [#823] Make configuration and specs ORM independent
|
17
|
+
- [#745] Add created_at timestamp to token generation options
|
18
|
+
- [#838] Drop `Application#scopes` generator and warning, introduced for
|
19
|
+
upgrading doorkeeper from v2 to v3.
|
20
|
+
- [#801] Fix Rails 5 warning messages
|
21
|
+
- Test against Rails 5 RC1
|
22
|
+
|
23
|
+
## 4.0.0.rc3
|
24
|
+
|
25
|
+
- [#769] Revoke refresh token on access token use. To make use of the new config
|
26
|
+
add `previous_refresh_token` column to `oauth_access_tokens`:
|
27
|
+
|
28
|
+
```
|
29
|
+
rails generate doorkeeper:previous_refresh_token
|
30
|
+
```
|
31
|
+
- [#811] Toughen parameters filter with exact match
|
32
|
+
- [#813] Applications admin bugfix
|
33
|
+
- [#799] Fix Ruby Warnings
|
34
|
+
- Drop `attr_accessible` from models
|
35
|
+
|
36
|
+
### Backward incompatible changes
|
37
|
+
|
38
|
+
- [#730] Force all timezones to use UTC to prevent comparison issues.
|
39
|
+
- [#802] Remove `config.i18n.fallbacks` from engine
|
40
|
+
|
41
|
+
## 4.0.0.rc2
|
42
|
+
|
43
|
+
- Fix optional belongs_to for Rails 5
|
44
|
+
- Fix Ruby warnings
|
45
|
+
|
46
|
+
## 4.0.0.rc1
|
47
|
+
|
48
|
+
### Backward incompatible changes
|
49
|
+
|
50
|
+
- Drops support for Rails 4.1 and earlier
|
51
|
+
- Drops support for Ruby 2.0
|
52
|
+
- [#778] Bug fix: use the remaining time that a token is still valid when
|
53
|
+
building the redirect URI for the implicit grant flow
|
54
|
+
|
55
|
+
### Other changes
|
56
|
+
|
57
|
+
- [#771] Validation error messages fixes
|
58
|
+
- Adds foreign key constraints in generated migrations between tokens and
|
59
|
+
grants, and applications
|
60
|
+
- Support Rails 5
|
61
|
+
|
62
|
+
## 3.1.0
|
63
|
+
|
64
|
+
- [#736] Existing valid tokens are now reused in client_credentials flow
|
65
|
+
- [#749] Allow user to raise authorization error with custom messages.
|
66
|
+
Under `resource_owner_authenticator` block a user can
|
67
|
+
`raise Doorkeeper::Errors::DoorkeeperError.new('custom_message')`
|
68
|
+
- [#762] Check doesn’t abort the actual migration, so it runs
|
69
|
+
- [#722] `doorkeeper_forbidden_render_options` now supports returning a 404 by
|
70
|
+
specifying `respond_not_found_when_forbidden: true` in the
|
71
|
+
`doorkeeper_forbidden_render_options` method.
|
72
|
+
- [#734] Simplify and remove duplication in request strategy classes
|
73
|
+
|
74
|
+
## 3.0.1
|
75
|
+
|
76
|
+
- [#712] Wrap exchange of grant token for access token and access token refresh
|
77
|
+
in transactions
|
78
|
+
- [#704] Allow applications scopes to be mass assigned
|
79
|
+
- [#707] Fixed order of Mixin inclusion and table_name configuration in models
|
80
|
+
- [#712] Wrap access token and refresh grants in transactions
|
81
|
+
- Adds JRuby support
|
82
|
+
- Specs, views and documentation adjustments
|
6
83
|
|
7
84
|
## 3.0.0
|
8
85
|
|
@@ -45,7 +122,7 @@ User-visible changes worth mentioning.
|
|
45
122
|
- Remove `applications.scopes` upgrade notice.
|
46
123
|
|
47
124
|
|
48
|
-
## 2.2.2
|
125
|
+
## 2.2.2
|
49
126
|
|
50
127
|
- [#541] Fixed `undefined method attr_accessible` problem on Rails 4
|
51
128
|
(happens only when ProtectedAttributes gem is used) in #599
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# Doorkeeper - awesome oauth provider for your Rails app.
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/doorkeeper-gem/doorkeeper.svg?branch=master)](https://travis-ci.org/doorkeeper-gem/doorkeeper)
|
4
|
-
[![Dependency Status](https://gemnasium.com/
|
5
|
-
[![Code Climate](https://codeclimate.com/github/
|
4
|
+
[![Dependency Status](https://gemnasium.com/doorkeeper-gem/doorkeeper.svg?travis)](https://gemnasium.com/doorkeeper-gem/doorkeeper)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/doorkeeper-gem/doorkeeper.svg)](https://codeclimate.com/github/doorkeeper-gem/doorkeeper)
|
6
6
|
[![Gem Version](https://badge.fury.io/rb/doorkeeper.svg)](https://rubygems.org/gems/doorkeeper)
|
7
7
|
|
8
8
|
Doorkeeper is a gem that makes it easy to introduce OAuth 2 provider
|
@@ -14,43 +14,43 @@ functionality to your Rails or Grape application.
|
|
14
14
|
## Documentation valid for `master` branch
|
15
15
|
|
16
16
|
Please check the documentation for the version of doorkeeper you are using in:
|
17
|
-
https://github.com/doorkeeper-gem/doorkeeper/releases
|
17
|
+
https://github.com/doorkeeper-gem/doorkeeper/releases
|
18
|
+
|
19
|
+
- See the [wiki](https://github.com/doorkeeper-gem/doorkeeper/wiki)
|
20
|
+
- For general questions, please post in [Stack Overflow](http://stackoverflow.com/questions/tagged/doorkeeper)
|
18
21
|
|
19
22
|
## Table of Contents
|
20
23
|
|
21
|
-
|
24
|
+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
25
|
+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
26
|
+
|
22
27
|
- [Installation](#installation)
|
23
28
|
- [Configuration](#configuration)
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
+
- [Active Record](#active-record)
|
30
|
+
- [Other ORMs](#other-orms)
|
31
|
+
- [Routes](#routes)
|
32
|
+
- [Authenticating](#authenticating)
|
33
|
+
- [Internationalization (I18n)](#internationalization-i18n)
|
29
34
|
- [Protecting resources with OAuth (a.k.a your API endpoint)](#protecting-resources-with-oauth-aka-your-api-endpoint)
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
35
|
+
- [Protect your API with OAuth when using Grape](#protect-your-api-with-oauth-when-using-grape)
|
36
|
+
- [Route Constraints and other integrations](#route-constraints-and-other-integrations)
|
37
|
+
- [Access Token Scopes](#access-token-scopes)
|
38
|
+
- [Custom Access Token Generator](#custom-access-token-generator)
|
39
|
+
- [Authenticated resource owner](#authenticated-resource-owner)
|
40
|
+
- [Applications list](#applications-list)
|
36
41
|
- [Other customizations](#other-customizations)
|
37
42
|
- [Upgrading](#upgrading)
|
38
43
|
- [Development](#development)
|
39
44
|
- [Contributing](#contributing)
|
40
45
|
- [Other resources](#other-resources)
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
- [License](#license)
|
48
|
-
|
49
|
-
|
50
|
-
## Useful links
|
46
|
+
- [Wiki](#wiki)
|
47
|
+
- [Screencast](#screencast)
|
48
|
+
- [Client applications](#client-applications)
|
49
|
+
- [Contributors](#contributors)
|
50
|
+
- [IETF Standards](#ietf-standards)
|
51
|
+
- [License](#license)
|
51
52
|
|
52
|
-
|
53
|
-
- For general questions, please post it in [stack overflow](http://stackoverflow.com/questions/tagged/doorkeeper)
|
53
|
+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
54
54
|
|
55
55
|
## Installation
|
56
56
|
|
@@ -75,9 +75,19 @@ to generate the migration tables:
|
|
75
75
|
|
76
76
|
rails generate doorkeeper:migration
|
77
77
|
|
78
|
-
|
78
|
+
You may want to add foreign keys to your migration. For example, if you plan on
|
79
|
+
using `User` as the resource owner, add the following line to the migration file
|
80
|
+
for each table that includes a `resource_owner_id` column:
|
81
|
+
|
82
|
+
```ruby
|
83
|
+
add_foreign_key :table_name, :users, column: :resource_owner_id
|
84
|
+
```
|
79
85
|
|
80
|
-
|
86
|
+
Then run migrations:
|
87
|
+
|
88
|
+
```sh
|
89
|
+
rake db:migrate
|
90
|
+
```
|
81
91
|
|
82
92
|
### Other ORMs
|
83
93
|
|
@@ -117,7 +127,7 @@ wiki](https://github.com/doorkeeper-gem/doorkeeper/wiki/Customizing-routes).
|
|
117
127
|
### Authenticating
|
118
128
|
|
119
129
|
You need to configure Doorkeeper in order to provide `resource_owner` model
|
120
|
-
and authentication block `initializers/doorkeeper.rb
|
130
|
+
and authentication block in `config/initializers/doorkeeper.rb`:
|
121
131
|
|
122
132
|
``` ruby
|
123
133
|
Doorkeeper.configure do
|
@@ -236,13 +246,13 @@ class Api::V1::ProductsController < Api::V1::ApiController
|
|
236
246
|
end
|
237
247
|
```
|
238
248
|
|
239
|
-
Please note that there is a logical OR between multiple required scopes. In
|
249
|
+
Please note that there is a logical OR between multiple required scopes. In the
|
240
250
|
above example, `doorkeeper_authorize! :admin, :write` means that the access
|
241
|
-
token is required to have either `:admin` scope or `:write` scope, but not
|
242
|
-
have both of them.
|
251
|
+
token is required to have either `:admin` scope or `:write` scope, but does not
|
252
|
+
need have both of them.
|
243
253
|
|
244
|
-
If want to require the access token to have multiple scopes at the same
|
245
|
-
use multiple `doorkeeper_authorize!`, for example:
|
254
|
+
If you want to require the access token to have multiple scopes at the same
|
255
|
+
time, use multiple `doorkeeper_authorize!`, for example:
|
246
256
|
|
247
257
|
```ruby
|
248
258
|
class Api::V1::ProductsController < Api::V1::ApiController
|
@@ -254,12 +264,12 @@ class Api::V1::ProductsController < Api::V1::ApiController
|
|
254
264
|
end
|
255
265
|
```
|
256
266
|
|
257
|
-
In above example, a client can call `:create` action only if its access token
|
258
|
-
|
267
|
+
In the above example, a client can call `:create` action only if its access token
|
268
|
+
has both `:admin` and `:write` scopes.
|
259
269
|
|
260
270
|
### Custom Access Token Generator
|
261
271
|
|
262
|
-
By default a
|
272
|
+
By default a 128 bit access token will be generated. If you require a custom
|
263
273
|
token, such as [JWT](http://jwt.io), specify an object that responds to
|
264
274
|
`.generate(options = {})` and returns a string to be used as the token.
|
265
275
|
|
@@ -303,7 +313,7 @@ token owner.
|
|
303
313
|
|
304
314
|
### Applications list
|
305
315
|
|
306
|
-
By default, the applications list (`/oauth/applications`) is
|
316
|
+
By default, the applications list (`/oauth/applications`) is publicly available.
|
307
317
|
To protect the endpoint you should uncomment these lines:
|
308
318
|
|
309
319
|
```ruby
|
@@ -317,9 +327,9 @@ end
|
|
317
327
|
|
318
328
|
The logic is the same as the `resource_owner_authenticator` block. **Note:**
|
319
329
|
since the application list is just a scaffold, it's recommended to either
|
320
|
-
customize the controller used by the list or skip the controller
|
321
|
-
more information see the page
|
322
|
-
wiki](https://github.com/doorkeeper-gem/doorkeeper/wiki/Customizing-routes).
|
330
|
+
customize the controller used by the list or skip the controller all together.
|
331
|
+
For more information see the page
|
332
|
+
[in the wiki](https://github.com/doorkeeper-gem/doorkeeper/wiki/Customizing-routes).
|
323
333
|
|
324
334
|
## Other customizations
|
325
335
|
|
@@ -331,7 +341,9 @@ wiki](https://github.com/doorkeeper-gem/doorkeeper/wiki/Customizing-routes).
|
|
331
341
|
If you want to upgrade doorkeeper to a new version, check out the [upgrading
|
332
342
|
notes](https://github.com/doorkeeper-gem/doorkeeper/wiki/Migration-from-old-versions)
|
333
343
|
and take a look at the
|
334
|
-
[changelog](https://github.com/doorkeeper-gem/doorkeeper/blob/master/
|
344
|
+
[changelog](https://github.com/doorkeeper-gem/doorkeeper/blob/master/NEWS.md).
|
345
|
+
|
346
|
+
Doorkeeper follows [semantic versioning](http://semver.org/).
|
335
347
|
|
336
348
|
## Development
|
337
349
|
|
@@ -369,12 +381,6 @@ page](https://github.com/doorkeeper-gem/doorkeeper/wiki/Contributing).
|
|
369
381
|
You can find everything about doorkeeper in our [wiki
|
370
382
|
here](https://github.com/doorkeeper-gem/doorkeeper/wiki).
|
371
383
|
|
372
|
-
### Live demo
|
373
|
-
|
374
|
-
Check out this [live demo](http://doorkeeper-provider.herokuapp.com) hosted on
|
375
|
-
heroku. For more demos check out [the
|
376
|
-
wiki](https://github.com/doorkeeper-gem/doorkeeper/wiki/Example-Applications).
|
377
|
-
|
378
384
|
### Screencast
|
379
385
|
|
380
386
|
Check out this screencast from [railscasts.com](http://railscasts.com/): [#353
|
@@ -392,7 +398,7 @@ here](https://github.com/doorkeeper-gem/doorkeeper/wiki/Testing-your-provider-wi
|
|
392
398
|
### Contributors
|
393
399
|
|
394
400
|
Thanks to all our [awesome
|
395
|
-
contributors](https://github.com/doorkeeper-gem/doorkeeper/contributors)!
|
401
|
+
contributors](https://github.com/doorkeeper-gem/doorkeeper/graphs/contributors)!
|
396
402
|
|
397
403
|
|
398
404
|
### IETF Standards
|
@@ -404,4 +410,3 @@ contributors](https://github.com/doorkeeper-gem/doorkeeper/contributors)!
|
|
404
410
|
### License
|
405
411
|
|
406
412
|
MIT License. Copyright 2011 Applicake.
|
407
|
-
[http://applicake.com](http://applicake.com)
|
data/RELEASING.md
CHANGED
@@ -4,8 +4,8 @@
|
|
4
4
|
2. Update `NEWS.md` to reflect the changes since last release.
|
5
5
|
3. Commit changes. There shouldn’t be code changes, and thus CI doesn’t need to
|
6
6
|
run, you can then add “[ci skip]” to the commit message.
|
7
|
-
4. Tag the release: `git tag vVERSION`
|
8
|
-
5. Push changes: `git push --tags`
|
7
|
+
4. Tag the release: `git tag vVERSION -m "Release vVERSION"`
|
8
|
+
5. Push changes: `git push && git push --tags`
|
9
9
|
6. Build and publish the gem:
|
10
10
|
|
11
11
|
```bash
|
data/Rakefile
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
module Doorkeeper
|
2
2
|
class ApplicationMetalController < ActionController::Metal
|
3
3
|
MODULES = [
|
4
|
-
ActionController::RackDelegation,
|
5
4
|
ActionController::Instrumentation,
|
6
5
|
AbstractController::Rendering,
|
7
6
|
ActionController::Rendering,
|
8
7
|
ActionController::Renderers::All,
|
9
8
|
Helpers::Controller
|
10
|
-
]
|
9
|
+
].freeze
|
11
10
|
|
12
11
|
MODULES.each do |mod|
|
13
12
|
include mod
|
@@ -2,8 +2,8 @@ module Doorkeeper
|
|
2
2
|
class ApplicationsController < Doorkeeper::ApplicationController
|
3
3
|
layout 'doorkeeper/admin'
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
before_action :authenticate_admin!
|
6
|
+
before_action :set_application, only: [:show, :edit, :update, :destroy]
|
7
7
|
|
8
8
|
def index
|
9
9
|
@applications = Application.all
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Doorkeeper
|
2
2
|
class AuthorizedApplicationsController < Doorkeeper::ApplicationController
|
3
|
-
|
3
|
+
before_action :authenticate_resource_owner!
|
4
4
|
|
5
5
|
def index
|
6
6
|
@applications = Application.authorized_for(current_resource_owner)
|
@@ -2,7 +2,7 @@ module Doorkeeper
|
|
2
2
|
class TokensController < Doorkeeper::ApplicationMetalController
|
3
3
|
def create
|
4
4
|
response = authorize_response
|
5
|
-
|
5
|
+
headers.merge! response.headers
|
6
6
|
self.response_body = response.body.to_json
|
7
7
|
self.status = response.status
|
8
8
|
rescue Errors::DoorkeeperError => e
|
@@ -1,15 +1,17 @@
|
|
1
|
-
module Doorkeeper
|
2
|
-
|
3
|
-
|
4
|
-
object.errors[method].
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
module Doorkeeper
|
2
|
+
module DashboardHelper
|
3
|
+
def doorkeeper_errors_for(object, method)
|
4
|
+
if object.errors[method].present?
|
5
|
+
object.errors[method].map do |msg|
|
6
|
+
content_tag(:span, class: 'help-block') do
|
7
|
+
msg.capitalize
|
8
|
+
end
|
9
|
+
end.join.html_safe
|
10
|
+
end
|
9
11
|
end
|
10
|
-
end
|
11
12
|
|
12
|
-
|
13
|
-
|
13
|
+
def doorkeeper_submit_path(application)
|
14
|
+
application.persisted? ? oauth_application_path(application) : oauth_applications_path
|
15
|
+
end
|
14
16
|
end
|
15
17
|
end
|
@@ -22,7 +22,7 @@
|
|
22
22
|
<code><%= uri %></code>
|
23
23
|
</td>
|
24
24
|
<td>
|
25
|
-
<%= link_to t('doorkeeper.applications.buttons.authorize'), oauth_authorization_path(client_id: @application.uid, redirect_uri: uri, response_type: 'code'), class: 'btn btn-success', target: '_blank' %>
|
25
|
+
<%= 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' %>
|
26
26
|
</td>
|
27
27
|
</tr>
|
28
28
|
<% end %>
|
@@ -9,8 +9,8 @@
|
|
9
9
|
<%= csrf_meta_tags %>
|
10
10
|
</head>
|
11
11
|
<body>
|
12
|
-
<div class="navbar navbar-inverse navbar-
|
13
|
-
<div class="container">
|
12
|
+
<div class="navbar navbar-inverse navbar-static-top" role="navigation">
|
13
|
+
<div class="container-fluid">
|
14
14
|
<div class="navbar-header">
|
15
15
|
<%= link_to t('doorkeeper.layouts.admin.nav.oauth2_provider'), oauth_applications_path, class: 'navbar-brand' %>
|
16
16
|
</div>
|
@@ -18,6 +18,9 @@
|
|
18
18
|
<%= content_tag :li, class: "#{'active' if request.path == oauth_applications_path}" do %>
|
19
19
|
<%= link_to t('doorkeeper.layouts.admin.nav.applications'), oauth_applications_path %>
|
20
20
|
<% end %>
|
21
|
+
<%= content_tag :li do %>
|
22
|
+
<%= link_to t('doorkeeper.layouts.admin.nav.home'), root_path %>
|
23
|
+
<% end %>
|
21
24
|
</ul>
|
22
25
|
</div>
|
23
26
|
</div>
|
data/config/locales/en.yml
CHANGED
data/doorkeeper.gemspec
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
$LOAD_PATH.push File.expand_path("../lib", __FILE__)
|
2
2
|
|
3
3
|
require "doorkeeper/version"
|
4
4
|
|
@@ -16,13 +16,13 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.test_files = `git ls-files -- spec/*`.split("\n")
|
17
17
|
s.require_paths = ["lib"]
|
18
18
|
|
19
|
-
s.add_dependency "railties", ">=
|
19
|
+
s.add_dependency "railties", ">= 4.2"
|
20
20
|
|
21
|
-
s.add_development_dependency "
|
22
|
-
s.add_development_dependency "
|
23
|
-
s.add_development_dependency "capybara", "~> 2.3.0"
|
24
|
-
s.add_development_dependency "generator_spec", "~> 0.9.0"
|
21
|
+
s.add_development_dependency "capybara"
|
22
|
+
s.add_development_dependency "database_cleaner", "~> 1.3.0"
|
25
23
|
s.add_development_dependency "factory_girl", "~> 4.5.0"
|
24
|
+
s.add_development_dependency "generator_spec", "~> 0.9.0"
|
25
|
+
s.add_development_dependency "rake", "> 10.5.0"
|
26
|
+
s.add_development_dependency "rspec-rails"
|
26
27
|
s.add_development_dependency "timecop", "~> 0.7.0"
|
27
|
-
s.add_development_dependency "database_cleaner", "~> 1.3.0"
|
28
28
|
end
|
data/lib/doorkeeper/config.rb
CHANGED
@@ -10,15 +10,10 @@ module Doorkeeper
|
|
10
10
|
setup_orm_adapter
|
11
11
|
setup_orm_models
|
12
12
|
setup_application_owner if @config.enable_application_owner?
|
13
|
-
check_requirements
|
14
13
|
end
|
15
14
|
|
16
15
|
def self.configuration
|
17
|
-
@config || (fail MissingConfiguration
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.check_requirements
|
21
|
-
@orm_adapter.check_requirements!(configuration)
|
16
|
+
@config || (fail MissingConfiguration)
|
22
17
|
end
|
23
18
|
|
24
19
|
def self.setup_orm_adapter
|
@@ -133,19 +128,20 @@ doorkeeper.
|
|
133
128
|
attribute_builder = options[:builder_class]
|
134
129
|
|
135
130
|
Builder.instance_eval do
|
131
|
+
remove_method name if method_defined?(name)
|
136
132
|
define_method name do |*args, &block|
|
137
133
|
# TODO: is builder_class option being used?
|
138
|
-
value =
|
139
|
-
block ? block : args.first
|
140
|
-
else
|
134
|
+
value = if attribute_builder
|
141
135
|
attribute_builder.new(&block).build
|
136
|
+
else
|
137
|
+
block ? block : args.first
|
142
138
|
end
|
143
139
|
|
144
140
|
@config.instance_variable_set(:"@#{attribute}", value)
|
145
141
|
end
|
146
142
|
end
|
147
143
|
|
148
|
-
define_method attribute do |*
|
144
|
+
define_method attribute do |*_args|
|
149
145
|
if instance_variable_defined?(:"@#{attribute}")
|
150
146
|
instance_variable_get(:"@#{attribute}")
|
151
147
|
else
|
@@ -180,7 +176,7 @@ doorkeeper.
|
|
180
176
|
|
181
177
|
option :skip_authorization, default: ->(_routes) {}
|
182
178
|
option :access_token_expires_in, default: 7200
|
183
|
-
option :custom_access_token_expires_in, default:
|
179
|
+
option :custom_access_token_expires_in, default: ->(_app) { nil }
|
184
180
|
option :authorization_code_expires_in, default: 600
|
185
181
|
option :orm, default: :active_record
|
186
182
|
option :native_redirect_uri, default: 'urn:ietf:wg:oauth:2.0:oob'
|
@@ -193,14 +189,17 @@ doorkeeper.
|
|
193
189
|
attr_reader :reuse_access_token
|
194
190
|
|
195
191
|
def refresh_token_enabled?
|
192
|
+
@refresh_token_enabled ||= false
|
196
193
|
!!@refresh_token_enabled
|
197
194
|
end
|
198
195
|
|
199
196
|
def enable_application_owner?
|
197
|
+
@enable_application_owner ||= false
|
200
198
|
!!@enable_application_owner
|
201
199
|
end
|
202
200
|
|
203
201
|
def confirm_application_owner?
|
202
|
+
@confirm_application_owner ||= false
|
204
203
|
!!@confirm_application_owner
|
205
204
|
end
|
206
205
|
|
@@ -224,10 +223,6 @@ doorkeeper.
|
|
224
223
|
@access_token_methods ||= [:from_bearer_authorization, :from_access_token_param, :from_bearer_param]
|
225
224
|
end
|
226
225
|
|
227
|
-
def realm
|
228
|
-
@realm ||= 'Doorkeeper'
|
229
|
-
end
|
230
|
-
|
231
226
|
def authorization_response_types
|
232
227
|
@authorization_response_types ||= calculate_authorization_response_types
|
233
228
|
end
|