doorkeeper 3.1.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/.travis.yml +8 -10
- data/CONTRIBUTING.md +2 -0
- data/Gemfile +8 -4
- data/NEWS.md +57 -2
- data/README.md +48 -40
- data/Rakefile +1 -1
- 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/layouts/doorkeeper/admin.html.erb +1 -1
- data/config/locales/en.yml +1 -0
- data/doorkeeper.gemspec +7 -6
- data/lib/doorkeeper/config.rb +10 -15
- data/lib/doorkeeper/engine.rb +11 -7
- data/lib/doorkeeper/helpers/controller.rb +1 -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/client/credentials.rb +1 -1
- 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/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 +23 -11
- 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_token.rb +8 -0
- data/lib/doorkeeper/orm/active_record/application.rb +2 -7
- data/lib/doorkeeper/orm/active_record.rb +0 -16
- data/lib/doorkeeper/rails/helpers.rb +1 -1
- data/lib/doorkeeper/rails/routes/mapper.rb +1 -1
- data/lib/doorkeeper/rails/routes.rb +2 -1
- data/lib/doorkeeper/request/password.rb +11 -1
- 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 +47 -18
- 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/{20130902175349_add_owner_to_application.rb → 20151223200000_add_owner_to_application.rb} +0 -0
- 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/code_response_spec.rb +34 -0
- 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 +0 -1
- data/spec/lib/oauth/token_spec.rb +12 -5
- data/spec/models/doorkeeper/access_token_spec.rb +45 -1
- data/spec/models/doorkeeper/application_spec.rb +2 -10
- data/spec/requests/flows/password_spec.rb +26 -5
- data/spec/requests/flows/refresh_token_spec.rb +87 -17
- data/spec/spec_helper_integration.rb +3 -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 +52 -32
- 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
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/.travis.yml
CHANGED
@@ -3,20 +3,18 @@ language: ruby
|
|
3
3
|
sudo: false
|
4
4
|
|
5
5
|
rvm:
|
6
|
-
- 2.0
|
7
6
|
- 2.1
|
8
|
-
- 2.2
|
9
|
-
-
|
7
|
+
- 2.2.4
|
8
|
+
- 2.3.0
|
9
|
+
|
10
|
+
before_install:
|
11
|
+
- gem install bundler -v '~> 1.10'
|
10
12
|
|
11
13
|
env:
|
12
|
-
- rails=3.2.0
|
13
|
-
- rails=4.1.0
|
14
14
|
- rails=4.2.0
|
15
|
+
- rails=5.0.0
|
15
16
|
|
16
17
|
matrix:
|
17
18
|
exclude:
|
18
|
-
- env: rails=
|
19
|
-
rvm:
|
20
|
-
exclude:
|
21
|
-
- env: rails=3.2.0
|
22
|
-
rvm: 2.2
|
19
|
+
- env: rails=5.0.0
|
20
|
+
rvm: 2.1
|
data/CONTRIBUTING.md
CHANGED
data/Gemfile
CHANGED
@@ -1,10 +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
|
6
10
|
|
7
|
-
gem "sqlite3", platform: [:ruby, :mswin, :mingw]
|
8
11
|
gem "activerecord-jdbcsqlite3-adapter", platform: :jruby
|
12
|
+
gem "sqlite3", platform: [:ruby, :mswin, :mingw]
|
9
13
|
|
10
14
|
gemspec
|
data/NEWS.md
CHANGED
@@ -2,7 +2,62 @@
|
|
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
|
6
61
|
|
7
62
|
## 3.1.0
|
8
63
|
|
@@ -67,7 +122,7 @@ User-visible changes worth mentioning.
|
|
67
122
|
- Remove `applications.scopes` upgrade notice.
|
68
123
|
|
69
124
|
|
70
|
-
## 2.2.2
|
125
|
+
## 2.2.2
|
71
126
|
|
72
127
|
- [#541] Fixed `undefined method attr_accessible` problem on Rails 4
|
73
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
|
@@ -16,43 +16,41 @@ functionality to your Rails or Grape application.
|
|
16
16
|
Please check the documentation for the version of doorkeeper you are using in:
|
17
17
|
https://github.com/doorkeeper-gem/doorkeeper/releases
|
18
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)
|
21
|
+
|
19
22
|
## Table of Contents
|
20
23
|
|
21
24
|
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
22
25
|
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
23
|
-
|
26
|
+
|
24
27
|
- [Installation](#installation)
|
25
28
|
- [Configuration](#configuration)
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
29
|
+
- [Active Record](#active-record)
|
30
|
+
- [Other ORMs](#other-orms)
|
31
|
+
- [Routes](#routes)
|
32
|
+
- [Authenticating](#authenticating)
|
33
|
+
- [Internationalization (I18n)](#internationalization-i18n)
|
31
34
|
- [Protecting resources with OAuth (a.k.a your API endpoint)](#protecting-resources-with-oauth-aka-your-api-endpoint)
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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)
|
38
41
|
- [Other customizations](#other-customizations)
|
39
42
|
- [Upgrading](#upgrading)
|
40
43
|
- [Development](#development)
|
41
44
|
- [Contributing](#contributing)
|
42
45
|
- [Other resources](#other-resources)
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
46
|
+
- [Wiki](#wiki)
|
47
|
+
- [Screencast](#screencast)
|
48
|
+
- [Client applications](#client-applications)
|
49
|
+
- [Contributors](#contributors)
|
50
|
+
- [IETF Standards](#ietf-standards)
|
51
|
+
- [License](#license)
|
50
52
|
|
51
|
-
|
52
|
-
## Useful links
|
53
|
-
|
54
|
-
- For documentation, please check out our [wiki](https://github.com/doorkeeper-gem/doorkeeper/wiki)
|
55
|
-
- 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 -->
|
56
54
|
|
57
55
|
## Installation
|
58
56
|
|
@@ -77,9 +75,19 @@ to generate the migration tables:
|
|
77
75
|
|
78
76
|
rails generate doorkeeper:migration
|
79
77
|
|
80
|
-
|
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
81
|
|
82
|
-
|
82
|
+
```ruby
|
83
|
+
add_foreign_key :table_name, :users, column: :resource_owner_id
|
84
|
+
```
|
85
|
+
|
86
|
+
Then run migrations:
|
87
|
+
|
88
|
+
```sh
|
89
|
+
rake db:migrate
|
90
|
+
```
|
83
91
|
|
84
92
|
### Other ORMs
|
85
93
|
|
@@ -119,7 +127,7 @@ wiki](https://github.com/doorkeeper-gem/doorkeeper/wiki/Customizing-routes).
|
|
119
127
|
### Authenticating
|
120
128
|
|
121
129
|
You need to configure Doorkeeper in order to provide `resource_owner` model
|
122
|
-
and authentication block `initializers/doorkeeper.rb
|
130
|
+
and authentication block in `config/initializers/doorkeeper.rb`:
|
123
131
|
|
124
132
|
``` ruby
|
125
133
|
Doorkeeper.configure do
|
@@ -238,13 +246,13 @@ class Api::V1::ProductsController < Api::V1::ApiController
|
|
238
246
|
end
|
239
247
|
```
|
240
248
|
|
241
|
-
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
|
242
250
|
above example, `doorkeeper_authorize! :admin, :write` means that the access
|
243
|
-
token is required to have either `:admin` scope or `:write` scope, but not
|
244
|
-
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.
|
245
253
|
|
246
|
-
If want to require the access token to have multiple scopes at the same
|
247
|
-
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:
|
248
256
|
|
249
257
|
```ruby
|
250
258
|
class Api::V1::ProductsController < Api::V1::ApiController
|
@@ -256,8 +264,8 @@ class Api::V1::ProductsController < Api::V1::ApiController
|
|
256
264
|
end
|
257
265
|
```
|
258
266
|
|
259
|
-
In above example, a client can call `:create` action only if its access token
|
260
|
-
|
267
|
+
In the above example, a client can call `:create` action only if its access token
|
268
|
+
has both `:admin` and `:write` scopes.
|
261
269
|
|
262
270
|
### Custom Access Token Generator
|
263
271
|
|
@@ -305,7 +313,7 @@ token owner.
|
|
305
313
|
|
306
314
|
### Applications list
|
307
315
|
|
308
|
-
By default, the applications list (`/oauth/applications`) is
|
316
|
+
By default, the applications list (`/oauth/applications`) is publicly available.
|
309
317
|
To protect the endpoint you should uncomment these lines:
|
310
318
|
|
311
319
|
```ruby
|
@@ -319,9 +327,9 @@ end
|
|
319
327
|
|
320
328
|
The logic is the same as the `resource_owner_authenticator` block. **Note:**
|
321
329
|
since the application list is just a scaffold, it's recommended to either
|
322
|
-
customize the controller used by the list or skip the controller
|
323
|
-
more information see the page
|
324
|
-
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).
|
325
333
|
|
326
334
|
## Other customizations
|
327
335
|
|
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 %>
|
@@ -19,7 +19,7 @@
|
|
19
19
|
<%= link_to t('doorkeeper.layouts.admin.nav.applications'), oauth_applications_path %>
|
20
20
|
<% end %>
|
21
21
|
<%= content_tag :li do %>
|
22
|
-
<%= link_to '
|
22
|
+
<%= link_to t('doorkeeper.layouts.admin.nav.home'), root_path %>
|
23
23
|
<% end %>
|
24
24
|
</ul>
|
25
25
|
</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,12 +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 "generator_spec", "~> 0.9.0"
|
21
|
+
s.add_development_dependency "capybara"
|
22
|
+
s.add_development_dependency "database_cleaner", "~> 1.3.0"
|
24
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"
|
25
27
|
s.add_development_dependency "timecop", "~> 0.7.0"
|
26
|
-
s.add_development_dependency "database_cleaner", "~> 1.3.0"
|
27
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
|
data/lib/doorkeeper/engine.rb
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
module Doorkeeper
|
2
2
|
class Engine < Rails::Engine
|
3
3
|
initializer "doorkeeper.params.filter" do |app|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
initializer "doorkeeper.locales" do |app|
|
8
|
-
if app.config.i18n.fallbacks.blank?
|
9
|
-
app.config.i18n.fallbacks = [:en]
|
10
|
-
end
|
4
|
+
parameters = %w(client_secret code authentication_token access_token refresh_token)
|
5
|
+
app.config.filter_parameters << /^(#{Regexp.union parameters})$/
|
11
6
|
end
|
12
7
|
|
13
8
|
initializer "doorkeeper.routes" do
|
@@ -19,5 +14,14 @@ module Doorkeeper
|
|
19
14
|
include Doorkeeper::Rails::Helpers
|
20
15
|
end
|
21
16
|
end
|
17
|
+
|
18
|
+
if defined?(Sprockets) && Sprockets::VERSION.chr.to_i >= 4
|
19
|
+
initializer 'doorkeeper.assets.precompile' do |app|
|
20
|
+
app.config.assets.precompile += %w(
|
21
|
+
doorkeeper/application.css
|
22
|
+
doorkeeper/admin/application.css
|
23
|
+
)
|
24
|
+
end
|
25
|
+
end
|
22
26
|
end
|
23
27
|
end
|
@@ -54,7 +54,7 @@ module Doorkeeper
|
|
54
54
|
|
55
55
|
def handle_token_exception(exception)
|
56
56
|
error = get_error_response_from_exception exception
|
57
|
-
|
57
|
+
headers.merge! error.headers
|
58
58
|
self.response_body = error.body.to_json
|
59
59
|
self.status = error.status
|
60
60
|
end
|
@@ -10,12 +10,16 @@ module Doorkeeper
|
|
10
10
|
include ActiveModel::MassAssignmentSecurity if defined?(::ProtectedAttributes)
|
11
11
|
|
12
12
|
included do
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
belongs_to_options = {
|
14
|
+
class_name: 'Doorkeeper::Application',
|
15
|
+
inverse_of: :access_grants
|
16
|
+
}
|
17
|
+
if defined?(ActiveRecord::Base) && ActiveRecord::VERSION::MAJOR >= 5
|
18
|
+
belongs_to_options[:optional] = true
|
17
19
|
end
|
18
20
|
|
21
|
+
belongs_to :application, belongs_to_options
|
22
|
+
|
19
23
|
validates :resource_owner_id, :application_id, :token, :expires_in, :redirect_uri, presence: true
|
20
24
|
validates :token, uniqueness: true
|
21
25
|
|
@@ -24,7 +28,7 @@ module Doorkeeper
|
|
24
28
|
|
25
29
|
module ClassMethods
|
26
30
|
def by_token(token)
|
27
|
-
|
31
|
+
find_by(token: token.to_s)
|
28
32
|
end
|
29
33
|
end
|
30
34
|
|