bsm-sso-client 0.2.0 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,7 +22,7 @@ class Bsm::Sso::Client::FailureApp < ActionController::Metal
22
22
  end
23
23
 
24
24
  def redirect!
25
- redirect_to Bsm::Sso::Client.user_class.sign_in_url(:service => service_url(env["warden.options"][:attempted_path])), :status => 303
25
+ redirect_to Bsm::Sso::Client.user_class.sso_sign_in_url(:service => service_url(env["warden.options"][:attempted_path])), :status => 303
26
26
  end
27
27
 
28
28
  def respond_with_js!
@@ -9,7 +9,7 @@ class Bsm::Sso::Client::Strategies::HttpAuth < Bsm::Sso::Client::Strategies::Bas
9
9
  end
10
10
 
11
11
  def authenticate!
12
- u = user_class.authorize(token)
12
+ u = user_class.sso_authorize(token)
13
13
  u.nil? ? fail!(:invalid) : success!(u)
14
14
  end
15
15
 
@@ -6,7 +6,7 @@ class Bsm::Sso::Client::Strategies::Ticket < Bsm::Sso::Client::Strategies::Base
6
6
  end
7
7
 
8
8
  def authenticate!
9
- u = user_class.consume(params[:ticket], service_url)
9
+ u = user_class.sso_consume(params[:ticket], service_url)
10
10
  u.nil? ? fail!(:invalid) : success!(u)
11
11
  end
12
12
 
@@ -1,36 +1,39 @@
1
1
  class Bsm::Sso::Client::User < Bsm::Sso::Client::AbstractResource
2
2
  class << self
3
3
 
4
- def consume(ticket, service)
5
- # TODO rename Sso endpoint to /validate
6
- find :one, :from => '/validate', :params => { :ticket => ticket, :service => service }
4
+ def sso_find(id)
5
+ find id
6
+ end
7
+
8
+ def sso_consume(ticket, service)
9
+ find :one, :from => '/consume', :params => { :ticket => ticket, :service => service }
7
10
  rescue ActiveResource::ResourceInvalid
8
11
  nil
9
12
  end
10
13
 
11
- def authorize(token)
14
+ def sso_authorize(token)
12
15
  find :one, :from => '/authorize', :params => { :auth_token => token }
13
16
  rescue ActiveResource::ResourceInvalid
14
17
  nil
15
18
  end
16
19
 
17
- def authenticate(credentials)
20
+ def sso_authenticate(credentials)
18
21
  find :one, :from => "/authenticate", :params => credentials.slice(:email, :password)
19
22
  rescue ActiveResource::ResourceInvalid
20
23
  nil
21
24
  end
22
25
 
23
- def sign_in_url(params = {})
24
- custom_absolute_method_root_url(:sign_in, params)
26
+ def sso_sign_in_url(params = {})
27
+ sso_custom_absolute_method_root_url(:sign_in, params)
25
28
  end
26
29
 
27
- def sign_out_url(params = {})
28
- custom_absolute_method_root_url(:sign_out, params)
30
+ def sso_sign_out_url(params = {})
31
+ sso_custom_absolute_method_root_url(:sign_out, params)
29
32
  end
30
33
 
31
34
  private
32
35
 
33
- def custom_absolute_method_root_url(method_name, params = {})
36
+ def sso_custom_absolute_method_root_url(method_name, params = {})
34
37
  "#{site.to_s.chomp('/')}/#{method_name}#{query_string(params)}"
35
38
  end
36
39
 
@@ -3,25 +3,34 @@ module Bsm::Sso::Client::UserMethods
3
3
 
4
4
  included do
5
5
  class << self
6
- delegate :sign_in_url, :sign_out_url, :to => :"Bsm::Sso::Client::User"
6
+ delegate :sso_sign_in_url, :sso_sign_out_url, :to => :"Bsm::Sso::Client::User"
7
7
  end
8
8
  end
9
9
 
10
10
  module ClassMethods
11
11
 
12
- def consume(*a)
13
- result = Bsm::Sso::Client::User.consume(*a)
14
- new(result.attributes) if result
12
+ def sso_find(id)
13
+ resource = Bsm::Sso::Client::User.sso_find(id)
14
+ sso_cache(resource, :find) if resource
15
15
  end
16
16
 
17
- def authenticate(*a)
18
- result = Bsm::Sso::Client::User.authenticate(*a)
19
- new(result.attributes) if result
17
+ def sso_consume(*a)
18
+ resource = Bsm::Sso::Client::User.sso_consume(*a)
19
+ sso_cache(resource, :consume) if resource
20
20
  end
21
21
 
22
- def authorize(*a)
23
- result = Bsm::Sso::Client::User.authorize(*a)
24
- new(result.attributes) if result
22
+ def sso_authenticate(*a)
23
+ resource = Bsm::Sso::Client::User.sso_authenticate(*a)
24
+ sso_cache(resource, :authenticate) if resource
25
+ end
26
+
27
+ def sso_authorize(*a)
28
+ resource = Bsm::Sso::Client::User.sso_authorize(*a)
29
+ sso_cache(resource, :authorize) if resource
30
+ end
31
+
32
+ def sso_cache(resource, action = nil)
33
+ new(resource.attributes)
25
34
  end
26
35
 
27
36
  end
@@ -5,7 +5,7 @@ class Warden::SessionSerializer
5
5
  end
6
6
 
7
7
  def deserialize(id)
8
- Bsm::Sso::Client.user_class.find(id)
8
+ Bsm::Sso::Client.user_class.sso_find(id)
9
9
  end
10
10
 
11
11
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bsm-sso-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-21 00:00:00.000000000Z
12
+ date: 2011-10-25 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activeresource
16
- requirement: &18984320 !ruby/object:Gem::Requirement
16
+ requirement: &14509780 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -24,10 +24,10 @@ dependencies:
24
24
  version: 3.2.0
25
25
  type: :runtime
26
26
  prerelease: false
27
- version_requirements: *18984320
27
+ version_requirements: *14509780
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: actionpack
30
- requirement: &18983200 !ruby/object:Gem::Requirement
30
+ requirement: &14508960 !ruby/object:Gem::Requirement
31
31
  none: false
32
32
  requirements:
33
33
  - - ! '>='
@@ -38,10 +38,10 @@ dependencies:
38
38
  version: 3.2.0
39
39
  type: :runtime
40
40
  prerelease: false
41
- version_requirements: *18983200
41
+ version_requirements: *14508960
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: railties
44
- requirement: &18981860 !ruby/object:Gem::Requirement
44
+ requirement: &14495240 !ruby/object:Gem::Requirement
45
45
  none: false
46
46
  requirements:
47
47
  - - ! '>='
@@ -52,10 +52,10 @@ dependencies:
52
52
  version: 3.2.0
53
53
  type: :runtime
54
54
  prerelease: false
55
- version_requirements: *18981860
55
+ version_requirements: *14495240
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: rails_warden
58
- requirement: &18980200 !ruby/object:Gem::Requirement
58
+ requirement: &14494520 !ruby/object:Gem::Requirement
59
59
  none: false
60
60
  requirements:
61
61
  - - ~>
@@ -63,10 +63,10 @@ dependencies:
63
63
  version: 0.5.0
64
64
  type: :runtime
65
65
  prerelease: false
66
- version_requirements: *18980200
66
+ version_requirements: *14494520
67
67
  - !ruby/object:Gem::Dependency
68
68
  name: rake
69
- requirement: &18967880 !ruby/object:Gem::Requirement
69
+ requirement: &14494120 !ruby/object:Gem::Requirement
70
70
  none: false
71
71
  requirements:
72
72
  - - ! '>='
@@ -74,10 +74,10 @@ dependencies:
74
74
  version: '0'
75
75
  type: :development
76
76
  prerelease: false
77
- version_requirements: *18967880
77
+ version_requirements: *14494120
78
78
  - !ruby/object:Gem::Dependency
79
79
  name: rack-test
80
- requirement: &18967420 !ruby/object:Gem::Requirement
80
+ requirement: &14493640 !ruby/object:Gem::Requirement
81
81
  none: false
82
82
  requirements:
83
83
  - - ! '>='
@@ -85,10 +85,10 @@ dependencies:
85
85
  version: '0'
86
86
  type: :development
87
87
  prerelease: false
88
- version_requirements: *18967420
88
+ version_requirements: *14493640
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: rspec
91
- requirement: &18967000 !ruby/object:Gem::Requirement
91
+ requirement: &14493220 !ruby/object:Gem::Requirement
92
92
  none: false
93
93
  requirements:
94
94
  - - ! '>='
@@ -96,10 +96,10 @@ dependencies:
96
96
  version: '0'
97
97
  type: :development
98
98
  prerelease: false
99
- version_requirements: *18967000
99
+ version_requirements: *14493220
100
100
  - !ruby/object:Gem::Dependency
101
101
  name: shoulda-matchers
102
- requirement: &18966380 !ruby/object:Gem::Requirement
102
+ requirement: &14492780 !ruby/object:Gem::Requirement
103
103
  none: false
104
104
  requirements:
105
105
  - - ! '>='
@@ -107,10 +107,10 @@ dependencies:
107
107
  version: '0'
108
108
  type: :development
109
109
  prerelease: false
110
- version_requirements: *18966380
110
+ version_requirements: *14492780
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: webmock
113
- requirement: &18965740 !ruby/object:Gem::Requirement
113
+ requirement: &14492360 !ruby/object:Gem::Requirement
114
114
  none: false
115
115
  requirements:
116
116
  - - ! '>='
@@ -118,7 +118,7 @@ dependencies:
118
118
  version: '0'
119
119
  type: :development
120
120
  prerelease: false
121
- version_requirements: *18965740
121
+ version_requirements: *14492360
122
122
  description: ''
123
123
  email: dimitrij@blacksquaremedia.com
124
124
  executables: []
@@ -158,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
158
  version: 1.3.6
159
159
  requirements: []
160
160
  rubyforge_project:
161
- rubygems_version: 1.8.10
161
+ rubygems_version: 1.8.11
162
162
  signing_key:
163
163
  specification_version: 3
164
164
  summary: BSM's internal SSO client