doorkeeper 1.1.0 → 1.2.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/.travis.yml +2 -2
- data/CHANGELOG.md +14 -2
- data/README.md +93 -42
- data/app/controllers/doorkeeper/application_controller.rb +1 -1
- data/app/controllers/doorkeeper/applications_controller.rb +4 -4
- data/app/controllers/doorkeeper/authorizations_controller.rb +3 -3
- data/app/controllers/doorkeeper/authorized_applications_controller.rb +1 -1
- data/app/controllers/doorkeeper/token_info_controller.rb +3 -3
- data/app/controllers/doorkeeper/tokens_controller.rb +29 -2
- data/app/helpers/doorkeeper/form_errors_helper.rb +2 -2
- data/app/validators/redirect_uri_validator.rb +1 -1
- data/app/views/doorkeeper/applications/_form.html.erb +3 -3
- data/app/views/doorkeeper/applications/edit.html.erb +1 -1
- data/app/views/doorkeeper/applications/new.html.erb +1 -1
- data/app/views/doorkeeper/applications/show.html.erb +1 -1
- data/app/views/doorkeeper/authorizations/new.html.erb +5 -5
- data/doorkeeper.gemspec +1 -1
- data/lib/doorkeeper.rb +31 -31
- data/lib/doorkeeper/config.rb +66 -37
- data/lib/doorkeeper/doorkeeper_for.rb +6 -3
- data/lib/doorkeeper/engine.rb +2 -2
- data/lib/doorkeeper/helpers/controller.rb +9 -9
- data/lib/doorkeeper/helpers/filter.rb +1 -1
- data/lib/doorkeeper/models/access_grant.rb +5 -5
- data/lib/doorkeeper/models/access_token.rb +22 -18
- data/lib/doorkeeper/models/active_record/access_token.rb +8 -8
- data/lib/doorkeeper/models/active_record/application.rb +5 -5
- data/lib/doorkeeper/models/application.rb +8 -9
- data/lib/doorkeeper/models/expirable.rb +1 -1
- data/lib/doorkeeper/models/mongo_mapper/access_grant.rb +2 -2
- data/lib/doorkeeper/models/mongo_mapper/access_token.rb +11 -11
- data/lib/doorkeeper/models/mongo_mapper/application.rb +4 -4
- data/lib/doorkeeper/models/mongoid/version.rb +2 -2
- data/lib/doorkeeper/models/mongoid2/access_grant.rb +7 -7
- data/lib/doorkeeper/models/mongoid2/access_token.rb +14 -14
- data/lib/doorkeeper/models/mongoid2/application.rb +7 -7
- data/lib/doorkeeper/models/mongoid3_4/access_grant.rb +7 -7
- data/lib/doorkeeper/models/mongoid3_4/access_token.rb +13 -13
- data/lib/doorkeeper/models/mongoid3_4/application.rb +6 -6
- data/lib/doorkeeper/models/ownership.rb +5 -5
- data/lib/doorkeeper/oauth/authorization/code.rb +5 -5
- data/lib/doorkeeper/oauth/authorization/token.rb +7 -7
- data/lib/doorkeeper/oauth/authorization_code_request.rb +18 -19
- data/lib/doorkeeper/oauth/client.rb +1 -1
- data/lib/doorkeeper/oauth/client_credentials/creator.rb +4 -4
- data/lib/doorkeeper/oauth/client_credentials/issuer.rb +6 -4
- data/lib/doorkeeper/oauth/client_credentials/validation.rb +2 -2
- data/lib/doorkeeper/oauth/client_credentials_request.rb +11 -15
- data/lib/doorkeeper/oauth/code_request.rb +5 -4
- data/lib/doorkeeper/oauth/code_response.rb +8 -7
- data/lib/doorkeeper/oauth/error.rb +1 -1
- data/lib/doorkeeper/oauth/error_response.rb +5 -5
- data/lib/doorkeeper/oauth/helpers/uri_checker.rb +1 -1
- data/lib/doorkeeper/oauth/invalid_token_response.rb +10 -10
- data/lib/doorkeeper/oauth/password_access_token_request.rb +57 -54
- data/lib/doorkeeper/oauth/pre_authorization.rb +7 -7
- data/lib/doorkeeper/oauth/refresh_token_request.rb +27 -24
- data/lib/doorkeeper/oauth/scopes.rb +3 -3
- data/lib/doorkeeper/oauth/token.rb +27 -1
- data/lib/doorkeeper/oauth/token_request.rb +14 -4
- data/lib/doorkeeper/rails/routes.rb +31 -22
- data/lib/doorkeeper/rails/routes/mapping.rb +11 -12
- data/lib/doorkeeper/request.rb +5 -5
- data/lib/doorkeeper/version.rb +1 -1
- data/lib/generators/doorkeeper/application_owner_generator.rb +1 -1
- data/lib/generators/doorkeeper/install_generator.rb +5 -5
- data/lib/generators/doorkeeper/migration_generator.rb +1 -1
- data/lib/generators/doorkeeper/mongo_mapper/indexes_generator.rb +2 -2
- data/lib/generators/doorkeeper/templates/add_owner_to_application_migration.rb +2 -2
- data/lib/generators/doorkeeper/templates/initializer.rb +16 -3
- data/lib/generators/doorkeeper/templates/migration.rb +16 -17
- data/lib/generators/doorkeeper/views_generator.rb +1 -1
- data/spec/controllers/applications_controller_spec.rb +7 -7
- data/spec/controllers/authorizations_controller_spec.rb +48 -48
- data/spec/controllers/protected_resources_controller_spec.rb +108 -107
- data/spec/controllers/token_info_controller_spec.rb +11 -11
- data/spec/controllers/tokens_controller_spec.rb +8 -8
- data/spec/dummy/app/controllers/custom_authorizations_controller.rb +2 -2
- data/spec/dummy/app/controllers/full_protected_resources_controller.rb +3 -3
- data/spec/dummy/app/controllers/home_controller.rb +5 -5
- data/spec/dummy/app/controllers/metal_controller.rb +1 -1
- data/spec/dummy/app/controllers/semi_protected_resources_controller.rb +2 -2
- data/spec/dummy/app/models/user.rb +3 -3
- data/spec/dummy/config/application.rb +8 -9
- data/spec/dummy/config/boot.rb +1 -1
- data/spec/dummy/config/environments/test.rb +1 -1
- data/spec/dummy/config/initializers/doorkeeper.rb +5 -5
- data/spec/dummy/config/initializers/session_store.rb +1 -1
- data/spec/dummy/config/initializers/wrap_parameters.rb +1 -1
- data/spec/dummy/config/routes.rb +27 -27
- data/spec/dummy/db/migrate/20130902165751_create_doorkeeper_tables.rb +16 -17
- data/spec/dummy/db/migrate/20130902175349_add_owner_to_application.rb +3 -3
- data/spec/dummy/db/schema.rb +39 -39
- data/spec/factories/access_grant.rb +3 -3
- data/spec/factories/access_token.rb +1 -1
- data/spec/factories/application.rb +3 -3
- data/spec/generators/application_owner_generator_spec.rb +6 -7
- data/spec/generators/install_generator_spec.rb +9 -9
- data/spec/generators/migration_generator_spec.rb +4 -4
- data/spec/lib/config_spec.rb +136 -44
- data/spec/lib/models/expirable_spec.rb +9 -9
- data/spec/lib/models/revocable_spec.rb +4 -4
- data/spec/lib/oauth/authorization/uri_builder_spec.rb +4 -4
- data/spec/lib/oauth/authorization_code_request_spec.rb +2 -2
- data/spec/lib/oauth/client/credentials_spec.rb +4 -4
- data/spec/lib/oauth/client/methods_spec.rb +10 -10
- data/spec/lib/oauth/client_credentials/issuer_spec.rb +9 -7
- data/spec/lib/oauth/client_credentials/validation_spec.rb +2 -2
- data/spec/lib/oauth/client_credentials_request_spec.rb +6 -6
- data/spec/lib/oauth/client_spec.rb +4 -4
- data/spec/lib/oauth/code_request_spec.rb +10 -9
- data/spec/lib/oauth/error_response_spec.rb +8 -8
- data/spec/lib/oauth/error_spec.rb +1 -1
- data/spec/lib/oauth/helpers/scope_checker_spec.rb +17 -17
- data/spec/lib/oauth/helpers/unique_token_spec.rb +7 -7
- data/spec/lib/oauth/helpers/uri_checker_spec.rb +33 -33
- data/spec/lib/oauth/invalid_token_response_spec.rb +4 -4
- data/spec/lib/oauth/password_access_token_request_spec.rb +13 -13
- data/spec/lib/oauth/pre_authorization_spec.rb +47 -7
- data/spec/lib/oauth/refresh_token_request_spec.rb +11 -21
- data/spec/lib/oauth/scopes_spec.rb +32 -32
- data/spec/lib/oauth/token_request_spec.rb +10 -9
- data/spec/lib/oauth/token_response_spec.rb +13 -15
- data/spec/lib/oauth/token_spec.rb +24 -10
- data/spec/lib/server_spec.rb +24 -2
- data/spec/models/doorkeeper/access_grant_spec.rb +8 -8
- data/spec/models/doorkeeper/access_token_spec.rb +79 -33
- data/spec/models/doorkeeper/application_spec.rb +29 -29
- data/spec/requests/applications/applications_request_spec.rb +15 -15
- data/spec/requests/applications/authorized_applications_spec.rb +7 -7
- data/spec/requests/endpoints/authorization_spec.rb +19 -12
- data/spec/requests/endpoints/token_spec.rb +26 -8
- data/spec/requests/flows/authorization_code_errors_spec.rb +17 -17
- data/spec/requests/flows/authorization_code_spec.rb +28 -28
- data/spec/requests/flows/client_credentials_spec.rb +3 -3
- data/spec/requests/flows/implicit_grant_errors_spec.rb +5 -5
- data/spec/requests/flows/implicit_grant_spec.rb +2 -2
- data/spec/requests/flows/password_spec.rb +32 -32
- data/spec/requests/flows/refresh_token_spec.rb +23 -23
- data/spec/requests/flows/revoke_token_spec.rb +165 -0
- data/spec/requests/flows/skip_authorization_spec.rb +10 -10
- data/spec/requests/protected_resources/metal_spec.rb +1 -1
- data/spec/requests/protected_resources/private_api_spec.rb +5 -5
- data/spec/routing/custom_controller_routes_spec.rb +4 -0
- data/spec/routing/default_routes_spec.rb +5 -1
- data/spec/spec_helper.rb +2 -2
- data/spec/spec_helper_integration.rb +8 -10
- data/spec/support/helpers/access_token_request_helper.rb +3 -3
- data/spec/support/helpers/authorization_request_helper.rb +3 -3
- data/spec/support/helpers/config_helper.rb +1 -1
- data/spec/support/helpers/model_helper.rb +2 -2
- data/spec/support/helpers/request_spec_helper.rb +3 -3
- data/spec/support/helpers/url_helper.rb +25 -21
- data/spec/support/orm/active_record.rb +4 -4
- data/spec/support/orm/mongo_mapper.rb +2 -3
- data/spec/support/orm/mongoid.rb +5 -6
- data/spec/support/shared/controllers_shared_context.rb +15 -15
- data/spec/support/shared/models_shared_examples.rb +13 -13
- data/spec/validators/redirect_uri_validator_spec.rb +9 -9
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 923df84b3da199e68a3cce57633ad6b0e1257aab
|
4
|
+
data.tar.gz: 16f3055a34246abe9db2b2110e1c9ca0c00a5f60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e69a18ef913b226db002e6bf5b7f850dd49a6fe8db9c78b74862e6b726b2ccdc79e03e03b303e38306244589540716540464b9d1b5240f4f9a9b14484202473
|
7
|
+
data.tar.gz: 4dbd9358b6d3ecf463947ff299000e5ed43b71f8bb7d624c370f34b32a627abea2ac17c412df679b3a3218dd570ee05981a8cdb1dce6488feb9a9f40e0758a5c
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,18 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## 1.
|
3
|
+
## 1.2.0
|
4
|
+
|
5
|
+
- enhancements
|
6
|
+
- [#376] Allow users to enable basic header authorization for access tokens.
|
7
|
+
- [#374] Token revocation implementation [RFC 7009]
|
8
|
+
- [#295] Only enable specific grant flows.
|
9
|
+
- internals
|
10
|
+
- [#381] Locale source fix.
|
11
|
+
- [#380] Renames `errors_for` to `doorkeeper_errors_for`.
|
12
|
+
- [#390] Style adjustments in accordance with Ruby Style Guide form
|
13
|
+
Thoughtbot.
|
14
|
+
|
15
|
+
## 1.1.0
|
4
16
|
|
5
17
|
- enhancements
|
6
18
|
- [#336] mongoid4 support.
|
@@ -47,7 +59,7 @@
|
|
47
59
|
- [#204] Allow to overwrite scope in routes
|
48
60
|
- internals
|
49
61
|
- Returns only present keys in Token Response (may imply a backwards
|
50
|
-
incompatible change). https://github.com/
|
62
|
+
incompatible change). https://github.com/doorkeeper-gem/doorkeeper/issues/220
|
51
63
|
- bug
|
52
64
|
- [#290] Support for Rails 4 when 'protected_attributes' gem is present.
|
53
65
|
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Doorkeeper - awesome oauth provider for your Rails app.
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.org/
|
3
|
+
[![Build Status](https://travis-ci.org/doorkeeper-gem/doorkeeper.png?branch=master)](https://travis-ci.org/doorkeeper-gem/doorkeeper)
|
4
4
|
[![Dependency Status](https://gemnasium.com/applicake/doorkeeper.png?travis)](https://gemnasium.com/applicake/doorkeeper)
|
5
5
|
[![Code Climate](https://codeclimate.com/github/applicake/doorkeeper.png)](https://codeclimate.com/github/applicake/doorkeeper)
|
6
6
|
[![Gem Version](https://badge.fury.io/rb/doorkeeper.png)](https://rubygems.org/gems/doorkeeper)
|
@@ -38,14 +38,14 @@ Doorkeeper is a gem that makes it easy to introduce OAuth 2 provider functionali
|
|
38
38
|
|
39
39
|
## Useful links
|
40
40
|
|
41
|
-
- For documentation, please check out our [wiki](https://github.com/
|
41
|
+
- For documentation, please check out our [wiki](https://github.com/doorkeeper-gem/doorkeeper/wiki)
|
42
42
|
- For general questions, please post it in [stack overflow](http://stackoverflow.com/questions/tagged/doorkeeper)
|
43
43
|
|
44
44
|
## Requirements
|
45
45
|
|
46
46
|
- Ruby >1.9.3
|
47
47
|
- Rails >3.1
|
48
|
-
- ORM ActiveRecord, Mongoid
|
48
|
+
- ORM ActiveRecord, Mongoid, MongoMapper
|
49
49
|
|
50
50
|
## Installation
|
51
51
|
|
@@ -65,7 +65,8 @@ This will install the doorkeeper initializer into `config/initializers/doorkeepe
|
|
65
65
|
|
66
66
|
### Active Record
|
67
67
|
|
68
|
-
By default doorkeeper is configured to use active record, so to start you have
|
68
|
+
By default doorkeeper is configured to use active record, so to start you have
|
69
|
+
to generate the migration tables:
|
69
70
|
|
70
71
|
rails generate doorkeeper:migration
|
71
72
|
|
@@ -75,7 +76,8 @@ Don't forget to run the migration with:
|
|
75
76
|
|
76
77
|
### Mongoid / MongoMapper
|
77
78
|
|
78
|
-
Doorkeeper currently supports MongoMapper, Mongoid 2 and 3. To start using it,
|
79
|
+
Doorkeeper currently supports MongoMapper, Mongoid 2 and 3. To start using it,
|
80
|
+
you have to set the `orm` configuration:
|
79
81
|
|
80
82
|
``` ruby
|
81
83
|
Doorkeeper.configure do
|
@@ -85,7 +87,9 @@ end
|
|
85
87
|
|
86
88
|
#### Mongoid indexes
|
87
89
|
|
88
|
-
Make sure you create indexes for doorkeeper models. You can do this either by
|
90
|
+
Make sure you create indexes for doorkeeper models. You can do this either by
|
91
|
+
running `rake db:mongoid:create_indexes` or (if you're using Mongoid 2) by
|
92
|
+
adding `autocreate_indexes: true` to your `config/mongoid.yml`
|
89
93
|
|
90
94
|
#### MongoMapper indexes
|
91
95
|
|
@@ -96,7 +100,8 @@ Generate the `db/indexes.rb` file and create indexes for the doorkeeper models:
|
|
96
100
|
|
97
101
|
### Routes
|
98
102
|
|
99
|
-
The installation script will also automatically add the Doorkeeper routes into
|
103
|
+
The installation script will also automatically add the Doorkeeper routes into
|
104
|
+
your app, like this:
|
100
105
|
|
101
106
|
``` ruby
|
102
107
|
Rails.application.routes.draw do
|
@@ -111,16 +116,19 @@ This will mount following routes:
|
|
111
116
|
POST /oauth/authorize
|
112
117
|
DELETE /oauth/authorize
|
113
118
|
POST /oauth/token
|
119
|
+
POST /oauth/revoke
|
114
120
|
resources /oauth/applications
|
115
121
|
GET /oauth/authorized_applications
|
116
122
|
DELETE /oauth/authorized_applications/:id
|
117
123
|
GET /oauth/token/info
|
118
124
|
|
119
|
-
For more information on how to customize routes, check out [this page on the
|
125
|
+
For more information on how to customize routes, check out [this page on the
|
126
|
+
wiki](https://github.com/doorkeeper-gem/doorkeeper/wiki/Customizing-routes).
|
120
127
|
|
121
128
|
### Authenticating
|
122
129
|
|
123
|
-
You need to configure Doorkeeper in order to provide resource_owner model
|
130
|
+
You need to configure Doorkeeper in order to provide `resource_owner` model
|
131
|
+
and authentication block `initializers/doorkeeper.rb`
|
124
132
|
|
125
133
|
``` ruby
|
126
134
|
Doorkeeper.configure do
|
@@ -130,11 +138,13 @@ Doorkeeper.configure do
|
|
130
138
|
end
|
131
139
|
```
|
132
140
|
|
133
|
-
This code is run in the context of your application so you have access to your
|
134
|
-
since this code is not run in the
|
135
|
-
|
141
|
+
This code is run in the context of your application so you have access to your
|
142
|
+
models, session or routes helpers. However, since this code is not run in the
|
143
|
+
context of your application's `ApplicationController` it doesn't have access to
|
144
|
+
the methods defined over there.
|
136
145
|
|
137
|
-
If you use [devise](https://github.com/plataformatec/devise), you may want to
|
146
|
+
If you use [devise](https://github.com/plataformatec/devise), you may want to
|
147
|
+
use warden to authenticate the block:
|
138
148
|
|
139
149
|
``` ruby
|
140
150
|
resource_owner_authenticator do
|
@@ -142,29 +152,36 @@ resource_owner_authenticator do
|
|
142
152
|
end
|
143
153
|
```
|
144
154
|
|
145
|
-
Side note: when using devise you have access to current_user as devise extends
|
155
|
+
Side note: when using devise you have access to `current_user` as devise extends
|
156
|
+
entire `ActionController::Base` with the `current_#{mapping}`.
|
146
157
|
|
147
|
-
If you are not using devise, you may want to check other ways of
|
158
|
+
If you are not using devise, you may want to check other ways of
|
159
|
+
authentication
|
160
|
+
[here](https://github.com/doorkeeper-gem/doorkeeper/wiki/Authenticating-using-Clearance-or-DIY).
|
148
161
|
|
149
162
|
## Protecting resources with OAuth (a.k.a your API endpoint)
|
150
163
|
|
151
|
-
To protect your API with OAuth, doorkeeper only requires you to call
|
164
|
+
To protect your API with OAuth, doorkeeper only requires you to call
|
165
|
+
`doorkeeper_for` helper, specifying the actions you want to protect.
|
152
166
|
|
153
|
-
For example, if you have a products controller under api/v1, you can require
|
167
|
+
For example, if you have a products controller under api/v1, you can require
|
168
|
+
the OAuth authentication with:
|
154
169
|
|
155
170
|
``` ruby
|
156
171
|
class Api::V1::ProductsController < Api::V1::ApiController
|
157
|
-
doorkeeper_for :all
|
158
|
-
doorkeeper_for :all, :
|
159
|
-
doorkeeper_for :index, :show
|
172
|
+
doorkeeper_for :all # Require access token for all actions
|
173
|
+
doorkeeper_for :all, except: :index # All actions except index
|
174
|
+
doorkeeper_for :index, :show # Only for index and show action
|
160
175
|
|
161
176
|
# your actions
|
162
177
|
end
|
163
178
|
```
|
164
179
|
|
165
|
-
You don't need to setup any before filter, `doorkeeper_for` will handle that
|
180
|
+
You don't need to setup any before filter, `doorkeeper_for` will handle that
|
181
|
+
for you.
|
166
182
|
|
167
|
-
You can pass `if` or `unless` blocks that would specify when doorkeeper has to
|
183
|
+
You can pass `if` or `unless` blocks that would specify when doorkeeper has to
|
184
|
+
guard the access.
|
168
185
|
|
169
186
|
``` ruby
|
170
187
|
class Api::V1::ProductsController < Api::V1::ApiController
|
@@ -174,7 +191,8 @@ end
|
|
174
191
|
|
175
192
|
### ActionController::Metal integration and other integrations
|
176
193
|
|
177
|
-
The `doorkeeper_for` filter is intended to work with ActionController::Metal
|
194
|
+
The `doorkeeper_for` filter is intended to work with ActionController::Metal
|
195
|
+
too. You only need to include the required `ActionController` modules:
|
178
196
|
|
179
197
|
```ruby
|
180
198
|
class MetalController < ActionController::Metal
|
@@ -186,11 +204,14 @@ class MetalController < ActionController::Metal
|
|
186
204
|
end
|
187
205
|
```
|
188
206
|
|
189
|
-
For more information about integration and other integrations, check out [the
|
207
|
+
For more information about integration and other integrations, check out [the
|
208
|
+
related wiki
|
209
|
+
page](https://github.com/doorkeeper-gem/doorkeeper/wiki/ActionController::Metal-with-doorkeeper).
|
190
210
|
|
191
211
|
### Access Token Scopes
|
192
212
|
|
193
|
-
You can also require the access token to have specific scopes in certain
|
213
|
+
You can also require the access token to have specific scopes in certain
|
214
|
+
actions:
|
194
215
|
|
195
216
|
First configure the scopes in `initializers/doorkeeper.rb`
|
196
217
|
|
@@ -210,11 +231,15 @@ class Api::V1::ProductsController < Api::V1::ApiController
|
|
210
231
|
end
|
211
232
|
```
|
212
233
|
|
213
|
-
For a more detailed explanation about scopes usage, check out the related
|
234
|
+
For a more detailed explanation about scopes usage, check out the related
|
235
|
+
[page in the
|
236
|
+
wiki](https://github.com/doorkeeper-gem/doorkeeper/wiki/Using-Scopes).
|
214
237
|
|
215
238
|
### Authenticated resource owner
|
216
239
|
|
217
|
-
If you want to return data based on the current resource owner, in other
|
240
|
+
If you want to return data based on the current resource owner, in other
|
241
|
+
words, the access token owner, you may want to define a method in your
|
242
|
+
controller that returns the resource owner instance:
|
218
243
|
|
219
244
|
``` ruby
|
220
245
|
class Api::V1::CredentialsController < Api::V1::ApiController
|
@@ -235,11 +260,13 @@ class Api::V1::CredentialsController < Api::V1::ApiController
|
|
235
260
|
end
|
236
261
|
```
|
237
262
|
|
238
|
-
In this example, we're returning the credentials (`me.json`) of the access
|
263
|
+
In this example, we're returning the credentials (`me.json`) of the access
|
264
|
+
token owner.
|
239
265
|
|
240
266
|
### Applications list
|
241
267
|
|
242
|
-
By default, the applications list (`/oauth/applications`) is public available.
|
268
|
+
By default, the applications list (`/oauth/applications`) is public available.
|
269
|
+
To protect the endpoint you should uncomment these lines:
|
243
270
|
|
244
271
|
```ruby
|
245
272
|
# config/initializers/doorkeeper.rb
|
@@ -250,16 +277,23 @@ Doorkeeper.configure do
|
|
250
277
|
end
|
251
278
|
```
|
252
279
|
|
253
|
-
The logic is the same as the `resource_owner_authenticator` block. **Note:**
|
280
|
+
The logic is the same as the `resource_owner_authenticator` block. **Note:**
|
281
|
+
since the application list is just a scaffold, it's recommended to either
|
282
|
+
customize the controller used by the list or skip the controller at all. For
|
283
|
+
more information see the page [in the
|
284
|
+
wiki](https://github.com/doorkeeper-gem/doorkeeper/wiki/Customizing-routes).
|
254
285
|
|
255
286
|
## Other customizations
|
256
287
|
|
257
|
-
- [Associate users to OAuth applications (ownership)](https://github.com/
|
258
|
-
- [CORS - Cross Origin Resource Sharing](https://github.com/
|
288
|
+
- [Associate users to OAuth applications (ownership)](https://github.com/doorkeeper-gem/doorkeeper/wiki/Associate-users-to-OAuth-applications-%28ownership%29)
|
289
|
+
- [CORS - Cross Origin Resource Sharing](https://github.com/doorkeeper-gem/doorkeeper/wiki/%5BCORS%5D-Cross-Origin-Resource-Sharing)
|
259
290
|
|
260
291
|
## Upgrading
|
261
292
|
|
262
|
-
If you want to upgrade doorkeeper to a new version, check out the [upgrading
|
293
|
+
If you want to upgrade doorkeeper to a new version, check out the [upgrading
|
294
|
+
notes](https://github.com/doorkeeper-gem/doorkeeper/wiki/Migration-from-old-versions)
|
295
|
+
and take a look at the
|
296
|
+
[changelog](https://github.com/doorkeeper-gem/doorkeeper/blob/master/CHANGELOG.md).
|
263
297
|
|
264
298
|
## Development
|
265
299
|
|
@@ -270,7 +304,8 @@ rails=3.2.8 orm=active_record bundle install
|
|
270
304
|
rails=3.2.8 orm=active_record bundle exec rails server
|
271
305
|
````
|
272
306
|
|
273
|
-
By default, it uses the latest Rails version with ActiveRecord. To run the
|
307
|
+
By default, it uses the latest Rails version with ActiveRecord. To run the
|
308
|
+
tests:
|
274
309
|
|
275
310
|
```
|
276
311
|
rails=3.2.8 orm=active_record bundle exec rake
|
@@ -280,32 +315,48 @@ Or you might prefer to run `script/run_all` to integrate against all ORMs.
|
|
280
315
|
|
281
316
|
## Contributing
|
282
317
|
|
283
|
-
Want to contribute and don't know where to start? Check out [features we're
|
318
|
+
Want to contribute and don't know where to start? Check out [features we're
|
319
|
+
missing](https://github.com/doorkeeper-gem/doorkeeper/wiki/Supported-Features),
|
320
|
+
create [example
|
321
|
+
apps](https://github.com/doorkeeper-gem/doorkeeper/wiki/Example-Applications),
|
322
|
+
integrate the gem with your app and let us know!
|
284
323
|
|
285
|
-
Also, check out our [contributing guidelines
|
324
|
+
Also, check out our [contributing guidelines
|
325
|
+
page](https://github.com/doorkeeper-gem/doorkeeper/wiki/Contributing).
|
286
326
|
|
287
327
|
## Other resources
|
288
328
|
|
289
329
|
### Wiki
|
290
330
|
|
291
|
-
You can find everything about doorkeeper in our [wiki
|
331
|
+
You can find everything about doorkeeper in our [wiki
|
332
|
+
here](https://github.com/doorkeeper-gem/doorkeeper/wiki).
|
292
333
|
|
293
334
|
### Live demo
|
294
335
|
|
295
|
-
Check out this [live demo](http://doorkeeper-provider.herokuapp.com) hosted on
|
336
|
+
Check out this [live demo](http://doorkeeper-provider.herokuapp.com) hosted on
|
337
|
+
heroku. For more demos check out [the
|
338
|
+
wiki](https://github.com/doorkeeper-gem/doorkeeper/wiki/Example-Applications).
|
296
339
|
|
297
340
|
### Screencast
|
298
341
|
|
299
|
-
Check out this screencast from [railscasts.com](http://railscasts.com/): [#353
|
342
|
+
Check out this screencast from [railscasts.com](http://railscasts.com/): [#353
|
343
|
+
OAuth with
|
344
|
+
Doorkeeper](http://railscasts.com/episodes/353-oauth-with-doorkeeper)
|
300
345
|
|
301
346
|
### Client applications
|
302
347
|
|
303
|
-
After you set up the provider, you may want to create a client application to
|
348
|
+
After you set up the provider, you may want to create a client application to
|
349
|
+
test the integration. Check out these [client
|
350
|
+
examples](https://github.com/doorkeeper-gem/doorkeeper/wiki/Example-Applications)
|
351
|
+
in our wiki or follow this [tutorial
|
352
|
+
here](https://github.com/doorkeeper-gem/doorkeeper/wiki/Testing-your-provider-with-OAuth2-gem).
|
304
353
|
|
305
354
|
### Contributors
|
306
355
|
|
307
|
-
Thanks to all our [awesome
|
356
|
+
Thanks to all our [awesome
|
357
|
+
contributors](https://github.com/doorkeeper-gem/doorkeeper/contributors)!
|
308
358
|
|
309
359
|
### License
|
310
360
|
|
311
|
-
MIT License. Copyright 2011 Applicake.
|
361
|
+
MIT License. Copyright 2011 Applicake.
|
362
|
+
[http://applicake.com](http://applicake.com)
|
@@ -4,7 +4,7 @@ module Doorkeeper
|
|
4
4
|
respond_to :html
|
5
5
|
|
6
6
|
before_filter :authenticate_admin!
|
7
|
-
before_filter :set_application, :
|
7
|
+
before_filter :set_application, only: [:show, :edit, :update, :destroy]
|
8
8
|
|
9
9
|
def index
|
10
10
|
@applications = Application.all
|
@@ -17,7 +17,7 @@ module Doorkeeper
|
|
17
17
|
def create
|
18
18
|
@application = Application.new(application_params)
|
19
19
|
if @application.save
|
20
|
-
flash[:notice] = I18n.t(:notice, :
|
20
|
+
flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :create])
|
21
21
|
respond_with [:oauth, @application]
|
22
22
|
else
|
23
23
|
render :new
|
@@ -32,7 +32,7 @@ module Doorkeeper
|
|
32
32
|
|
33
33
|
def update
|
34
34
|
if @application.update_attributes(application_params)
|
35
|
-
flash[:notice] = I18n.t(:notice, :
|
35
|
+
flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :update])
|
36
36
|
respond_with [:oauth, @application]
|
37
37
|
else
|
38
38
|
render :edit
|
@@ -40,7 +40,7 @@ module Doorkeeper
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def destroy
|
43
|
-
flash[:notice] = I18n.t(:notice, :
|
43
|
+
flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :destroy]) if @application.destroy
|
44
44
|
redirect_to oauth_applications_url
|
45
45
|
end
|
46
46
|
|
@@ -25,7 +25,7 @@ module Doorkeeper
|
|
25
25
|
if auth.redirectable?
|
26
26
|
redirect_to auth.redirect_uri
|
27
27
|
else
|
28
|
-
render :
|
28
|
+
render json: auth.body, status: auth.status
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
@@ -35,11 +35,11 @@ module Doorkeeper
|
|
35
35
|
if auth.redirectable?
|
36
36
|
redirect_to auth.redirect_uri
|
37
37
|
else
|
38
|
-
render :
|
38
|
+
render json: auth.body, status: auth.status
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
|
42
|
+
private
|
43
43
|
|
44
44
|
def pre_auth
|
45
45
|
@pre_auth ||= OAuth::PreAuthorization.new(Doorkeeper.configuration, server.client_via_uid, params)
|
@@ -7,6 +7,6 @@ class Doorkeeper::AuthorizedApplicationsController < Doorkeeper::ApplicationCont
|
|
7
7
|
|
8
8
|
def destroy
|
9
9
|
Doorkeeper::AccessToken.revoke_all_for params[:id], current_resource_owner
|
10
|
-
redirect_to oauth_authorized_applications_url, :
|
10
|
+
redirect_to oauth_authorized_applications_url, notice: I18n.t(:notice, scope: [:doorkeeper, :flash, :authorized_applications, :destroy])
|
11
11
|
end
|
12
12
|
end
|
@@ -2,11 +2,11 @@ module Doorkeeper
|
|
2
2
|
class TokenInfoController < ::Doorkeeper::ApplicationController
|
3
3
|
def show
|
4
4
|
if doorkeeper_token && doorkeeper_token.accessible?
|
5
|
-
render :
|
5
|
+
render json: doorkeeper_token, status: :ok
|
6
6
|
else
|
7
|
-
error = OAuth::ErrorResponse.new(:
|
7
|
+
error = OAuth::ErrorResponse.new(name: :invalid_request)
|
8
8
|
response.headers.merge!(error.headers)
|
9
|
-
render :
|
9
|
+
render json: error.body, status: error.status
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Doorkeeper
|
2
|
-
class TokensController <
|
2
|
+
class TokensController < ::Doorkeeper::ApplicationController
|
3
3
|
include Helpers::Controller
|
4
4
|
include ActionController::RackDelegation
|
5
5
|
include ActionController::Instrumentation
|
@@ -13,7 +13,34 @@ module Doorkeeper
|
|
13
13
|
handle_token_exception e
|
14
14
|
end
|
15
15
|
|
16
|
-
|
16
|
+
#############################################
|
17
|
+
# RFC 7009 - OAuth 2.0 Token Revocation #
|
18
|
+
# #
|
19
|
+
# http://tools.ietf.org/html/rfc7009 #
|
20
|
+
#############################################
|
21
|
+
def revoke
|
22
|
+
# The authorization server first validates the client credentials
|
23
|
+
if doorkeeper_token && doorkeeper_token.accessible?
|
24
|
+
# Doorkeeper does not use the token_type_hint logic described in the RFC 7009
|
25
|
+
# due to the refresh token implementation that is a field in the access token model.
|
26
|
+
revoke_token(request.POST['token']) if request.POST['token']
|
27
|
+
end
|
28
|
+
# The authorization server responds with HTTP status code 200 if the
|
29
|
+
# token has been revoked sucessfully or if the client submitted an invalid token
|
30
|
+
render json: {}, status: 200
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def revoke_token(token)
|
36
|
+
token = Doorkeeper::AccessToken.authenticate(token) || Doorkeeper::AccessToken.by_refresh_token(token)
|
37
|
+
if token && doorkeeper_token.same_credential?(token)
|
38
|
+
token.revoke
|
39
|
+
true
|
40
|
+
else
|
41
|
+
false
|
42
|
+
end
|
43
|
+
end
|
17
44
|
|
18
45
|
def strategy
|
19
46
|
@strategy ||= server.token_request params[:grant_type]
|