rails-auth 0.4.0 → 0.4.1

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: 91890f235f52285df442021821f7cafe571d159d
4
- data.tar.gz: 317be3357a00fe49de1e6f6e35e143887c6cd8ab
3
+ metadata.gz: 5b48234e95be0db7806d0126d60590261a585409
4
+ data.tar.gz: 02ae7923ef2a6f12da93fbe0ecea10818c167fb5
5
5
  SHA512:
6
- metadata.gz: 5d922c273e1ea6bcc90c9dbd7b4c46a44e4d26f350162ecc48cfd5b9412b98242f5ce51a4191729a68c9d86d83bee0879c4e7c407393b8bff309ee30be0cc7bb
7
- data.tar.gz: 50c8da3ad9fada2f4347f42090e685103b851771f58d61d14e3d4939937a062017fdf107c57c4ede0ef4c2f392f5b0522c08f493e516c486e6682a2672939c74
6
+ metadata.gz: ffac862f2da1d9054751ba8bdcd05cc292851ce87bf0fea120eb9ec001003bee782b7740f400ef9e02e0a6dd634ab668a96f347e3313391f1bbdd6e7c3b82a39
7
+ data.tar.gz: 1a6a4ed4a30071156042b36755ae8db7ae1b8cc749ba5fad792970ab588e9f051be9199a90af78a60ef0abc59f4befb092785d6e8256872e9ea0ae3401f59c07
data/.travis.yml CHANGED
@@ -1,16 +1,21 @@
1
1
  language: ruby
2
2
  sudo: false
3
+ branches:
4
+ only:
5
+ - master
3
6
 
4
7
  before_install:
5
8
  - gem install bundler
6
9
 
10
+ bundler_args: --without development
11
+
7
12
  rvm:
8
13
  - 2.0.0
9
- - 2.1.8
14
+ - 2.1.10
10
15
  - 2.2.4
11
16
  - 2.3.0
12
17
  matrix:
13
18
  include:
14
- - rvm: jruby-9.0.4.0
19
+ - rvm: jruby-9.0.5.0
15
20
  env: JRUBY_OPTS="--debug" # for simplecov
16
21
  fast_finish: true
data/CHANGES.md CHANGED
@@ -1,3 +1,13 @@
1
+ ### 0.4.1 (2016-04-23)
2
+
3
+ * [#17](https://github.com/square/rails-auth/pull/17)
4
+ Use PATH_INFO instead of REQUEST_PATH.
5
+ ([@tarcieri])
6
+
7
+ * [#15](https://github.com/square/rails-auth/pull/15)
8
+ Check types more thoroughly when parsing ACLs.
9
+ ([@tarcieri])
10
+
1
11
  ### 0.4.0 (2016-03-14)
2
12
 
3
13
  * [#14](https://github.com/square/rails-auth/pull/14)
data/Gemfile CHANGED
@@ -4,7 +4,8 @@ group :development do
4
4
  gem "guard-rspec"
5
5
  end
6
6
 
7
- group :test do
7
+ group :development, :test do
8
+ gem "rake"
8
9
  gem "rspec"
9
10
  gem "rubocop", "0.38.0"
10
11
  gem "coveralls", require: false
data/README.md CHANGED
@@ -73,7 +73,7 @@ policies around them.
73
73
  Below is a comparison of how Rails::Auth relates to the existing landscape
74
74
  of Rails AuthN and AuthZ libraries. These are grouped into two different
75
75
  categories: libraries Rails::Auth replaces, and libraries with which
76
- Rails::Auth can be used in a complimentary fashion.
76
+ Rails::Auth can be used in a complementary fashion.
77
77
 
78
78
  ### Replaces:
79
79
 
@@ -93,7 +93,7 @@ Rails::Auth can be used in a complimentary fashion.
93
93
  easily support [claims-based identity] systems where user identity
94
94
  is outsourced to a separate microservice.
95
95
 
96
- ### Compliments:
96
+ ### Complements:
97
97
 
98
98
  * [Pundit]: Domain object-centric fine-grained authorization using clean
99
99
  object-oriented APIs. Pundit makes authorization decisions around particular
@@ -22,9 +22,13 @@ module Rails
22
22
  # @param [Hash] :matchers predicate matchers for use with this ACL
23
23
  #
24
24
  def initialize(acl, matchers: {})
25
+ raise TypeError, "expected Array for acl, got #{acl.class}" unless acl.is_a?(Array)
26
+
25
27
  @resources = []
26
28
 
27
- acl.each_with_index do |entry|
29
+ acl.each do |entry|
30
+ raise TypeError, "expected Hash for acl entry, got #{entry.class}" unless entry.is_a?(Hash)
31
+
28
32
  resources = entry["resources"]
29
33
  raise ParseError, "no 'resources' key present in entry: #{entry.inspect}" unless resources
30
34
 
@@ -58,7 +58,7 @@ module Rails
58
58
  #
59
59
  def match!(env)
60
60
  return false unless @http_methods.nil? || @http_methods.include?(env["REQUEST_METHOD".freeze])
61
- return false unless @path =~ env["REQUEST_PATH".freeze]
61
+ return false unless @path =~ env["PATH_INFO".freeze]
62
62
  return false unless @host.nil? || @host =~ env["HTTP_HOST".freeze]
63
63
  true
64
64
  end
@@ -72,7 +72,7 @@
72
72
  </tr>
73
73
  <tr>
74
74
  <td class="label">Path</td>
75
- <td><%= h(env["REQUEST_PATH"]) %></td>
75
+ <td><%= h(env["PATH_INFO"]) %></td>
76
76
  </tr>
77
77
  <tr>
78
78
  <td class="label">Host</td>
@@ -35,7 +35,7 @@ module Rails
35
35
 
36
36
  env = {
37
37
  "REQUEST_METHOD" => method,
38
- "REQUEST_PATH" => self.class.description
38
+ "PATH_INFO" => self.class.description
39
39
  }
40
40
 
41
41
  certificates.each do |type, value|
@@ -3,6 +3,6 @@
3
3
  module Rails
4
4
  # Pluggable authentication and authorization for Rack/Rails
5
5
  module Auth
6
- VERSION = "0.4.0".freeze
6
+ VERSION = "0.4.1".freeze
7
7
  end
8
8
  end
@@ -11,6 +11,12 @@ RSpec.describe Rails::Auth::ACL do
11
11
  )
12
12
  end
13
13
 
14
+ describe "#initialize" do
15
+ it "raises TypeError if given a non-Array ACL type" do
16
+ expect { described_class.new(:bogus) }.to raise_error(TypeError)
17
+ end
18
+ end
19
+
14
20
  describe "#match" do
15
21
  it "matches routes against the ACL" do
16
22
  expect(example_acl.match(env_for(:get, "/"))).to eq true
data/spec/spec_helper.rb CHANGED
@@ -18,9 +18,10 @@ def fixture_path(*args)
18
18
  Pathname.new(File.expand_path("../fixtures", __FILE__)).join(*args)
19
19
  end
20
20
 
21
- def env_for(method, path)
21
+ def env_for(method, path, host = "127.0.0.1")
22
22
  {
23
23
  "REQUEST_METHOD" => method.to_s.upcase,
24
- "REQUEST_PATH" => path
24
+ "PATH_INFO" => path,
25
+ "HTTP_HOST" => host
25
26
  }
26
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Arcieri
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-15 00:00:00.000000000 Z
11
+ date: 2016-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack