devise_oauth2_rails4 1.1.2 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +6 -0
- data/.ruby-gemset +1 -1
- data/CONTRIBUTORS.txt +1 -0
- data/README.md +2 -2
- data/Rakefile +3 -3
- data/app/controllers/devise/{oauth2_providable → oauth2}/authorizations_controller.rb +8 -2
- data/app/controllers/devise/oauth2/tokens_controller.rb +23 -0
- data/app/models/devise/oauth2/access_token.rb +39 -0
- data/app/models/devise/oauth2/authorization_code.rb +3 -0
- data/app/models/devise/oauth2/client.rb +29 -0
- data/app/models/devise/{oauth2_providable → oauth2}/refresh_token.rb +1 -1
- data/app/views/devise/{oauth2_providable → oauth2}/authorizations/_form.html.erb +1 -0
- data/app/views/devise/{oauth2_providable → oauth2}/authorizations/error.html.erb +0 -0
- data/app/views/devise/oauth2/authorizations/new.html.erb +8 -0
- data/config/routes.rb +2 -1
- data/db/migrate/20111014160714_create_devise_oauth2_providable_schema.rb +13 -8
- data/devise_oauth2_rails4.gemspec +32 -0
- data/lib/devise/oauth2/engine.rb +16 -0
- data/lib/devise/{oauth2_providable → oauth2}/expirable_token.rb +4 -4
- data/lib/devise/{oauth2_providable → oauth2}/models/oauth2_authorization_code_grantable.rb +0 -0
- data/lib/devise/{oauth2_providable → oauth2}/models/oauth2_password_grantable.rb +0 -0
- data/lib/devise/{oauth2_providable → oauth2}/models/oauth2_providable.rb +3 -3
- data/lib/devise/{oauth2_providable → oauth2}/models/oauth2_refresh_token_grantable.rb +0 -0
- data/lib/devise/{oauth2_providable → oauth2}/strategies/oauth2_authorization_code_grant_type_strategy.rb +1 -1
- data/lib/devise/{oauth2_providable → oauth2}/strategies/oauth2_grant_type_strategy.rb +1 -1
- data/lib/devise/{oauth2_providable → oauth2}/strategies/oauth2_password_grant_type_strategy.rb +1 -1
- data/lib/devise/{oauth2_providable → oauth2}/strategies/oauth2_providable_strategy.rb +3 -3
- data/lib/devise/{oauth2_providable → oauth2}/strategies/oauth2_refresh_token_grant_type_strategy.rb +2 -2
- data/lib/devise/oauth2/version.rb +5 -0
- data/lib/devise_oauth2_rails4.rb +41 -0
- data/lib/generators/devise/oauth2/migrations_generator.rb +16 -0
- data/lib/generators/devise/oauth2/views_generator.rb +11 -0
- data/rails/tasks/engine.rake +17 -0
- data/spec/controllers/authorizations_controller_spec.rb +1 -1
- data/spec/controllers/protected_controller_spec.rb +1 -1
- data/spec/dummy/app/models/user.rb +1 -1
- data/spec/dummy/app/views/devise/confirmations/new.html.erb +12 -0
- data/spec/dummy/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
- data/spec/dummy/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
- data/spec/dummy/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
- data/spec/dummy/app/views/devise/passwords/edit.html.erb +16 -0
- data/spec/dummy/app/views/devise/passwords/new.html.erb +12 -0
- data/spec/dummy/app/views/devise/registrations/edit.html.erb +29 -0
- data/spec/dummy/app/views/devise/registrations/new.html.erb +18 -0
- data/spec/dummy/app/views/devise/sessions/new.html.erb +17 -0
- data/spec/dummy/app/views/devise/shared/_links.erb +25 -0
- data/spec/dummy/app/views/devise/unlocks/new.html.erb +12 -0
- data/spec/dummy/config/application.rb +1 -1
- data/spec/dummy/config/initializers/devise.rb +86 -42
- data/spec/dummy/config/locales/devise.en.yml +49 -48
- data/spec/dummy/config/routes.rb +1 -1
- data/spec/dummy/db/migrate/{20111014161437_create_devise_oauth2_providable_schema.rb → 20140306063000_create_devise_oauth2_providable_schema.rb} +14 -9
- data/spec/dummy/db/schema.rb +34 -28
- data/spec/factories/client_factory.rb +6 -4
- data/spec/factories/user_factory.rb +4 -4
- data/spec/integration/oauth2_authorization_token_grant_type_strategy_spec.rb +2 -2
- data/spec/integration/oauth2_password_grant_type_strategy_spec.rb +2 -2
- data/spec/integration/oauth2_refresh_token_grant_type_strategy_spec.rb +2 -2
- data/spec/lib/devise_oauth2_providable_spec.rb +1 -1
- data/spec/models/access_token_spec.rb +5 -5
- data/spec/models/authorization_code_spec.rb +2 -2
- data/spec/models/client_spec.rb +2 -2
- data/spec/models/refresh_token_spec.rb +3 -3
- data/spec/routing/authorizations_routing_spec.rb +1 -1
- data/spec/routing/tokens_routing_spec.rb +1 -1
- metadata +70 -45
- data/app/controllers/devise/oauth2_providable/tokens_controller.rb +0 -19
- data/app/models/devise/oauth2_providable/access_token.rb +0 -25
- data/app/models/devise/oauth2_providable/authorization_code.rb +0 -3
- data/app/models/devise/oauth2_providable/client.rb +0 -25
- data/app/views/devise/oauth2_providable/authorizations/new.html.erb +0 -4
- data/lib/devise/oauth2_providable/engine.rb +0 -16
- data/lib/devise/oauth2_providable/version.rb +0 -5
- data/lib/devise_oauth2_providable.rb +0 -41
- data/lib/generators/devise_oauth2/views_generator.rb +0 -7
data/spec/dummy/db/schema.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: UTF-8
|
1
2
|
# This file is auto-generated from the current state of the database. Instead
|
2
3
|
# of editing this file, please use the migrations feature of Active Record to
|
3
4
|
# incrementally modify your database, and then regenerate this schema definition.
|
@@ -8,12 +9,14 @@
|
|
8
9
|
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
9
10
|
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
10
11
|
#
|
11
|
-
# It's strongly recommended
|
12
|
+
# It's strongly recommended that you check this file into your version control system.
|
12
13
|
|
13
|
-
ActiveRecord::Schema.define(:
|
14
|
+
ActiveRecord::Schema.define(version: 20140306063000) do
|
14
15
|
|
15
|
-
create_table "oauth2_access_tokens", :
|
16
|
-
t.integer "
|
16
|
+
create_table "oauth2_access_tokens", force: true do |t|
|
17
|
+
t.integer "owner_id"
|
18
|
+
t.string "owner_type"
|
19
|
+
t.text "permissions"
|
17
20
|
t.integer "client_id"
|
18
21
|
t.integer "refresh_token_id"
|
19
22
|
t.string "token"
|
@@ -22,40 +25,43 @@ ActiveRecord::Schema.define(:version => 20111014161437) do
|
|
22
25
|
t.datetime "updated_at"
|
23
26
|
end
|
24
27
|
|
25
|
-
add_index "oauth2_access_tokens", ["client_id"], :
|
26
|
-
add_index "oauth2_access_tokens", ["expires_at"], :
|
27
|
-
add_index "oauth2_access_tokens", ["
|
28
|
-
add_index "oauth2_access_tokens", ["
|
28
|
+
add_index "oauth2_access_tokens", ["client_id"], name: "index_oauth2_access_tokens_on_client_id"
|
29
|
+
add_index "oauth2_access_tokens", ["expires_at"], name: "index_oauth2_access_tokens_on_expires_at"
|
30
|
+
add_index "oauth2_access_tokens", ["owner_id"], name: "index_oauth2_access_tokens_on_owner_id"
|
31
|
+
add_index "oauth2_access_tokens", ["token"], name: "index_oauth2_access_tokens_on_token", unique: true
|
29
32
|
|
30
|
-
create_table "oauth2_authorization_codes", :
|
31
|
-
t.integer "
|
33
|
+
create_table "oauth2_authorization_codes", force: true do |t|
|
34
|
+
t.integer "owner_id"
|
35
|
+
t.string "owner_type"
|
32
36
|
t.integer "client_id"
|
33
37
|
t.string "token"
|
34
38
|
t.datetime "expires_at"
|
35
|
-
t.string "redirect_uri"
|
36
39
|
t.datetime "created_at"
|
37
40
|
t.datetime "updated_at"
|
38
41
|
end
|
39
42
|
|
40
|
-
add_index "oauth2_authorization_codes", ["client_id"], :
|
41
|
-
add_index "oauth2_authorization_codes", ["expires_at"], :
|
42
|
-
add_index "oauth2_authorization_codes", ["
|
43
|
-
add_index "oauth2_authorization_codes", ["
|
43
|
+
add_index "oauth2_authorization_codes", ["client_id"], name: "index_oauth2_authorization_codes_on_client_id"
|
44
|
+
add_index "oauth2_authorization_codes", ["expires_at"], name: "index_oauth2_authorization_codes_on_expires_at"
|
45
|
+
add_index "oauth2_authorization_codes", ["owner_id"], name: "index_oauth2_authorization_codes_on_owner_id"
|
46
|
+
add_index "oauth2_authorization_codes", ["token"], name: "index_oauth2_authorization_codes_on_token", unique: true
|
44
47
|
|
45
|
-
create_table "oauth2_clients", :
|
46
|
-
t.
|
48
|
+
create_table "oauth2_clients", force: true do |t|
|
49
|
+
t.integer "owner_id"
|
50
|
+
t.string "owner_type"
|
51
|
+
t.text "default_permissions"
|
47
52
|
t.string "redirect_uri"
|
48
|
-
t.string "website"
|
49
53
|
t.string "identifier"
|
50
54
|
t.string "secret"
|
55
|
+
t.boolean "passthrough", default: false, null: false
|
51
56
|
t.datetime "created_at"
|
52
57
|
t.datetime "updated_at"
|
53
58
|
end
|
54
59
|
|
55
|
-
add_index "oauth2_clients", ["identifier"], :
|
60
|
+
add_index "oauth2_clients", ["identifier"], name: "index_oauth2_clients_on_identifier", unique: true
|
56
61
|
|
57
|
-
create_table "oauth2_refresh_tokens", :
|
58
|
-
t.integer "
|
62
|
+
create_table "oauth2_refresh_tokens", force: true do |t|
|
63
|
+
t.integer "owner_id"
|
64
|
+
t.string "owner_type"
|
59
65
|
t.integer "client_id"
|
60
66
|
t.string "token"
|
61
67
|
t.datetime "expires_at"
|
@@ -63,14 +69,14 @@ ActiveRecord::Schema.define(:version => 20111014161437) do
|
|
63
69
|
t.datetime "updated_at"
|
64
70
|
end
|
65
71
|
|
66
|
-
add_index "oauth2_refresh_tokens", ["client_id"], :
|
67
|
-
add_index "oauth2_refresh_tokens", ["expires_at"], :
|
68
|
-
add_index "oauth2_refresh_tokens", ["
|
69
|
-
add_index "oauth2_refresh_tokens", ["
|
72
|
+
add_index "oauth2_refresh_tokens", ["client_id"], name: "index_oauth2_refresh_tokens_on_client_id"
|
73
|
+
add_index "oauth2_refresh_tokens", ["expires_at"], name: "index_oauth2_refresh_tokens_on_expires_at"
|
74
|
+
add_index "oauth2_refresh_tokens", ["owner_id"], name: "index_oauth2_refresh_tokens_on_owner_id"
|
75
|
+
add_index "oauth2_refresh_tokens", ["token"], name: "index_oauth2_refresh_tokens_on_token", unique: true
|
70
76
|
|
71
|
-
create_table "users", :
|
72
|
-
t.string "email"
|
73
|
-
t.string "encrypted_password"
|
77
|
+
create_table "users", force: true do |t|
|
78
|
+
t.string "email"
|
79
|
+
t.string "encrypted_password"
|
74
80
|
t.datetime "created_at"
|
75
81
|
t.datetime "updated_at"
|
76
82
|
end
|
@@ -1,5 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :client, :class => 'Devise::Oauth2::Client' do
|
3
|
+
name 'test'
|
4
|
+
website 'http://localhost'
|
5
|
+
redirect_uri 'http://localhost:3000'
|
6
|
+
end
|
5
7
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
2
|
-
f.email 'ryan@socialcast.com'
|
3
|
-
f.password 'test'
|
4
|
-
end
|
1
|
+
#FactoryGirl.register_factory :user do |f|
|
2
|
+
# f.email 'ryan@socialcast.com'
|
3
|
+
# f.password 'test'
|
4
|
+
#end
|
@@ -20,8 +20,8 @@ describe Devise::Strategies::Oauth2AuthorizationCodeGrantTypeStrategy do
|
|
20
20
|
it { response.code.to_i.should == 200 }
|
21
21
|
it { response.content_type.should == 'application/json' }
|
22
22
|
it 'returns json' do
|
23
|
-
token = Devise::
|
24
|
-
refresh_token = Devise::
|
23
|
+
token = Devise::Oauth2::AccessToken.last
|
24
|
+
refresh_token = Devise::Oauth2::RefreshToken.last
|
25
25
|
expected = {
|
26
26
|
:token_type => 'bearer',
|
27
27
|
:expires_in => 899,
|
@@ -21,7 +21,7 @@ describe Devise::Strategies::Oauth2PasswordGrantTypeStrategy do
|
|
21
21
|
it { response.code.to_i.should == 200 }
|
22
22
|
it { response.content_type.should == 'application/json' }
|
23
23
|
it 'returns json' do
|
24
|
-
token = Devise::
|
24
|
+
token = Devise::Oauth2::AccessToken.last
|
25
25
|
expected = token.token_response
|
26
26
|
response.body.should match_json(expected)
|
27
27
|
end
|
@@ -44,7 +44,7 @@ describe Devise::Strategies::Oauth2PasswordGrantTypeStrategy do
|
|
44
44
|
it { response.content_type.should == 'application/json' }
|
45
45
|
it 'returns json' do
|
46
46
|
puts response.body
|
47
|
-
token = Devise::
|
47
|
+
token = Devise::Oauth2::AccessToken.last
|
48
48
|
expected = token.token_response
|
49
49
|
response.body.should match_json(expected)
|
50
50
|
end
|
@@ -20,7 +20,7 @@ describe Devise::Strategies::Oauth2RefreshTokenGrantTypeStrategy do
|
|
20
20
|
it { response.code.to_i.should == 200 }
|
21
21
|
it { response.content_type.should == 'application/json' }
|
22
22
|
it 'returns json' do
|
23
|
-
token = Devise::
|
23
|
+
token = Devise::Oauth2::AccessToken.last
|
24
24
|
refresh_token = @refresh_token
|
25
25
|
expected = {
|
26
26
|
:token_type => 'bearer',
|
@@ -75,7 +75,7 @@ describe Devise::Strategies::Oauth2RefreshTokenGrantTypeStrategy do
|
|
75
75
|
it { response.code.to_i.should == 400 }
|
76
76
|
it { response.content_type.should == 'application/json' }
|
77
77
|
it 'returns json' do
|
78
|
-
token = Devise::
|
78
|
+
token = Devise::Oauth2::AccessToken.last
|
79
79
|
refresh_token = @refresh_token
|
80
80
|
expected = {
|
81
81
|
:error => 'invalid_grant',
|
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Devise::
|
4
|
-
it { Devise::
|
3
|
+
describe Devise::Oauth2::AccessToken do
|
4
|
+
it { Devise::Oauth2::AccessToken.table_name.should == 'oauth2_access_tokens' }
|
5
5
|
|
6
6
|
describe 'basic access token instance' do
|
7
7
|
with :client
|
8
8
|
subject do
|
9
|
-
Devise::
|
9
|
+
Devise::Oauth2::AccessToken.create! :client => client
|
10
10
|
end
|
11
11
|
it { should validate_presence_of :token }
|
12
12
|
it { should validate_uniqueness_of :token }
|
@@ -31,7 +31,7 @@ describe Devise::Oauth2Providable::AccessToken do
|
|
31
31
|
@later = 1.year.from_now
|
32
32
|
@refresh_token = client.refresh_tokens.create!
|
33
33
|
@refresh_token.expires_at = @soon
|
34
|
-
@access_token = Devise::
|
34
|
+
@access_token = Devise::Oauth2::AccessToken.create! :client => client, :refresh_token => @refresh_token
|
35
35
|
end
|
36
36
|
focus 'should not set the access token expires_at to equal refresh token' do
|
37
37
|
@access_token.expires_at.should_not == @later
|
@@ -43,7 +43,7 @@ describe Devise::Oauth2Providable::AccessToken do
|
|
43
43
|
@soon = 1.minute.from_now
|
44
44
|
@refresh_token = client.refresh_tokens.create!
|
45
45
|
@refresh_token.expires_at = @soon
|
46
|
-
@access_token = Devise::
|
46
|
+
@access_token = Devise::Oauth2::AccessToken.create! :client => client, :refresh_token => @refresh_token
|
47
47
|
end
|
48
48
|
it 'should set the access token expires_at to equal refresh token' do
|
49
49
|
@access_token.expires_at.should == @soon
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Devise::
|
3
|
+
describe Devise::Oauth2::AuthorizationCode do
|
4
4
|
describe 'basic authorization code instance' do
|
5
5
|
with :client
|
6
6
|
subject do
|
7
|
-
Devise::
|
7
|
+
Devise::Oauth2::AuthorizationCode.create! :client => client
|
8
8
|
end
|
9
9
|
it { should validate_presence_of :token }
|
10
10
|
it { should validate_uniqueness_of :token }
|
data/spec/models/client_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Devise::
|
4
|
-
it { Devise::
|
3
|
+
describe Devise::Oauth2::Client do
|
4
|
+
it { Devise::Oauth2::Client.table_name.should == 'oauth2_clients' }
|
5
5
|
|
6
6
|
describe 'basic client instance' do
|
7
7
|
with :client
|
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Devise::
|
4
|
-
it { Devise::
|
3
|
+
describe Devise::Oauth2::RefreshToken do
|
4
|
+
it { Devise::Oauth2::RefreshToken.table_name.should == 'oauth2_refresh_tokens' }
|
5
5
|
|
6
6
|
describe 'basic refresh token instance' do
|
7
7
|
with :client
|
8
8
|
subject do
|
9
|
-
Devise::
|
9
|
+
Devise::Oauth2::RefreshToken.create! :client => client
|
10
10
|
end
|
11
11
|
it { should validate_presence_of :token }
|
12
12
|
it { should validate_uniqueness_of :token }
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Devise::
|
3
|
+
describe Devise::Oauth2::AuthorizationsController do
|
4
4
|
describe 'routing' do
|
5
5
|
pending 'routes POST /oauth2/authorizations' do
|
6
6
|
post('/oauth2/authorizations').should route_to('devise/oauth2_providable/authorizations#create')
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Devise::
|
3
|
+
describe Devise::Oauth2::TokensController do
|
4
4
|
describe 'routing' do
|
5
5
|
pending 'routes POST /oauth2/token' do
|
6
6
|
post('/oauth2/token').should route_to('devise/oauth2_providable/tokens#create')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise_oauth2_rails4
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Wheeler
|
@@ -42,112 +42,112 @@ dependencies:
|
|
42
42
|
name: rack-oauth2
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 0.11.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.11.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec-rails
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - '
|
59
|
+
- - '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 2.6.1
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - '
|
66
|
+
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 2.6.1
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: sqlite3
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - '
|
73
|
+
- - '>='
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: 1.3.5
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - '
|
80
|
+
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 1.3.5
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: shoulda-matchers
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - '
|
87
|
+
- - '>='
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 1.0.0
|
89
|
+
version: 1.0.0
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - '
|
94
|
+
- - '>='
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 1.0.0
|
96
|
+
version: 1.0.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: pry
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - '
|
101
|
+
- - '>='
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: 0.9.6.2
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - '
|
108
|
+
- - '>='
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 0.9.6.2
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: factory_girl
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - '
|
115
|
+
- - '>='
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: 2.2.0
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- - '
|
122
|
+
- - '>='
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: 2.2.0
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: factory_girl_rspec
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- - '
|
129
|
+
- - '>='
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: 0.0.1
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- - '
|
136
|
+
- - '>='
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: 0.0.1
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: rake
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- - '
|
143
|
+
- - '>='
|
144
144
|
- !ruby/object:Gem::Version
|
145
145
|
version: 0.9.2.2
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
|
-
- - '
|
150
|
+
- - '>='
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: 0.9.2.2
|
153
153
|
description: Rails 4 engine that adds OAuth2 Provider support to any application built
|
@@ -166,31 +166,34 @@ files:
|
|
166
166
|
- LICENSE.txt
|
167
167
|
- README.md
|
168
168
|
- Rakefile
|
169
|
-
- app/controllers/devise/
|
170
|
-
- app/controllers/devise/
|
171
|
-
- app/models/devise/
|
172
|
-
- app/models/devise/
|
173
|
-
- app/models/devise/
|
174
|
-
- app/models/devise/
|
175
|
-
- app/views/devise/
|
176
|
-
- app/views/devise/
|
177
|
-
- app/views/devise/
|
169
|
+
- app/controllers/devise/oauth2/authorizations_controller.rb
|
170
|
+
- app/controllers/devise/oauth2/tokens_controller.rb
|
171
|
+
- app/models/devise/oauth2/access_token.rb
|
172
|
+
- app/models/devise/oauth2/authorization_code.rb
|
173
|
+
- app/models/devise/oauth2/client.rb
|
174
|
+
- app/models/devise/oauth2/refresh_token.rb
|
175
|
+
- app/views/devise/oauth2/authorizations/_form.html.erb
|
176
|
+
- app/views/devise/oauth2/authorizations/error.html.erb
|
177
|
+
- app/views/devise/oauth2/authorizations/new.html.erb
|
178
178
|
- config/routes.rb
|
179
179
|
- db/migrate/20111014160714_create_devise_oauth2_providable_schema.rb
|
180
|
-
-
|
181
|
-
- lib/devise/
|
182
|
-
- lib/devise/
|
183
|
-
- lib/devise/
|
184
|
-
- lib/devise/
|
185
|
-
- lib/devise/
|
186
|
-
- lib/devise/
|
187
|
-
- lib/devise/
|
188
|
-
- lib/devise/
|
189
|
-
- lib/devise/
|
190
|
-
- lib/devise/
|
191
|
-
- lib/devise/
|
192
|
-
- lib/
|
193
|
-
- lib/
|
180
|
+
- devise_oauth2_rails4.gemspec
|
181
|
+
- lib/devise/oauth2/engine.rb
|
182
|
+
- lib/devise/oauth2/expirable_token.rb
|
183
|
+
- lib/devise/oauth2/models/oauth2_authorization_code_grantable.rb
|
184
|
+
- lib/devise/oauth2/models/oauth2_password_grantable.rb
|
185
|
+
- lib/devise/oauth2/models/oauth2_providable.rb
|
186
|
+
- lib/devise/oauth2/models/oauth2_refresh_token_grantable.rb
|
187
|
+
- lib/devise/oauth2/strategies/oauth2_authorization_code_grant_type_strategy.rb
|
188
|
+
- lib/devise/oauth2/strategies/oauth2_grant_type_strategy.rb
|
189
|
+
- lib/devise/oauth2/strategies/oauth2_password_grant_type_strategy.rb
|
190
|
+
- lib/devise/oauth2/strategies/oauth2_providable_strategy.rb
|
191
|
+
- lib/devise/oauth2/strategies/oauth2_refresh_token_grant_type_strategy.rb
|
192
|
+
- lib/devise/oauth2/version.rb
|
193
|
+
- lib/devise_oauth2_rails4.rb
|
194
|
+
- lib/generators/devise/oauth2/migrations_generator.rb
|
195
|
+
- lib/generators/devise/oauth2/views_generator.rb
|
196
|
+
- rails/tasks/engine.rake
|
194
197
|
- script/rails
|
195
198
|
- spec/controllers/authorizations_controller_spec.rb
|
196
199
|
- spec/controllers/protected_controller_spec.rb
|
@@ -203,6 +206,17 @@ files:
|
|
203
206
|
- spec/dummy/app/mailers/.gitkeep
|
204
207
|
- spec/dummy/app/models/.gitkeep
|
205
208
|
- spec/dummy/app/models/user.rb
|
209
|
+
- spec/dummy/app/views/devise/confirmations/new.html.erb
|
210
|
+
- spec/dummy/app/views/devise/mailer/confirmation_instructions.html.erb
|
211
|
+
- spec/dummy/app/views/devise/mailer/reset_password_instructions.html.erb
|
212
|
+
- spec/dummy/app/views/devise/mailer/unlock_instructions.html.erb
|
213
|
+
- spec/dummy/app/views/devise/passwords/edit.html.erb
|
214
|
+
- spec/dummy/app/views/devise/passwords/new.html.erb
|
215
|
+
- spec/dummy/app/views/devise/registrations/edit.html.erb
|
216
|
+
- spec/dummy/app/views/devise/registrations/new.html.erb
|
217
|
+
- spec/dummy/app/views/devise/sessions/new.html.erb
|
218
|
+
- spec/dummy/app/views/devise/shared/_links.erb
|
219
|
+
- spec/dummy/app/views/devise/unlocks/new.html.erb
|
206
220
|
- spec/dummy/app/views/layouts/application.html.erb
|
207
221
|
- spec/dummy/config.ru
|
208
222
|
- spec/dummy/config/application.rb
|
@@ -223,7 +237,7 @@ files:
|
|
223
237
|
- spec/dummy/config/locales/en.yml
|
224
238
|
- spec/dummy/config/routes.rb
|
225
239
|
- spec/dummy/db/migrate/20111014142838_create_users.rb
|
226
|
-
- spec/dummy/db/migrate/
|
240
|
+
- spec/dummy/db/migrate/20140306063000_create_devise_oauth2_providable_schema.rb
|
227
241
|
- spec/dummy/db/schema.rb
|
228
242
|
- spec/dummy/lib/assets/.gitkeep
|
229
243
|
- spec/dummy/log/.gitkeep
|
@@ -266,7 +280,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
266
280
|
- !ruby/object:Gem::Version
|
267
281
|
version: '0'
|
268
282
|
requirements: []
|
269
|
-
rubyforge_project:
|
283
|
+
rubyforge_project: devise_oauth2_rails4
|
270
284
|
rubygems_version: 2.2.2
|
271
285
|
signing_key:
|
272
286
|
specification_version: 4
|
@@ -283,6 +297,17 @@ test_files:
|
|
283
297
|
- spec/dummy/app/mailers/.gitkeep
|
284
298
|
- spec/dummy/app/models/.gitkeep
|
285
299
|
- spec/dummy/app/models/user.rb
|
300
|
+
- spec/dummy/app/views/devise/confirmations/new.html.erb
|
301
|
+
- spec/dummy/app/views/devise/mailer/confirmation_instructions.html.erb
|
302
|
+
- spec/dummy/app/views/devise/mailer/reset_password_instructions.html.erb
|
303
|
+
- spec/dummy/app/views/devise/mailer/unlock_instructions.html.erb
|
304
|
+
- spec/dummy/app/views/devise/passwords/edit.html.erb
|
305
|
+
- spec/dummy/app/views/devise/passwords/new.html.erb
|
306
|
+
- spec/dummy/app/views/devise/registrations/edit.html.erb
|
307
|
+
- spec/dummy/app/views/devise/registrations/new.html.erb
|
308
|
+
- spec/dummy/app/views/devise/sessions/new.html.erb
|
309
|
+
- spec/dummy/app/views/devise/shared/_links.erb
|
310
|
+
- spec/dummy/app/views/devise/unlocks/new.html.erb
|
286
311
|
- spec/dummy/app/views/layouts/application.html.erb
|
287
312
|
- spec/dummy/config.ru
|
288
313
|
- spec/dummy/config/application.rb
|
@@ -303,7 +328,7 @@ test_files:
|
|
303
328
|
- spec/dummy/config/locales/en.yml
|
304
329
|
- spec/dummy/config/routes.rb
|
305
330
|
- spec/dummy/db/migrate/20111014142838_create_users.rb
|
306
|
-
- spec/dummy/db/migrate/
|
331
|
+
- spec/dummy/db/migrate/20140306063000_create_devise_oauth2_providable_schema.rb
|
307
332
|
- spec/dummy/db/schema.rb
|
308
333
|
- spec/dummy/lib/assets/.gitkeep
|
309
334
|
- spec/dummy/log/.gitkeep
|
@@ -1,19 +0,0 @@
|
|
1
|
-
class Devise::Oauth2Providable::TokensController < ApplicationController
|
2
|
-
before_filter :authenticate_user!
|
3
|
-
skip_before_filter :verify_authenticity_token, :only => :create
|
4
|
-
|
5
|
-
def create
|
6
|
-
@refresh_token = oauth2_current_refresh_token || oauth2_current_client.refresh_tokens.create!(:user => current_user)
|
7
|
-
@access_token = @refresh_token.access_tokens.create!(:client => oauth2_current_client, :user => current_user)
|
8
|
-
render :json => @access_token.token_response
|
9
|
-
end
|
10
|
-
|
11
|
-
private
|
12
|
-
|
13
|
-
def oauth2_current_client
|
14
|
-
env[Devise::Oauth2Providable::CLIENT_ENV_REF]
|
15
|
-
end
|
16
|
-
def oauth2_current_refresh_token
|
17
|
-
env[Devise::Oauth2Providable::REFRESH_TOKEN_ENV_REF]
|
18
|
-
end
|
19
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
class Devise::Oauth2Providable::AccessToken < ActiveRecord::Base
|
2
|
-
expires_according_to :access_token_expires_in
|
3
|
-
|
4
|
-
before_validation :restrict_expires_at, :on => :create, :if => :refresh_token
|
5
|
-
belongs_to :refresh_token
|
6
|
-
|
7
|
-
# Deprecated
|
8
|
-
#attr_accessible :refresh_token
|
9
|
-
|
10
|
-
def token_response
|
11
|
-
response = {
|
12
|
-
:access_token => token,
|
13
|
-
:token_type => 'bearer',
|
14
|
-
:expires_in => expires_in
|
15
|
-
}
|
16
|
-
response[:refresh_token] = refresh_token.token if refresh_token
|
17
|
-
response
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def restrict_expires_at
|
23
|
-
self.expires_at = [self.expires_at, refresh_token.expires_at].compact.min
|
24
|
-
end
|
25
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
class Devise::Oauth2Providable::Client < ActiveRecord::Base
|
2
|
-
has_many :access_tokens
|
3
|
-
has_many :refresh_tokens
|
4
|
-
has_many :authorization_codes
|
5
|
-
|
6
|
-
before_validation :init_identifier, :on => :create, :unless => :identifier?
|
7
|
-
before_validation :init_secret, :on => :create, :unless => :secret?
|
8
|
-
validates :website, :secret, :presence => true
|
9
|
-
validates :name, :presence => true, :uniqueness => true
|
10
|
-
validates :identifier, :presence => true, :uniqueness => true
|
11
|
-
|
12
|
-
# Deprecated
|
13
|
-
#attr_accessible :name, :website, :redirect_uri
|
14
|
-
|
15
|
-
private
|
16
|
-
|
17
|
-
def init_identifier
|
18
|
-
self.identifier = Devise::Oauth2Providable.random_id
|
19
|
-
end
|
20
|
-
|
21
|
-
def init_secret
|
22
|
-
self.secret = Devise::Oauth2Providable.random_id
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
@@ -1,4 +0,0 @@
|
|
1
|
-
<h2><%= link_to @client.name, @client.website %> is requesting permission to access your resources.</h2>
|
2
|
-
|
3
|
-
<%= render 'devise/oauth2_providable/authorizations/form', :client => @client, :response_type => @response_type, :redirect_uri => @redirect_uri, :action => :approve %>
|
4
|
-
<%= render 'devise/oauth2_providable/authorizations/form', :client => @client, :response_type => @response_type, :redirect_uri => @redirect_uri, :action => :deny %>
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module Devise
|
2
|
-
module Oauth2Providable
|
3
|
-
class Engine < Rails::Engine
|
4
|
-
config.devise_oauth2_providable = ActiveSupport::OrderedOptions.new
|
5
|
-
config.devise_oauth2_providable.access_token_expires_in = 15.minutes
|
6
|
-
config.devise_oauth2_providable.refresh_token_expires_in = 1.month
|
7
|
-
config.devise_oauth2_providable.authorization_code_expires_in = 1.minute
|
8
|
-
|
9
|
-
engine_name 'oauth2'
|
10
|
-
isolate_namespace Devise::Oauth2Providable
|
11
|
-
initializer "devise_oauth2_providable.initialize_application", :before=> :load_config_initializers do |app|
|
12
|
-
app.config.filter_parameters << :client_secret
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|