doorkeeper_sso_client 0.4.5 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/doorkeeper_sso_client.rb +1 -0
- data/lib/doorkeeper_sso_client/mixins.rb +5 -2
- data/lib/doorkeeper_sso_client/mixins/mongoid/passport.rb +1 -1
- data/lib/doorkeeper_sso_client/mixins/passport_base.rb +2 -3
- data/lib/doorkeeper_sso_client/version.rb +1 -1
- data/lib/doorkeeper_sso_client/warden/support.rb +38 -0
- data/spec/models/passport_spec.rb +43 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa2d95c6f02bff6fa8d4bf95dcb760591e39d23d
|
4
|
+
data.tar.gz: ae2fd4b66c75e23957fac23bc1145930f7be73f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e5c7076db43b1f70cea8f9df1db648f24023ce27ff120af72e2a58c2c8681d9782ace202424dbebfea60e622e23110b1c4e98350e4cf4748eebd4b947063f7b
|
7
|
+
data.tar.gz: b399085444f1e88108bd0a55cc2011debed894ebefd6cc1e3738ba03e8c77a1ed052c93800ba1aa6bbccde5790577a87ae2f0ac083e1bdbd484cb13dc3432bc1
|
@@ -4,6 +4,7 @@ require "doorkeeper_sso_client/engine"
|
|
4
4
|
require 'doorkeeper_sso_client/config'
|
5
5
|
require 'doorkeeper_sso_client/logging'
|
6
6
|
require 'doorkeeper_sso_client/passport_verifier'
|
7
|
+
require 'doorkeeper_sso_client/warden/support'
|
7
8
|
require 'doorkeeper_sso_client/warden/hooks/after_fetch'
|
8
9
|
require 'doorkeeper_sso_client/version'
|
9
10
|
require 'omniauth/strategies/doorkeeper_sso'
|
@@ -1,9 +1,12 @@
|
|
1
|
-
require 'doorkeeper_sso_client/mixins/passport_base'
|
2
1
|
require 'doorkeeper_sso_client/mixins/devise/controller_helpers'
|
3
2
|
require 'doorkeeper_sso_client/mixins/devise/test_helpers'
|
4
|
-
require 'doorkeeper_sso_client/mixins/
|
3
|
+
require 'doorkeeper_sso_client/mixins/passport_base'
|
5
4
|
|
6
5
|
module DoorkeeperSsoClient
|
7
6
|
module Mixins
|
7
|
+
module Mongoid
|
8
|
+
autoload :Passport, 'doorkeeper_sso_client/mixins/mongoid/passport'
|
9
|
+
end
|
8
10
|
end
|
9
11
|
end
|
12
|
+
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require_dependency 'mongoid'
|
2
|
-
|
3
1
|
module DoorkeeperSsoClient
|
4
2
|
module Mixins
|
5
3
|
module PassportBase
|
@@ -12,7 +10,8 @@ module DoorkeeperSsoClient
|
|
12
10
|
|
13
11
|
module ClassMethods
|
14
12
|
def create_from_omniauth(auth_hash)
|
15
|
-
|
13
|
+
uid = { uid: auth_hash["extra"]["passport_id"] }
|
14
|
+
passport = where(uid).first || new(uid)
|
16
15
|
passport.update_attributes!(
|
17
16
|
secret: auth_hash["extra"]["passport_secret"],
|
18
17
|
token: auth_hash["credentials"]["token"],
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module DoorkeeperSsoClient
|
2
|
+
module Warden
|
3
|
+
module Support
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
include ::DoorkeeperSsoClient::Logging
|
6
|
+
|
7
|
+
included do
|
8
|
+
attr_reader :user, :warden, :options
|
9
|
+
delegate :request, to: :warden
|
10
|
+
delegate :params, to: :request
|
11
|
+
end
|
12
|
+
|
13
|
+
module ClassMethods
|
14
|
+
def to_proc
|
15
|
+
proc do |user, warden, options|
|
16
|
+
new(user, warden, options).call
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize(user, warden, options)
|
22
|
+
@user, @warden, @options = user, warden, options
|
23
|
+
end
|
24
|
+
|
25
|
+
def scope
|
26
|
+
scope = options[:scope]
|
27
|
+
end
|
28
|
+
|
29
|
+
def session
|
30
|
+
warden.session(scope)
|
31
|
+
end
|
32
|
+
|
33
|
+
def logged_in?
|
34
|
+
warden.authenticated?(scope) && session && user
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -12,4 +12,47 @@ RSpec.describe DoorkeeperSsoClient::Passport, :type => :model do
|
|
12
12
|
it { is_expected.to validate_uniqueness_of(:uid) }
|
13
13
|
end
|
14
14
|
|
15
|
+
describe "::create_from_omniauth" do
|
16
|
+
let(:token) { SecureRandom.hex }
|
17
|
+
let(:passport_uid) { SecureRandom.uuid }
|
18
|
+
let(:auth_hash) {
|
19
|
+
HashWithIndifferentAccess.new(
|
20
|
+
provider: 'mindvalley',
|
21
|
+
uid: '123545',
|
22
|
+
info: {
|
23
|
+
first_name: 'Steve',
|
24
|
+
last_name: 'Jobs',
|
25
|
+
email: 'steve@apple.com'
|
26
|
+
},
|
27
|
+
extra: {
|
28
|
+
passport_id: passport_uid
|
29
|
+
},
|
30
|
+
credentials: { token: token, refresh_token: nil, expiry: nil }
|
31
|
+
)
|
32
|
+
}
|
33
|
+
let(:fetched_passport) { DoorkeeperSsoClient::Passport.first }
|
34
|
+
|
35
|
+
|
36
|
+
before(:each) do
|
37
|
+
DoorkeeperSsoClient::Passport.create_from_omniauth(auth_hash)
|
38
|
+
end
|
39
|
+
|
40
|
+
context "new passport" do
|
41
|
+
it { expect(DoorkeeperSsoClient::Passport.count).to eq 1 }
|
42
|
+
it { expect(fetched_passport.uid).to eq passport_uid }
|
43
|
+
it { expect(fetched_passport.token).to eq token }
|
44
|
+
end
|
45
|
+
|
46
|
+
context "update existing" do
|
47
|
+
let!(:passport) { Fabricate("DoorkeeperSsoClient::Passport") }
|
48
|
+
let(:token) { passport.token }
|
49
|
+
let(:passport_uid) { passport.uid }
|
50
|
+
|
51
|
+
it { expect(DoorkeeperSsoClient::Passport.count).to eq 1 }
|
52
|
+
it { expect(fetched_passport.uid).to eq passport_uid }
|
53
|
+
it { expect(fetched_passport.token).to eq token }
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
15
58
|
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.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-07
|
11
|
+
date: 2015-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: omniauth
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: '1'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: '1'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rails
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -351,6 +351,7 @@ files:
|
|
351
351
|
- lib/doorkeeper_sso_client/passport_verifier.rb
|
352
352
|
- lib/doorkeeper_sso_client/version.rb
|
353
353
|
- lib/doorkeeper_sso_client/warden/hooks/after_fetch.rb
|
354
|
+
- lib/doorkeeper_sso_client/warden/support.rb
|
354
355
|
- lib/omniauth/strategies/doorkeeper_sso.rb
|
355
356
|
- lib/tasks/doorkeeper_sso_client_tasks.rake
|
356
357
|
- spec/controllers/doorkeeper_sso_client/callbacks_controller_spec.rb
|