bsm-sso-client 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/bsm/sso/client.rb +8 -0
- data/lib/bsm/sso/client/failure_app.rb +1 -3
- data/lib/bsm/sso/client/railtie.rb +1 -1
- metadata +19 -19
data/lib/bsm/sso/client.rb
CHANGED
@@ -8,6 +8,8 @@ require 'rails_warden'
|
|
8
8
|
module Bsm
|
9
9
|
module Sso
|
10
10
|
module Client
|
11
|
+
UnauthorizedAccess = Class.new(ActionController::ActionControllerError)
|
12
|
+
|
11
13
|
autoload :AbstractResource, 'bsm/sso/client/abstract_resource'
|
12
14
|
autoload :User, 'bsm/sso/client/user'
|
13
15
|
autoload :UserMethods, 'bsm/sso/client/user_methods'
|
@@ -48,6 +50,12 @@ module Bsm
|
|
48
50
|
tap(&block)
|
49
51
|
end
|
50
52
|
|
53
|
+
# Raises an UnauthorizedAccess exception
|
54
|
+
def forbidden!(request, message = nil)
|
55
|
+
message ||= "You are not permitted to access the resource in #{request.path}"
|
56
|
+
raise UnauthorizedAccess, message
|
57
|
+
end
|
58
|
+
|
51
59
|
end
|
52
60
|
end
|
53
61
|
end
|
@@ -4,7 +4,6 @@ class Bsm::Sso::Client::FailureApp < ActionController::Metal
|
|
4
4
|
include Bsm::Sso::Client::UrlHelpers
|
5
5
|
|
6
6
|
NAVIGATIONAL_FORMATS = [:html, :all, :js, nil].to_set.freeze
|
7
|
-
UnauthorizedAccess = Class.new(ActionController::ActionControllerError)
|
8
7
|
|
9
8
|
def self.call(env)
|
10
9
|
action(:respond).call(env)
|
@@ -34,8 +33,7 @@ class Bsm::Sso::Client::FailureApp < ActionController::Metal
|
|
34
33
|
|
35
34
|
# Throws UnauthorizedAccess (rescued as 403 Forbidden response)
|
36
35
|
def stop!(message = nil)
|
37
|
-
message
|
38
|
-
raise UnauthorizedAccess, message
|
36
|
+
Bsm::Sso::Client.forbidden!(request, message)
|
39
37
|
end
|
40
38
|
|
41
39
|
end
|
@@ -20,7 +20,7 @@ class Bsm::Sso::Client::Railtie < ::Rails::Railtie
|
|
20
20
|
|
21
21
|
def self.handle_exceptions!
|
22
22
|
return unless defined?(::ActionDispatch::ShowExceptions)
|
23
|
-
ActionDispatch::ShowExceptions.rescue_responses.update("Bsm::Sso::Client::
|
23
|
+
ActionDispatch::ShowExceptions.rescue_responses.update("Bsm::Sso::Client::UnauthorizedAccess" => :forbidden)
|
24
24
|
end
|
25
25
|
|
26
26
|
def self.plugin!(app)
|
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.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-10-21 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activeresource
|
16
|
-
requirement: &
|
16
|
+
requirement: &18984320 !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: *
|
27
|
+
version_requirements: *18984320
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: actionpack
|
30
|
-
requirement: &
|
30
|
+
requirement: &18983200 !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: *
|
41
|
+
version_requirements: *18983200
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: railties
|
44
|
-
requirement: &
|
44
|
+
requirement: &18981860 !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: *
|
55
|
+
version_requirements: *18981860
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: rails_warden
|
58
|
-
requirement: &
|
58
|
+
requirement: &18980200 !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: *
|
66
|
+
version_requirements: *18980200
|
67
67
|
- !ruby/object:Gem::Dependency
|
68
68
|
name: rake
|
69
|
-
requirement: &
|
69
|
+
requirement: &18967880 !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: *
|
77
|
+
version_requirements: *18967880
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
79
|
name: rack-test
|
80
|
-
requirement: &
|
80
|
+
requirement: &18967420 !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: *
|
88
|
+
version_requirements: *18967420
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
90
|
name: rspec
|
91
|
-
requirement: &
|
91
|
+
requirement: &18967000 !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: *
|
99
|
+
version_requirements: *18967000
|
100
100
|
- !ruby/object:Gem::Dependency
|
101
101
|
name: shoulda-matchers
|
102
|
-
requirement: &
|
102
|
+
requirement: &18966380 !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: *
|
110
|
+
version_requirements: *18966380
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: webmock
|
113
|
-
requirement: &
|
113
|
+
requirement: &18965740 !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: *
|
121
|
+
version_requirements: *18965740
|
122
122
|
description: ''
|
123
123
|
email: dimitrij@blacksquaremedia.com
|
124
124
|
executables: []
|