bsm-sso-client 0.7.8 → 0.7.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,6 +22,7 @@ module Bsm
22
22
  autoload :FailureApp, 'bsm/sso/client/failure_app'
23
23
  autoload :Cached, 'bsm/sso/client/cached'
24
24
  autoload :Ability, 'bsm/sso/client/ability'
25
+ autoload :AuthorizedController, 'bsm/sso/client/authorized_controller'
25
26
 
26
27
  mattr_accessor :secret
27
28
  @@secret = nil
@@ -0,0 +1,42 @@
1
+ begin
2
+ require 'inherited_resources'
3
+ rescue LoadError => e
4
+ warn "\n [!] Please install `inherited_resources` Gem to use the AuthorizedController\n"
5
+ raise
6
+ end
7
+
8
+ class Bsm::Sso::Client::AuthorizedController < InheritedResources::Base
9
+
10
+ before_filter :authorize_inherited_resource!
11
+
12
+ protected
13
+
14
+ # Override. Apply `accessible_by` scope if #scope_accessible? applies
15
+ def apply_scopes(*)
16
+ relation = super
17
+ relation = relation.accessible_by(current_ability) if scope_accessible?
18
+ relation
19
+ end
20
+
21
+ # Callback. Default authorization of inherited resources
22
+ def authorize_inherited_resource!
23
+ authorize! :show, parent if parent?
24
+ authorize! authorizable_action, authorize_resource? ? resource : resource_class
25
+ end
26
+
27
+ # @return [Boolean] true if a single resource is to be authorized, false if the whole resource class
28
+ def authorize_resource?
29
+ !!(resources_configuration[:self][:singleton] || params[:id])
30
+ end
31
+
32
+ # @return [Boolean] true if accessible_by scope should be applied
33
+ def scope_accessible?
34
+ !authorize_resource? && ['new', 'create'].exclude?(action_name)
35
+ end
36
+
37
+ # @return [Symbol] resource permission name, defaults to the action name
38
+ def authorizable_action
39
+ action_name.to_sym
40
+ end
41
+
42
+ 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.7.8
4
+ version: 0.7.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-19 00:00:00.000000000 Z
12
+ date: 2012-10-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
@@ -219,28 +219,45 @@ dependencies:
219
219
  - - ! '>='
220
220
  - !ruby/object:Gem::Version
221
221
  version: '0'
222
+ - !ruby/object:Gem::Dependency
223
+ name: inherited_resources
224
+ requirement: !ruby/object:Gem::Requirement
225
+ none: false
226
+ requirements:
227
+ - - ! '>='
228
+ - !ruby/object:Gem::Version
229
+ version: '0'
230
+ type: :development
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ none: false
234
+ requirements:
235
+ - - ! '>='
236
+ - !ruby/object:Gem::Version
237
+ version: '0'
222
238
  description: ''
223
239
  email: dimitrij@blacksquaremedia.com
224
240
  executables: []
225
241
  extensions: []
226
242
  extra_rdoc_files: []
227
243
  files:
228
- - lib/bsm/sso/client.rb
229
- - lib/bsm/sso/client/strategies/ticket.rb
230
- - lib/bsm/sso/client/strategies/base.rb
231
- - lib/bsm/sso/client/strategies/http_auth.rb
232
- - lib/bsm/sso/client/cached.rb
233
- - lib/bsm/sso/client/failure_app.rb
234
- - lib/bsm/sso/client/ability.rb
244
+ - lib/bsm/sso/client/test_helpers.rb
235
245
  - lib/bsm/sso/client/abstract_resource.rb
236
- - lib/bsm/sso/client/railtie.rb
246
+ - lib/bsm/sso/client/ability.rb
247
+ - lib/bsm/sso/client/user.rb
248
+ - lib/bsm/sso/client/cached.rb
237
249
  - lib/bsm/sso/client/user_methods.rb
238
- - lib/bsm/sso/client/test_helpers.rb
239
250
  - lib/bsm/sso/client/url_helpers.rb
240
- - lib/bsm/sso/client/user.rb
241
251
  - lib/bsm/sso/client/warden_ext.rb
252
+ - lib/bsm/sso/client/authorized_controller.rb
242
253
  - lib/bsm/sso/client/strategies.rb
254
+ - lib/bsm/sso/client/failure_app.rb
255
+ - lib/bsm/sso/client/railtie.rb
243
256
  - lib/bsm/sso/client/cached/active_record.rb
257
+ - lib/bsm/sso/client/strategies/ticket.rb
258
+ - lib/bsm/sso/client/strategies/http_auth.rb
259
+ - lib/bsm/sso/client/strategies/base.rb
260
+ - lib/bsm/sso/client.rb
244
261
  - lib/bsm-sso-client.rb
245
262
  homepage: https://github.com/bsm/sso-client
246
263
  licenses: []