authority 3.2.2 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 209f70400ce02fb82c4ecb564e7f21607d48be15
4
- data.tar.gz: 9175a6345c96dbe3dd3f18278b35679f4a061677
3
+ metadata.gz: 0866ed584d33abcd9ad475731155ad4fe433bf32
4
+ data.tar.gz: b65075c60d7719464f45b961abbc8a9b796ccea0
5
5
  SHA512:
6
- metadata.gz: 270796016add52f4a991b33de28b1f835b84fa66ae4c1f38bf3d5996d352b640d2ada5d700a38e6a5c6617391886b948620ca6123ffdfeaa9daec560bcce5109
7
- data.tar.gz: 0836bfb4004649c65c47bfb09558d2e91f954e235a157364519852502288083df11a675b008dcf634dc086314e9d59e965ac3a6a3ca599ffe0f8de1e2a4946e2
6
+ metadata.gz: 6159f7b02e3343ec357415791660a1fd0f939d2110bc115defe89701ad97225cffbb70f114a07b183c0c88d5de881307f7c6da42a5faf3ff6fba4c80b9f01e34
7
+ data.tar.gz: 7f2e9bd8713b865ab707268dfa78362dc5f485405116453d92972d72a8255ab3102bac7ab7eeceea82a00d55029489859d55ca58478092659dc448e7bc6ffe57
@@ -1,9 +1,11 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 1.9.3
4
- - 2.0
5
- - 2.1
6
- - 2.2
4
+ - 2.0.0
5
+ - 2.1.10
6
+ - 2.2.6
7
+ - 2.3.3
8
+ - 2.4.0
7
9
  - jruby-19mode # JRuby in 1.9 mode
8
10
  # - rbx-2
9
11
 
@@ -20,8 +22,16 @@ matrix:
20
22
  exclude:
21
23
  - rvm: rbx
22
24
  gemfile: gemfiles/4.0.gemfile
25
+ - rvm: 2.4.0
26
+ gemfile: gemfiles/3.2.gemfile
27
+ - rvm: 2.4.0
28
+ gemfile: gemfiles/4.1.gemfile
29
+ - rvm: 2.4.0
30
+ gemfile: gemfiles/4.2.gemfile
23
31
  include:
24
- - rvm: 2.2.2
32
+ - rvm: 2.2.6
25
33
  gemfile: gemfiles/5.0.gemfile
26
- - rvm: 2.3.1
34
+ - rvm: 2.3.3
35
+ gemfile: gemfiles/5.0.gemfile
36
+ - rvm: 2.4.0
27
37
  gemfile: gemfiles/5.0.gemfile
@@ -6,6 +6,10 @@ Authority does its best to use [semantic versioning](http://semver.org).
6
6
 
7
7
  (nothing)
8
8
 
9
+ ## 3.3.0
10
+
11
+ - [Allow defining `authority_success` controller action to handle successful authorization](https://github.com/nathanl/authority/pull/119), thanks to [John Poulin](https://github.com/forced-request)
12
+
9
13
  ## 3.2.2
10
14
 
11
15
  - [Fix Rails 5 `after_filter` deprecation warning](https://github.com/nathanl/authority/pull/115), thanks to [Erik Axel Nielsen](https://github.com/erikaxel))
@@ -6,7 +6,7 @@ Authority will work fine with a standalone app or a single sign-on system. You c
6
6
 
7
7
  If you're using it with Rails controllers, it requires that you already have some kind of user object in your application, accessible via a method like `current_user` (configurable).
8
8
 
9
- [![Gem Version](https://badge.fury.io/rb/authority.png)](https://rubygems.org/gems/searchlight)
9
+ [![Gem Version](https://badge.fury.io/rb/authority.png)](https://rubygems.org/gems/authority)
10
10
  [![Build Status](https://secure.travis-ci.org/nathanl/authority.png?branch=master)](http://travis-ci.org/nathanl/authority)
11
11
  [![Code Climate](https://codeclimate.com/github/nathanl/authority.png)](https://codeclimate.com/github/nathanl/authority)
12
12
  [![Dependency Status](https://gemnasium.com/nathanl/authority.png)](https://gemnasium.com/nathanl/authority)
@@ -493,6 +493,16 @@ end
493
493
 
494
494
  Your method will be handed the `SecurityViolation`, which has a `message` method. In case you want to build your own message, it also exposes `user`, `action` and `resource`.
495
495
 
496
+ When a user action is successfully authorized, Authority will call `authority_success` on your controller.
497
+ By default, this does nothing, but you can override it to log the event or do something else.
498
+ For instance:
499
+
500
+ ```ruby
501
+ def authority_success(user, action, resource)
502
+ Authority.logger.info "user #{user} was authorized to #{action} resource #{resource}"
503
+ end
504
+ ```
505
+
496
506
  <a name="credits">
497
507
  ## Credits, AKA 'Shout-Outs'
498
508
 
@@ -2,5 +2,6 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'rails', '~> 3.2.3'
4
4
  gem 'rspec', '~> 2.14.0'
5
+ gem 'rake', '~> 11.3.0'
5
6
 
6
7
  gemspec path: '../'
@@ -2,6 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'rails', '~> 4.0.0'
4
4
  gem 'rspec', '~> 2.14.0'
5
+ gem 'rake', '~> 11.3.0'
5
6
 
6
7
  platforms :jruby, :ruby_19 do
7
8
  gem 'mime-types', '~> 2.99.2'
@@ -2,6 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'rails', '~> 4.1.0'
4
4
  gem 'rspec', '~> 2.14.0'
5
+ gem 'rake', '~> 11.3.0'
5
6
 
6
7
  platforms :jruby, :ruby_19 do
7
8
  gem 'mime-types', '~> 2.99.2'
@@ -2,9 +2,16 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'rails', '~> 4.2.0'
4
4
  gem 'rspec', '~> 2.14.0'
5
+ gem 'rake', '~> 11.3.0'
5
6
 
6
7
  platforms :jruby, :ruby_19 do
7
8
  gem 'mime-types', '~> 2.99.2'
8
9
  end
9
10
 
11
+ platforms :ruby do
12
+ if RUBY_VERSION < "2.1.0"
13
+ gem "nokogiri", "1.6.8.1"
14
+ end
15
+ end
16
+
10
17
  gemspec path: '../'
@@ -133,6 +133,10 @@ module Authority
133
133
  end
134
134
 
135
135
  Authority.enforce(authority_action, authority_resource, authority_user, *options)
136
+
137
+ # This method is always invoked, but will only log if it's overriden
138
+ authority_success(authority_user, authority_action, authority_resource)
139
+
136
140
  self.authorization_performed = true
137
141
  end
138
142
 
@@ -144,6 +148,11 @@ module Authority
144
148
  render :file => Rails.root.join('public', '403.html'), :status => 403, :layout => false
145
149
  end
146
150
 
151
+ # This method can be overloaded inside the application controller, similar to authority_forbidden.
152
+ def authority_success(user, action, resource)
153
+ # Do nothing by default, but provide the option for users to override if they will.
154
+ end
155
+
147
156
  private
148
157
 
149
158
  # The `before_filter` that will be setup to run when the class method
@@ -1,3 +1,3 @@
1
1
  module Authority
2
- VERSION = "3.2.2"
2
+ VERSION = "3.3.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authority
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.2
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Long
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-12-21 00:00:00.000000000 Z
12
+ date: 2017-02-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport