doorkeeper_sso 0.4.3 → 0.4.6
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/app/controllers/sso/sessions_controller.rb +6 -5
- data/app/models/sso/client.rb +10 -0
- data/app/models/sso/session.rb +3 -5
- data/app/serializers/sso/client_serializer.rb +20 -0
- data/app/serializers/sso/session_serializer.rb +2 -1
- data/db/migrate/20151030064515_add_device_information_to_sso_clients.rb +16 -0
- data/db/migrate/20151104090509_remove_group_id_from_sessions.rb +7 -0
- data/lib/doorkeeper_sso.rb +1 -0
- data/lib/sso/version.rb +1 -1
- data/spec/api/schemas/session.json +6 -2
- data/spec/controllers/sso/sessions_controller_spec.rb +1 -1
- data/spec/models/sso/client_spec.rb +8 -0
- data/spec/models/sso/session_spec.rb +18 -4
- data/spec/request/oauth/authorization_code_spec.rb +39 -50
- data/spec/support/shoulda_matchers.rb +6 -0
- data/spec/test_app/db/schema.rb +7 -5
- metadata +7 -3
- data/lib/sso/engine.rb.orig +0 -71
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2bd334100cf66c77b3f645412a863eabdc1662d2
|
4
|
+
data.tar.gz: dc41d49dbc70d8372eafd3f3b4d4992d46f70ec7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 733ec62c0762c923ccd25322e5670641f531850fddb84778a408c1d45bdac1b19c928db1114caeb296391e57bb4b2ec26f69cd43414ba53face2da3ab5cdd606
|
7
|
+
data.tar.gz: efdd2637c8a3b766f47766d985e7ffab1d1ee2643e2299b0b156dc049c474de6970983bf3e66e384742fff00915285100f24f9b877e94dc84e80d7dfe1ad94a7
|
@@ -15,20 +15,21 @@ module Sso
|
|
15
15
|
# Sessionless (iphone/outsider)
|
16
16
|
# Returns passport
|
17
17
|
def show
|
18
|
-
@
|
19
|
-
render json: @
|
18
|
+
@client = current_client
|
19
|
+
render json: @client, serializer: Sso::ClientSerializer
|
20
20
|
end
|
21
21
|
|
22
22
|
# Passport exchange
|
23
23
|
# Passport Strategy first exchange
|
24
24
|
# Insider : Client information from Apps should always be trusted
|
25
25
|
def create
|
26
|
-
@
|
26
|
+
@client = current_client
|
27
|
+
@session = @client.session
|
27
28
|
debug { "SessionsController#create - #{@session.inspect}"}
|
28
29
|
raise "ResourceOwner from token != session.owner" if doorkeeper_token.resource_owner_id != @session.owner.id
|
29
30
|
|
30
|
-
|
31
|
-
render json: @
|
31
|
+
@client.update_attributes!(client_params)
|
32
|
+
render json: @client, status: :created, serializer: Sso::ClientSerializer
|
32
33
|
end
|
33
34
|
|
34
35
|
################################################################################
|
data/app/models/sso/client.rb
CHANGED
@@ -10,6 +10,11 @@ module Sso
|
|
10
10
|
validates :access_grant_id, uniqueness: { allow_nil: true }
|
11
11
|
validates :access_token_id, uniqueness: { allow_nil: true }
|
12
12
|
|
13
|
+
scope :with_access_grant, -> { where.not(access_grant: nil) }
|
14
|
+
scope :with_access_token, -> { where.not(access_token: nil) }
|
15
|
+
|
16
|
+
before_save :ensure_random_token
|
17
|
+
|
13
18
|
class << self
|
14
19
|
def find_by_grant_token(token)
|
15
20
|
find_by(access_grant: ::Doorkeeper::AccessGrant.by_token(token))
|
@@ -29,5 +34,10 @@ module Sso
|
|
29
34
|
return false unless oauth_token = ::Doorkeeper::AccessToken.by_token(token)
|
30
35
|
update(access_token_id: oauth_token.id, application_id: oauth_token.application.id)
|
31
36
|
end
|
37
|
+
|
38
|
+
private
|
39
|
+
def ensure_random_token
|
40
|
+
self.random_token ||= SecureRandom.hex
|
41
|
+
end
|
32
42
|
end
|
33
43
|
end
|
data/app/models/sso/session.rb
CHANGED
@@ -16,7 +16,6 @@ module Sso
|
|
16
16
|
scope :master, -> { where(application_id: nil) }
|
17
17
|
|
18
18
|
before_validation :ensure_secret
|
19
|
-
before_validation :ensure_group_id
|
20
19
|
before_validation :ensure_activity_at
|
21
20
|
|
22
21
|
class << self
|
@@ -57,6 +56,9 @@ module Sso
|
|
57
56
|
end
|
58
57
|
|
59
58
|
def logout
|
59
|
+
clients.with_access_token.each do |c|
|
60
|
+
c.access_token.revoke
|
61
|
+
end
|
60
62
|
update revoked_at: Time.current, revoke_reason: "logout"
|
61
63
|
end
|
62
64
|
|
@@ -66,10 +68,6 @@ module Sso
|
|
66
68
|
self.secret ||= SecureRandom.uuid
|
67
69
|
end
|
68
70
|
|
69
|
-
def ensure_group_id
|
70
|
-
self.group_id ||= SecureRandom.uuid
|
71
|
-
end
|
72
|
-
|
73
71
|
def ensure_activity_at
|
74
72
|
self.activity_at ||= Time.current
|
75
73
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Sso
|
2
|
+
class ClientSerializer < ActiveModel::Serializer
|
3
|
+
delegate :id, :active?, :revoked_at, :revoke_reason, :secret, to: :session
|
4
|
+
|
5
|
+
attribute :id, :key => :client_id
|
6
|
+
attributes :id, :active?, :revoked_at, :revoke_reason, :secret, :random_token
|
7
|
+
|
8
|
+
|
9
|
+
belongs_to :owner, serializer: Sso::OwnerSerializer # WTH : hack to load owner using serializer
|
10
|
+
|
11
|
+
def session
|
12
|
+
object.session
|
13
|
+
end
|
14
|
+
|
15
|
+
# WTH : i dont get why i have to do loops to customize my json output
|
16
|
+
def owner
|
17
|
+
session.owner
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
module Sso
|
2
2
|
class SessionSerializer < ActiveModel::Serializer
|
3
|
-
attributes :id, :active?, :
|
3
|
+
attributes :id, :active?, :revoked_at, :revoke_reason, :secret
|
4
4
|
|
5
|
+
has_many :clients
|
5
6
|
belongs_to :owner, serializer: Sso::OwnerSerializer
|
6
7
|
end
|
7
8
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class AddDeviceInformationToSsoClients < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
change_table :sso_clients do |t|
|
4
|
+
t.string "device_os"
|
5
|
+
t.string "device_os_version"
|
6
|
+
t.string "device_model"
|
7
|
+
t.string "random_token"
|
8
|
+
end
|
9
|
+
|
10
|
+
Sso::Client.find_each do |client|
|
11
|
+
client.save
|
12
|
+
end
|
13
|
+
|
14
|
+
change_column :sso_clients, :random_token, :string, :null => true
|
15
|
+
end
|
16
|
+
end
|
data/lib/doorkeeper_sso.rb
CHANGED
data/lib/sso/version.rb
CHANGED
@@ -1,17 +1,21 @@
|
|
1
1
|
{
|
2
2
|
"type": "object",
|
3
3
|
"required" : [
|
4
|
+
"client_id",
|
4
5
|
"id",
|
5
6
|
"active?",
|
6
7
|
"secret",
|
7
|
-
"owner"
|
8
|
+
"owner",
|
9
|
+
"random_token"
|
8
10
|
],
|
9
11
|
"properties": {
|
12
|
+
"client_id" : { "type" : "string" },
|
10
13
|
"id" : { "type" : "string" },
|
11
14
|
"active?" : { "type" : "boolean" },
|
12
15
|
"revoked_at" : { "type": ["string", "null"], "format": "date-time" },
|
13
16
|
"revoke_reason" : { "type": ["string", "null"] },
|
14
17
|
"secret" : { "type" : "string" },
|
18
|
+
"random_token" : { "type" : "string" },
|
15
19
|
"owner" : {
|
16
20
|
"type" : "object",
|
17
21
|
"required" : [
|
@@ -32,4 +36,4 @@
|
|
32
36
|
}
|
33
37
|
}
|
34
38
|
}
|
35
|
-
}
|
39
|
+
}
|
@@ -59,7 +59,7 @@ RSpec.describe Sso::SessionsController, :type => :controller do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
it { expect(response).to have_http_status(:ok) }
|
62
|
-
it { expect(assigns(:
|
62
|
+
it { expect(assigns(:client)).to eq client }
|
63
63
|
it { expect(response).to match_response_schema("session") }
|
64
64
|
end
|
65
65
|
end
|
@@ -57,4 +57,12 @@ RSpec.describe Sso::Client, :type => :model do
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
+
describe "#ensure_random_token" do
|
61
|
+
subject!(:client) { Fabricate('Sso::Client', session: session,
|
62
|
+
application_id: application.id,
|
63
|
+
access_grant_id: access_grant.id) }
|
64
|
+
|
65
|
+
it { expect(client.random_token).not_to be_blank }
|
66
|
+
end
|
67
|
+
|
60
68
|
end
|
@@ -92,18 +92,32 @@ RSpec.describe Sso::Session, :type => :model do
|
|
92
92
|
|
93
93
|
context "(failure)" do
|
94
94
|
it "raises exception" do
|
95
|
-
expect { Sso::Session.generate_master(nil) }.to raise_exception
|
95
|
+
expect { Sso::Session.generate_master(nil, nil) }.to raise_exception(ActiveRecord::RecordInvalid)
|
96
96
|
end
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
100
|
describe "::logout" do
|
101
|
-
let
|
102
|
-
let
|
101
|
+
let(:user) { Fabricate(:user) }
|
102
|
+
let(:access_token) { Fabricate('Doorkeeper::AccessToken',
|
103
|
+
resource_owner_id: user.id) }
|
104
|
+
let(:access_grant) { Fabricate('Doorkeeper::AccessGrant',
|
105
|
+
application_id: nil,
|
106
|
+
resource_owner_id: user.id,
|
107
|
+
redirect_uri: 'http://localhost:3002/oauth/callback'
|
108
|
+
) }
|
109
|
+
|
110
|
+
let(:sso_session) { Fabricate('Sso::Session', owner: user) }
|
111
|
+
let!(:sso_client) { Fabricate('Sso::Client', session: sso_session,
|
112
|
+
access_token_id: access_token.id,
|
113
|
+
access_grant_id: access_grant.id) }
|
103
114
|
|
104
|
-
it "revokes session" do
|
115
|
+
it "revokes session and access token" do
|
105
116
|
Sso::Session.logout(sso_session.id)
|
106
117
|
new_session = Sso::Session.find(sso_session.id)
|
118
|
+
|
119
|
+
expect(new_session.clients.count).to eq(2) # Should have 2 clients for a session
|
120
|
+
expect(new_session.clients.with_access_token.first.access_token.revoked_at).not_to be_blank # Client access token should be revoked
|
107
121
|
expect(new_session.revoked_at).not_to be_blank
|
108
122
|
expect(new_session.revoke_reason).to eq("logout")
|
109
123
|
end
|
@@ -15,8 +15,8 @@ RSpec.describe 'OAuth 2.0 Authorization Grant Flow', type: :request, db: true do
|
|
15
15
|
let(:access_token_count) { ::Doorkeeper::AccessToken.count }
|
16
16
|
let(:grant_count) { ::Doorkeeper::AccessGrant.count }
|
17
17
|
|
18
|
-
let(:
|
19
|
-
let(:
|
18
|
+
let(:latest_session) { ::Sso::Session.last }
|
19
|
+
let(:session_count) { ::Sso::Session.count }
|
20
20
|
|
21
21
|
before do
|
22
22
|
get_via_redirect '/oauth/authorize', grant_params
|
@@ -27,32 +27,40 @@ RSpec.describe 'OAuth 2.0 Authorization Grant Flow', type: :request, db: true do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
describe 'Logging in' do
|
30
|
-
before do
|
31
|
-
post '/
|
30
|
+
before(:each) do
|
31
|
+
post '/users/sign_in', user: { email: user.email, password: "bumblebee" }
|
32
32
|
follow_redirect!
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'redirects to the application callback including the Grant Token' do
|
36
|
-
#
|
37
|
-
expect(response.body).to eq 1 #redirect_to "#{doorkeeper_application.redirect_uri}?code=#{latest_grant.token}&state=some_random_string"
|
36
|
+
is_expected.to redirect_to "#{doorkeeper_application.redirect_uri}?code=#{latest_grant.token}&state=some_random_string"
|
38
37
|
end
|
39
38
|
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
it 'generates a master session' do
|
40
|
+
expect(session_count).to eq 1
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'generates a master client and a child client' do
|
44
|
+
expect(latest_session.clients.count).to eq 2
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'child client have grant token info attached to it' do
|
48
|
+
expect(latest_session.clients.with_access_grant.count).to eq 1
|
49
|
+
expect(latest_session.clients.with_access_grant.first.access_grant_id).to eq latest_grant.id
|
50
|
+
end
|
43
51
|
|
44
|
-
|
45
|
-
|
46
|
-
|
52
|
+
it 'does not generate multiple authorization grants' do
|
53
|
+
expect(grant_count).to eq 1
|
54
|
+
end
|
47
55
|
|
48
|
-
|
56
|
+
context 'Exchanging the Authorization Grant for an Access Token' do
|
49
57
|
let(:grant) { ::Rack::Utils.parse_query(URI.parse(response.location).query).fetch('code') }
|
50
58
|
let(:grant_type) { :authorization_code }
|
51
|
-
let(:
|
59
|
+
let(:token_params) { { client_id: doorkeeper_application.uid, client_secret: doorkeeper_application.secret, code: grant, grant_type: grant_type, redirect_uri: redirect_uri } }
|
52
60
|
let(:token) { JSON.parse(response.body).fetch 'access_token' }
|
53
61
|
|
54
|
-
before do
|
55
|
-
post '/oauth/token',
|
62
|
+
before(:each) do
|
63
|
+
post '/oauth/token', token_params
|
56
64
|
end
|
57
65
|
|
58
66
|
it 'succeeds' do
|
@@ -67,52 +75,33 @@ RSpec.describe 'OAuth 2.0 Authorization Grant Flow', type: :request, db: true do
|
|
67
75
|
expect(result['access_token']).to eq latest_access_token.token
|
68
76
|
end
|
69
77
|
|
70
|
-
it '
|
71
|
-
expect(
|
78
|
+
it 'does not generate multiple master session' do
|
79
|
+
expect(session_count).to eq 1
|
72
80
|
end
|
73
81
|
|
74
|
-
it 'does not generate
|
75
|
-
expect(
|
82
|
+
it 'does not generate another client' do
|
83
|
+
expect(latest_session.clients.count).to eq 2
|
76
84
|
end
|
77
85
|
|
78
|
-
it '
|
79
|
-
expect(
|
86
|
+
it 'updates child client with the access token info' do
|
87
|
+
expect(latest_session.clients.with_access_token.first.access_token_id).to eq latest_access_token.id
|
80
88
|
end
|
81
89
|
|
82
|
-
|
83
|
-
|
84
|
-
end
|
90
|
+
context 'Updates the child client with user info' do
|
91
|
+
let(:client_params) { { access_token: token, ip: "127.0.0.1", agent: "curl/7.43.0" } }
|
85
92
|
|
86
|
-
|
87
|
-
|
88
|
-
SSO.config.passport_chip_key = SecureRandom.hex
|
89
|
-
post '/oauth/sso/v1/passports', access_token: token
|
93
|
+
before(:each) do
|
94
|
+
post '/sso/sessions', client_params
|
90
95
|
end
|
91
96
|
|
92
97
|
it 'succeeds' do
|
93
|
-
expect(response.status).to eq
|
94
|
-
end
|
95
|
-
|
96
|
-
it 'gets the passport' do
|
97
|
-
expect(result['passport']).to be_present
|
98
|
-
end
|
99
|
-
|
100
|
-
it 'is the passport for that access token' do
|
101
|
-
expect(result['passport']['id']).to eq latest_passport.id
|
102
|
-
expect(latest_passport.oauth_access_token_id).to eq latest_access_token.id
|
103
|
-
end
|
104
|
-
|
105
|
-
pending 'is an outsider passport' do
|
106
|
-
expect(latest_passport).to_not be_insider
|
98
|
+
expect(response.status).to eq 201
|
107
99
|
end
|
108
100
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
it 'is an insider passport' do
|
114
|
-
expect(latest_passport).to be_insider
|
115
|
-
end
|
101
|
+
it 'child client is updated with user info' do
|
102
|
+
child_client = latest_session.clients.with_access_token.first
|
103
|
+
expect(child_client.ip).to eq "127.0.0.1"
|
104
|
+
expect(child_client.agent).to eq "curl/7.43.0"
|
116
105
|
end
|
117
106
|
end
|
118
107
|
|
data/spec/test_app/db/schema.rb
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# It's strongly recommended that you check this file into your version control system.
|
13
13
|
|
14
|
-
ActiveRecord::Schema.define(version:
|
14
|
+
ActiveRecord::Schema.define(version: 20151104090509) do
|
15
15
|
|
16
16
|
# These are extensions that must be enabled in order to support this database
|
17
17
|
enable_extension "plpgsql"
|
@@ -78,8 +78,12 @@ ActiveRecord::Schema.define(version: 20150603145730) do
|
|
78
78
|
t.string "location"
|
79
79
|
t.string "device"
|
80
80
|
t.datetime "activity_at"
|
81
|
-
t.datetime "created_at",
|
82
|
-
t.datetime "updated_at",
|
81
|
+
t.datetime "created_at", null: false
|
82
|
+
t.datetime "updated_at", null: false
|
83
|
+
t.string "device_os"
|
84
|
+
t.string "device_os_version"
|
85
|
+
t.string "device_model"
|
86
|
+
t.string "random_token", null: false
|
83
87
|
end
|
84
88
|
|
85
89
|
add_index "sso_clients", ["access_grant_id"], name: "index_sso_clients_on_access_grant_id", using: :btree
|
@@ -97,7 +101,6 @@ ActiveRecord::Schema.define(version: 20150603145730) do
|
|
97
101
|
t.integer "access_token_id"
|
98
102
|
t.integer "application_id"
|
99
103
|
t.integer "owner_id", null: false
|
100
|
-
t.string "group_id", null: false
|
101
104
|
t.string "secret", null: false
|
102
105
|
t.datetime "activity_at", null: false
|
103
106
|
t.datetime "revoked_at"
|
@@ -109,7 +112,6 @@ ActiveRecord::Schema.define(version: 20150603145730) do
|
|
109
112
|
add_index "sso_sessions", ["access_grant_id"], name: "index_sso_sessions_on_access_grant_id", using: :btree
|
110
113
|
add_index "sso_sessions", ["access_token_id"], name: "index_sso_sessions_on_access_token_id", using: :btree
|
111
114
|
add_index "sso_sessions", ["application_id"], name: "index_sso_sessions_on_application_id", using: :btree
|
112
|
-
add_index "sso_sessions", ["group_id"], name: "index_sso_sessions_on_group_id", using: :btree
|
113
115
|
add_index "sso_sessions", ["owner_id", "access_token_id", "application_id"], name: "one_access_token_per_owner", unique: true, where: "((revoked_at IS NULL) AND (access_token_id IS NOT NULL))", using: :btree
|
114
116
|
add_index "sso_sessions", ["owner_id"], name: "index_sso_sessions_on_owner_id", using: :btree
|
115
117
|
add_index "sso_sessions", ["revoke_reason"], name: "index_sso_sessions_on_revoke_reason", using: :btree
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: doorkeeper_sso
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Wong
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: warden
|
@@ -338,6 +338,7 @@ files:
|
|
338
338
|
- app/models/sso/notifier.rb
|
339
339
|
- app/models/sso/pingback.rb
|
340
340
|
- app/models/sso/session.rb
|
341
|
+
- app/serializers/sso/client_serializer.rb
|
341
342
|
- app/serializers/sso/owner_serializer.rb
|
342
343
|
- app/serializers/sso/session_serializer.rb
|
343
344
|
- app/views/layouts/doorkeeper/admin.html.erb
|
@@ -348,6 +349,8 @@ files:
|
|
348
349
|
- db/migrate/20150521142926_create_sso_clients.rb
|
349
350
|
- db/migrate/20150521165143_remove_extra_columns_from_sso_sessions.rb
|
350
351
|
- db/migrate/20150603145730_add_pingback_uri_to_doorkeeper_applications.rb
|
352
|
+
- db/migrate/20151030064515_add_device_information_to_sso_clients.rb
|
353
|
+
- db/migrate/20151104090509_remove_group_id_from_sessions.rb
|
351
354
|
- lib/doorkeeper_sso.rb
|
352
355
|
- lib/sso.rb
|
353
356
|
- lib/sso/doorkeeper/access_grant_mixin.rb
|
@@ -361,7 +364,6 @@ files:
|
|
361
364
|
- lib/sso/doorkeeper/oauth/authorization_code_request_mixin.rb
|
362
365
|
- lib/sso/doorkeeper/oauth/base.rb
|
363
366
|
- lib/sso/engine.rb
|
364
|
-
- lib/sso/engine.rb.orig
|
365
367
|
- lib/sso/logging.rb
|
366
368
|
- lib/sso/version.rb
|
367
369
|
- lib/sso/warden/hooks/before_logout.rb
|
@@ -393,6 +395,7 @@ files:
|
|
393
395
|
- spec/support/database_cleaner.rb
|
394
396
|
- spec/support/devise.rb
|
395
397
|
- spec/support/fabrication.rb
|
398
|
+
- spec/support/shoulda_matchers.rb
|
396
399
|
- spec/support/vcr.rb
|
397
400
|
- spec/test_app/Rakefile
|
398
401
|
- spec/test_app/app/controllers/application_controller.rb
|
@@ -452,6 +455,7 @@ test_files:
|
|
452
455
|
- spec/support/database_cleaner.rb
|
453
456
|
- spec/support/devise.rb
|
454
457
|
- spec/support/fabrication.rb
|
458
|
+
- spec/support/shoulda_matchers.rb
|
455
459
|
- spec/support/vcr.rb
|
456
460
|
- spec/test_app/app/controllers/application_controller.rb
|
457
461
|
- spec/test_app/app/models/user.rb
|
data/lib/sso/engine.rb.orig
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
module Sso
|
2
|
-
class Engine < ::Rails::Engine
|
3
|
-
isolate_namespace Sso
|
4
|
-
|
5
|
-
# New test framework integration
|
6
|
-
config.generators do |g|
|
7
|
-
g.test_framework :rspec,
|
8
|
-
:fixtures => true,
|
9
|
-
:view_specs => false,
|
10
|
-
:helper_specs => false,
|
11
|
-
:routing_specs => false,
|
12
|
-
:controller_specs => true,
|
13
|
-
:request_specs => false
|
14
|
-
g.fixture_replacement :fabrication
|
15
|
-
end
|
16
|
-
|
17
|
-
initializer :append_migrations do |app|
|
18
|
-
unless app.root.to_s.match root.to_s
|
19
|
-
config.paths["db/migrate"].expanded.each do |expanded_path|
|
20
|
-
app.config.paths["db/migrate"] << expanded_path
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
config.before_initialize do
|
26
|
-
[::Sso::Logging, ::Wisper::Publisher].each do |klass|
|
27
|
-
::Doorkeeper::OAuth::RequestConcern.send(:include, klass)
|
28
|
-
::Doorkeeper::OAuth::Authorization::Code.send(:include, klass)
|
29
|
-
::Doorkeeper::OAuth::Authorization::Token.send(:include, klass)
|
30
|
-
end
|
31
|
-
|
32
|
-
::Doorkeeper::ApplicationMetalController.send(:include, ::AbstractController::Callbacks)
|
33
|
-
|
34
|
-
# need a better way to fix this
|
35
|
-
::Doorkeeper::OAuth::RequestConcern.class_eval do
|
36
|
-
def after_successful_response
|
37
|
-
raise "RequestConcern#token - #{@access_token.inspect}"
|
38
|
-
broadcast(:access_token_request_successful, @access_token.id)
|
39
|
-
super
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
config.after_initialize do
|
45
|
-
|
46
|
-
::Doorkeeper::OAuth::Authorization::Code.send(:prepend, ::Sso::Doorkeeper::Authorization::CodeMixin)
|
47
|
-
::Doorkeeper::OAuth::Authorization::Token.send(:prepend, ::Sso::Doorkeeper::Authorization::TokenMixin)
|
48
|
-
::Doorkeeper::Application.send(:include, ::Sso::Doorkeeper::ApplicationMixin)
|
49
|
-
::Doorkeeper::AccessGrant.send(:include, ::Sso::Doorkeeper::AccessGrantMixin)
|
50
|
-
::Doorkeeper::AccessToken.send(:include, ::Sso::Doorkeeper::AccessTokenMixin)
|
51
|
-
::Doorkeeper::ApplicationMetalController.send(:include, ::Sso::Doorkeeper::ApplicationControllerMixin)
|
52
|
-
::Doorkeeper::ApplicationController.send(:include, ::Sso::Doorkeeper::ApplicationControllerMixin)
|
53
|
-
# ::Doorkeeper::TokensController.send(:include, ::AbstractController::Callbacks)
|
54
|
-
# ::Doorkeeper::TokensController.send(:include, ::Sso::Doorkeeper::TokensControllerMixin)
|
55
|
-
# ::Doorkeeper::AuthorizationsController.send(:include, ::Sso::Doorkeeper::AuthorizationsControllerMixin)
|
56
|
-
|
57
|
-
<<<<<<< HEAD
|
58
|
-
::Warden::Manager.after_set_user(scope: :user, &::Sso::Warden::Hooks::CreateMasterSession.to_proc)
|
59
|
-
=======
|
60
|
-
>>>>>>> Use wisper to broadcast when token is created
|
61
|
-
::Warden::Manager.after_set_user(scope: :user, except: :fetch, &::Sso::Warden::Hooks::CreateMasterSession.to_proc)
|
62
|
-
::Warden::Manager.before_logout(scope: :user, &::Sso::Warden::Hooks::BeforeLogout.to_proc)
|
63
|
-
|
64
|
-
# TODO : Do we want to ensure that session is always active?
|
65
|
-
# ::Warden::Manager.after_fetch(scope: :user, &::Sso::Warden::Hooks::SessionCheck.to_proc)
|
66
|
-
|
67
|
-
# TODO : Why does it need a passport strategy
|
68
|
-
# Warden::Strategies.add :passport, ::Sso::Server::Warden::Strategies::Passport
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|