doorkeeper_sso_client 0.2.5 → 0.2.7
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00aa97b0712d8db04fbb37bb15432c99fb042ee1
|
4
|
+
data.tar.gz: fdd6f0131330cb540ad92afc656d0777edf7d6be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea87f47e2380d4e2eb07947ace447a9f7dbe25ee75f8c352b8dfbaff92dda77344b9b5a5ded28d9b433f3128c01e3a3681861d73395b53678e6c3851128b87c7
|
7
|
+
data.tar.gz: 63a7dcf41d25b79c420146d65052e55ddfa41a1b199ac977657329fad7b761afbbebbe551b8db558d2e5025236cdf28318c986e1d16ecbb6c446a1ee124bf791
|
@@ -3,12 +3,28 @@ module DoorkeeperSsoClient
|
|
3
3
|
module ControllerHelpers
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
|
+
module ClassMethods
|
7
|
+
def activate_sso(scope, options = {})
|
8
|
+
devise_group :sso, contains: [scope]
|
9
|
+
|
10
|
+
unless options[:skip_devise_hook]
|
11
|
+
class_eval <<-METHODS, __FILE__, __LINE__ + 1
|
12
|
+
def authenticate_#{scope}!
|
13
|
+
validate_passport!
|
14
|
+
super
|
15
|
+
end
|
16
|
+
METHODS
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
6
21
|
def validate_passport!
|
7
22
|
if sso_signed_in?
|
8
23
|
sign_out(current_sso) unless current_sso.passport.try(:active?)
|
9
24
|
end
|
10
25
|
return true
|
11
26
|
end
|
27
|
+
|
12
28
|
end
|
13
29
|
end
|
14
30
|
end
|
@@ -2,44 +2,80 @@ require 'rails_helper'
|
|
2
2
|
|
3
3
|
# DoorkeeperSsoClient::Mixins::ControllerHelpers automatically included into Devise::Controller::Helpers
|
4
4
|
|
5
|
-
RSpec.describe "DoorkeeperSsoClient::Mixins::ControllerHelpers", :type => :controller do
|
6
|
-
|
7
|
-
|
5
|
+
RSpec.describe "DoorkeeperSsoClient::Mixins::ControllerHelpers DeviseHook", :type => :controller do
|
6
|
+
controller(ApplicationController) do
|
7
|
+
activate_sso :user
|
8
|
+
before_filter :authenticate_user!
|
8
9
|
|
9
|
-
|
10
|
-
|
10
|
+
def index
|
11
|
+
render nothing: :true
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:passport) { Fabricate('DoorkeeperSsoClient::Passport', identity: Fabricate(:user)) }
|
16
|
+
let(:user) { passport.identity }
|
17
|
+
|
18
|
+
before(:each) do
|
19
|
+
@request.env["devise.mapping"] = Devise.mappings[:user]
|
20
|
+
sign_in user
|
21
|
+
get :index
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "::activate_sso" do
|
11
25
|
|
12
|
-
|
13
|
-
|
26
|
+
context "with valid passport" do
|
27
|
+
it "remain signed in" do
|
28
|
+
expect(controller.user_signed_in?).to be_truthy
|
14
29
|
end
|
15
30
|
end
|
16
31
|
|
17
|
-
|
18
|
-
|
32
|
+
context "with invalid passport" do
|
33
|
+
let(:passport) { Fabricate('DoorkeeperSsoClient::Passport', identity: Fabricate(:user), revoked_at: Time.now, revoke_reason: :logout ) }
|
34
|
+
it "automatically signed out" do
|
35
|
+
expect(controller.user_signed_in?).to be_falsey
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
19
40
|
|
20
|
-
describe "before_filter#validate_passport!" do
|
21
|
-
context "when user is logged in" do
|
22
|
-
before(:each) do
|
23
|
-
@request.env["devise.mapping"] = Devise.mappings[:user]
|
24
|
-
sign_in user
|
25
|
-
get :index
|
26
|
-
end
|
27
41
|
|
28
|
-
context "with valid passport" do
|
29
42
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
end
|
43
|
+
RSpec.describe "DoorkeeperSsoClient::Mixins::ControllerHelpers SkipDeviseHook", :type => :controller do
|
44
|
+
controller(ApplicationController) do
|
45
|
+
activate_sso :user, :skip_devise_hook => true
|
46
|
+
before_filter :authenticate_user!
|
35
47
|
|
36
|
-
|
37
|
-
|
48
|
+
def index
|
49
|
+
render nothing: :true
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
let(:passport) { Fabricate('DoorkeeperSsoClient::Passport', identity: Fabricate(:user)) }
|
54
|
+
let(:user) { passport.identity }
|
38
55
|
|
39
|
-
|
40
|
-
|
41
|
-
|
56
|
+
before(:each) do
|
57
|
+
@request.env["devise.mapping"] = Devise.mappings[:user]
|
58
|
+
sign_in user
|
59
|
+
get :index
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "#validate_passport!" do
|
63
|
+
context "with valid passport" do
|
64
|
+
it "remain signed in" do
|
65
|
+
expect(controller.user_signed_in?).to be_truthy
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context "with invalid passport" do
|
70
|
+
let(:passport) { Fabricate('DoorkeeperSsoClient::Passport', identity: Fabricate(:user), revoked_at: Time.now, revoke_reason: :logout ) }
|
71
|
+
it "remain signed in" do
|
72
|
+
expect(controller.user_signed_in?).to be_truthy
|
73
|
+
end
|
42
74
|
|
75
|
+
it "sign out when manually validate_passport!" do
|
76
|
+
controller.validate_passport!
|
77
|
+
expect(controller.user_signed_in?).to be_falsey
|
43
78
|
end
|
44
79
|
end
|
80
|
+
end
|
45
81
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: doorkeeper_sso_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
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-07-
|
11
|
+
date: 2015-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: omniauth
|