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
@@ -1,37 +1,37 @@
|
|
1
1
|
require 'spec_helper_integration'
|
2
2
|
|
3
3
|
describe Doorkeeper::TokensController do
|
4
|
-
describe
|
4
|
+
describe 'when authorization has succeeded' do
|
5
5
|
let :token do
|
6
|
-
double(:token, :
|
6
|
+
double(:token, authorize: true)
|
7
7
|
end
|
8
8
|
|
9
9
|
before do
|
10
10
|
allow(controller).to receive(:token) { token }
|
11
11
|
end
|
12
12
|
|
13
|
-
it
|
13
|
+
it 'returns the authorization' do
|
14
14
|
pending 'verify need of these specs'
|
15
15
|
expect(token).to receive(:authorization)
|
16
16
|
post :create
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
describe
|
20
|
+
describe 'when authorization has failed' do
|
21
21
|
let :token do
|
22
|
-
double(:token, :
|
22
|
+
double(:token, authorize: false)
|
23
23
|
end
|
24
24
|
|
25
25
|
before do
|
26
26
|
allow(controller).to receive(:token) { token }
|
27
27
|
end
|
28
28
|
|
29
|
-
it
|
29
|
+
it 'returns the error response' do
|
30
30
|
pending 'verify need of these specs'
|
31
|
-
allow(token).to receive(:error_response).and_return(double(:
|
31
|
+
allow(token).to receive(:error_response).and_return(double(to_json: [], status: :unauthorized))
|
32
32
|
post :create
|
33
33
|
expect(response.status).to eq 401
|
34
|
-
expect(response.headers[
|
34
|
+
expect(response.headers['WWW-Authenticate']).to match(/Bearer/)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class CustomAuthorizationsController < ::ApplicationController
|
2
|
-
%w
|
2
|
+
%w(index show new create edit update destroy).each do |action|
|
3
3
|
define_method action do
|
4
|
-
render :
|
4
|
+
render nothing: true
|
5
5
|
end
|
6
6
|
end
|
7
7
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
class FullProtectedResourcesController < ApplicationController
|
2
2
|
doorkeeper_for :index
|
3
|
-
doorkeeper_for :show, :
|
3
|
+
doorkeeper_for :show, scopes: [:admin]
|
4
4
|
|
5
5
|
def index
|
6
|
-
render :
|
6
|
+
render text: 'index'
|
7
7
|
end
|
8
8
|
|
9
9
|
def show
|
10
|
-
render :
|
10
|
+
render text: 'show'
|
11
11
|
end
|
12
12
|
end
|
@@ -4,14 +4,14 @@ class HomeController < ApplicationController
|
|
4
4
|
|
5
5
|
def sign_in
|
6
6
|
session[:user_id] = if Rails.env.development?
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
User.first || User.create!(name: 'Joe', password: 'sekret')
|
8
|
+
else
|
9
|
+
User.first
|
10
|
+
end
|
11
11
|
redirect_to '/'
|
12
12
|
end
|
13
13
|
|
14
14
|
def callback
|
15
|
-
render :
|
15
|
+
render text: 'ok'
|
16
16
|
end
|
17
17
|
end
|
@@ -2,10 +2,10 @@ class SemiProtectedResourcesController < ApplicationController
|
|
2
2
|
doorkeeper_for :index
|
3
3
|
|
4
4
|
def index
|
5
|
-
render :
|
5
|
+
render text: 'protected index'
|
6
6
|
end
|
7
7
|
|
8
8
|
def show
|
9
|
-
render :
|
9
|
+
render text: 'protected show'
|
10
10
|
end
|
11
11
|
end
|
@@ -7,8 +7,8 @@ when :mongoid2, :mongoid3, :mongoid4
|
|
7
7
|
include Mongoid::Document
|
8
8
|
include Mongoid::Timestamps
|
9
9
|
|
10
|
-
field :name, :
|
11
|
-
field :password, :
|
10
|
+
field :name, type: String
|
11
|
+
field :password, type: String
|
12
12
|
end
|
13
13
|
when :mongo_mapper
|
14
14
|
class User
|
@@ -26,6 +26,6 @@ class User
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def self.authenticate!(name, password)
|
29
|
-
User.where(:
|
29
|
+
User.where(name: name, password: password).first
|
30
30
|
end
|
31
31
|
end
|
@@ -1,16 +1,16 @@
|
|
1
1
|
require File.expand_path('../boot', __FILE__)
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'action_controller/railtie'
|
4
|
+
require 'sprockets/railtie'
|
5
5
|
|
6
6
|
Bundler.require :default
|
7
7
|
|
8
8
|
orm = if [:mongoid2, :mongoid3, :mongoid4].include?(DOORKEEPER_ORM)
|
9
|
-
|
10
|
-
|
11
|
-
else
|
12
|
-
|
13
|
-
end
|
9
|
+
Mongoid.load!(File.join(File.dirname(File.expand_path(__FILE__)), "#{DOORKEEPER_ORM}.yml"))
|
10
|
+
:mongoid
|
11
|
+
else
|
12
|
+
DOORKEEPER_ORM
|
13
|
+
end
|
14
14
|
|
15
15
|
require "#{orm}/railtie"
|
16
16
|
|
@@ -40,7 +40,7 @@ module Dummy
|
|
40
40
|
# config.i18n.default_locale = :en
|
41
41
|
|
42
42
|
# Configure the default encoding used in templates for Ruby 1.9.
|
43
|
-
config.encoding =
|
43
|
+
config.encoding = 'utf-8'
|
44
44
|
|
45
45
|
# Configure sensitive parameters which will be filtered from the log file.
|
46
46
|
config.filter_parameters += [:password]
|
@@ -52,4 +52,3 @@ module Dummy
|
|
52
52
|
config.assets.version = '1.0'
|
53
53
|
end
|
54
54
|
end
|
55
|
-
|
data/spec/dummy/config/boot.rb
CHANGED
@@ -9,7 +9,7 @@ Dummy::Application.configure do
|
|
9
9
|
|
10
10
|
# Configure static asset server for tests with Cache-Control for performance
|
11
11
|
config.serve_static_assets = true
|
12
|
-
config.static_cache_control =
|
12
|
+
config.static_cache_control = 'public, max-age=3600'
|
13
13
|
|
14
14
|
if Rails.version.to_i < 4
|
15
15
|
# Log error messages when you accidentally call methods on nil
|
@@ -8,7 +8,7 @@ Doorkeeper.configure do
|
|
8
8
|
resource_owner_authenticator do
|
9
9
|
# Put your resource owner authentication logic here.
|
10
10
|
# e.g. User.find_by_id(session[:user_id]) || redirect_to(new_user_session_url)
|
11
|
-
User.find_by_id(session[:user_id]) || redirect_to(root_url, :
|
11
|
+
User.find_by_id(session[:user_id]) || redirect_to(root_url, alert: 'Needs sign in.')
|
12
12
|
end
|
13
13
|
|
14
14
|
# If you want to restrict the access to the web interface for
|
@@ -30,7 +30,8 @@ Doorkeeper.configure do
|
|
30
30
|
use_refresh_token
|
31
31
|
|
32
32
|
# Define access token scopes for your provider
|
33
|
-
# For more information go to
|
33
|
+
# For more information go to
|
34
|
+
# https://github.com/doorkeeper-gem/doorkeeper/wiki/Using-Scopes
|
34
35
|
default_scopes :public
|
35
36
|
optional_scopes :write, :update
|
36
37
|
|
@@ -46,7 +47,6 @@ Doorkeeper.configure do
|
|
46
47
|
# Check out the wiki for mor information on customization
|
47
48
|
# access_token_methods :from_bearer_authorization, :from_access_token_param, :from_bearer_param
|
48
49
|
|
49
|
-
|
50
50
|
# Change the test redirect uri for client apps
|
51
51
|
# When clients register with the following redirect uri, they won't be redirected to any server and the authorization code will be displayed within the provider
|
52
52
|
# The value can be any string. Use nil to disable this feature. When disabled, clients must provide a valid URL
|
@@ -54,6 +54,6 @@ Doorkeeper.configure do
|
|
54
54
|
#
|
55
55
|
# test_redirect_uri 'urn:ietf:wg:oauth:2.0:oob'
|
56
56
|
|
57
|
-
#
|
58
|
-
realm
|
57
|
+
# WWW-Authenticate Realm (default 'Doorkeeper').
|
58
|
+
realm 'Doorkeeper'
|
59
59
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# Be sure to restart your server when you modify this file.
|
2
2
|
|
3
|
-
Dummy::Application.config.session_store :cookie_store, :
|
3
|
+
Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
|
4
4
|
|
5
5
|
# Use the database for sessions instead of the cookie-based default,
|
6
6
|
# which shouldn't be used to store highly confidential information
|
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
7
7
|
ActiveSupport.on_load(:action_controller) do
|
8
|
-
wrap_parameters :
|
8
|
+
wrap_parameters format: [:json]
|
9
9
|
end
|
10
10
|
|
11
11
|
# Disable root element in JSON by default.
|
data/spec/dummy/config/routes.rb
CHANGED
@@ -1,42 +1,42 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
2
|
use_doorkeeper
|
3
|
-
use_doorkeeper :
|
3
|
+
use_doorkeeper scope: 'scope'
|
4
4
|
|
5
5
|
scope 'inner_space' do
|
6
|
-
use_doorkeeper :
|
7
|
-
controllers :
|
8
|
-
:
|
9
|
-
:
|
10
|
-
:
|
11
|
-
|
12
|
-
as :
|
13
|
-
:
|
14
|
-
:
|
6
|
+
use_doorkeeper scope: 'scope' do
|
7
|
+
controllers authorizations: 'custom_authorizations',
|
8
|
+
tokens: 'custom_authorizations',
|
9
|
+
applications: 'custom_authorizations',
|
10
|
+
token_info: 'custom_authorizations'
|
11
|
+
|
12
|
+
as authorizations: 'custom_auth',
|
13
|
+
tokens: 'custom_token',
|
14
|
+
token_info: 'custom_token_info'
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
scope 'space' do
|
19
19
|
use_doorkeeper do
|
20
|
-
controllers :
|
21
|
-
:
|
22
|
-
:
|
23
|
-
:
|
24
|
-
|
25
|
-
as :
|
26
|
-
:
|
27
|
-
:
|
20
|
+
controllers authorizations: 'custom_authorizations',
|
21
|
+
tokens: 'custom_authorizations',
|
22
|
+
applications: 'custom_authorizations',
|
23
|
+
token_info: 'custom_authorizations'
|
24
|
+
|
25
|
+
as authorizations: 'custom_auth',
|
26
|
+
tokens: 'custom_token',
|
27
|
+
token_info: 'custom_token_info'
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
31
|
scope 'outer_space' do
|
32
32
|
use_doorkeeper do
|
33
|
-
controllers :
|
34
|
-
:
|
35
|
-
:
|
33
|
+
controllers authorizations: 'custom_authorizations',
|
34
|
+
tokens: 'custom_authorizations',
|
35
|
+
token_info: 'custom_authorizations'
|
36
36
|
|
37
|
-
as :
|
38
|
-
:
|
39
|
-
:
|
37
|
+
as authorizations: 'custom_auth',
|
38
|
+
tokens: 'custom_token',
|
39
|
+
token_info: 'custom_token_info'
|
40
40
|
|
41
41
|
skip_controllers :tokens, :applications, :token_info
|
42
42
|
end
|
@@ -44,9 +44,9 @@ Rails.application.routes.draw do
|
|
44
44
|
|
45
45
|
get 'metal.json' => 'metal#index'
|
46
46
|
|
47
|
-
get '/callback', :
|
48
|
-
get '/sign_in', :
|
47
|
+
get '/callback', to: 'home#callback'
|
48
|
+
get '/sign_in', to: 'home#sign_in'
|
49
49
|
resources :semi_protected_resources
|
50
50
|
resources :full_protected_resources
|
51
|
-
root :
|
51
|
+
root to: 'home#index'
|
52
52
|
end
|
@@ -1,42 +1,41 @@
|
|
1
1
|
class CreateDoorkeeperTables < ActiveRecord::Migration
|
2
2
|
def change
|
3
3
|
create_table :oauth_applications do |t|
|
4
|
-
t.string :name, :
|
5
|
-
t.string :uid, :
|
6
|
-
t.string :secret, :
|
7
|
-
t.string :redirect_uri, :
|
4
|
+
t.string :name, null: false
|
5
|
+
t.string :uid, null: false
|
6
|
+
t.string :secret, null: false
|
7
|
+
t.string :redirect_uri, null: false, limit: 2048
|
8
8
|
t.timestamps
|
9
9
|
end
|
10
10
|
|
11
|
-
add_index :oauth_applications, :uid, :
|
11
|
+
add_index :oauth_applications, :uid, unique: true
|
12
12
|
|
13
13
|
create_table :oauth_access_grants do |t|
|
14
|
-
t.integer :resource_owner_id, :
|
15
|
-
t.integer :application_id, :
|
16
|
-
t.string :token, :
|
17
|
-
t.integer :expires_in, :
|
18
|
-
t.string :redirect_uri, :
|
19
|
-
t.datetime :created_at, :
|
14
|
+
t.integer :resource_owner_id, null: false
|
15
|
+
t.integer :application_id, null: false
|
16
|
+
t.string :token, null: false
|
17
|
+
t.integer :expires_in, null: false
|
18
|
+
t.string :redirect_uri, null: false, limit: 2048
|
19
|
+
t.datetime :created_at, null: false
|
20
20
|
t.datetime :revoked_at
|
21
21
|
t.string :scopes
|
22
22
|
end
|
23
23
|
|
24
|
-
add_index :oauth_access_grants, :token, :
|
24
|
+
add_index :oauth_access_grants, :token, unique: true
|
25
25
|
|
26
26
|
create_table :oauth_access_tokens do |t|
|
27
27
|
t.integer :resource_owner_id
|
28
28
|
t.integer :application_id
|
29
|
-
t.string :token, :
|
29
|
+
t.string :token, null: false
|
30
30
|
t.string :refresh_token
|
31
31
|
t.integer :expires_in
|
32
32
|
t.datetime :revoked_at
|
33
|
-
t.datetime :created_at, :
|
33
|
+
t.datetime :created_at, null: false
|
34
34
|
t.string :scopes
|
35
35
|
end
|
36
36
|
|
37
|
-
add_index :oauth_access_tokens, :token, :
|
37
|
+
add_index :oauth_access_tokens, :token, unique: true
|
38
38
|
add_index :oauth_access_tokens, :resource_owner_id
|
39
|
-
add_index :oauth_access_tokens, :refresh_token, :
|
40
|
-
|
39
|
+
add_index :oauth_access_tokens, :refresh_token, unique: true
|
41
40
|
end
|
42
41
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class AddOwnerToApplication < ActiveRecord::Migration
|
2
2
|
def change
|
3
|
-
add_column :oauth_applications, :owner_id, :integer, :
|
4
|
-
add_column :oauth_applications, :owner_type, :string, :
|
3
|
+
add_column :oauth_applications, :owner_id, :integer, null: true
|
4
|
+
add_column :oauth_applications, :owner_type, :string, null: true
|
5
5
|
add_index :oauth_applications, [:owner_id, :owner_type]
|
6
6
|
end
|
7
|
-
end
|
7
|
+
end
|
data/spec/dummy/db/schema.rb
CHANGED
@@ -11,55 +11,55 @@
|
|
11
11
|
#
|
12
12
|
# It's strongly recommended to check this file into your version control system.
|
13
13
|
|
14
|
-
ActiveRecord::Schema.define(:
|
14
|
+
ActiveRecord::Schema.define(version: 20130902175349) do
|
15
15
|
|
16
|
-
create_table
|
17
|
-
t.integer
|
18
|
-
t.integer
|
19
|
-
t.string
|
20
|
-
t.integer
|
21
|
-
t.text
|
22
|
-
t.datetime
|
23
|
-
t.datetime
|
24
|
-
t.string
|
16
|
+
create_table 'oauth_access_grants', force: true do |t|
|
17
|
+
t.integer 'resource_owner_id', null: false
|
18
|
+
t.integer 'application_id', null: false
|
19
|
+
t.string 'token', null: false
|
20
|
+
t.integer 'expires_in', null: false
|
21
|
+
t.text 'redirect_uri', null: false
|
22
|
+
t.datetime 'created_at', null: false
|
23
|
+
t.datetime 'revoked_at'
|
24
|
+
t.string 'scopes'
|
25
25
|
end
|
26
26
|
|
27
|
-
add_index
|
27
|
+
add_index 'oauth_access_grants', ['token'], name: 'index_oauth_access_grants_on_token', unique: true
|
28
28
|
|
29
|
-
create_table
|
30
|
-
t.integer
|
31
|
-
t.integer
|
32
|
-
t.string
|
33
|
-
t.string
|
34
|
-
t.integer
|
35
|
-
t.datetime
|
36
|
-
t.datetime
|
37
|
-
t.string
|
29
|
+
create_table 'oauth_access_tokens', force: true do |t|
|
30
|
+
t.integer 'resource_owner_id'
|
31
|
+
t.integer 'application_id'
|
32
|
+
t.string 'token', null: false
|
33
|
+
t.string 'refresh_token'
|
34
|
+
t.integer 'expires_in'
|
35
|
+
t.datetime 'revoked_at'
|
36
|
+
t.datetime 'created_at', null: false
|
37
|
+
t.string 'scopes'
|
38
38
|
end
|
39
39
|
|
40
|
-
add_index
|
41
|
-
add_index
|
42
|
-
add_index
|
40
|
+
add_index 'oauth_access_tokens', ['refresh_token'], name: 'index_oauth_access_tokens_on_refresh_token', unique: true
|
41
|
+
add_index 'oauth_access_tokens', ['resource_owner_id'], name: 'index_oauth_access_tokens_on_resource_owner_id'
|
42
|
+
add_index 'oauth_access_tokens', ['token'], name: 'index_oauth_access_tokens_on_token', unique: true
|
43
43
|
|
44
|
-
create_table
|
45
|
-
t.string
|
46
|
-
t.string
|
47
|
-
t.string
|
48
|
-
t.text
|
49
|
-
t.datetime
|
50
|
-
t.datetime
|
51
|
-
t.integer
|
52
|
-
t.string
|
44
|
+
create_table 'oauth_applications', force: true do |t|
|
45
|
+
t.string 'name', null: false
|
46
|
+
t.string 'uid', null: false
|
47
|
+
t.string 'secret', null: false
|
48
|
+
t.text 'redirect_uri', null: false
|
49
|
+
t.datetime 'created_at', null: false
|
50
|
+
t.datetime 'updated_at', null: false
|
51
|
+
t.integer 'owner_id'
|
52
|
+
t.string 'owner_type'
|
53
53
|
end
|
54
54
|
|
55
|
-
add_index
|
56
|
-
add_index
|
55
|
+
add_index 'oauth_applications', %w(owner_id owner_type), name: 'index_oauth_applications_on_owner_id_and_owner_type'
|
56
|
+
add_index 'oauth_applications', ['uid'], name: 'index_oauth_applications_on_uid', unique: true
|
57
57
|
|
58
|
-
create_table
|
59
|
-
t.string
|
60
|
-
t.datetime
|
61
|
-
t.datetime
|
62
|
-
t.string
|
58
|
+
create_table 'users', force: true do |t|
|
59
|
+
t.string 'name'
|
60
|
+
t.datetime 'created_at', null: false
|
61
|
+
t.datetime 'updated_at', null: false
|
62
|
+
t.string 'password'
|
63
63
|
end
|
64
64
|
|
65
65
|
end
|