rails-auth 2.0.2 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +10 -0
- data/lib/rails/auth/credentials.rb +6 -1
- data/lib/rails/auth/monitor/middleware.rb +1 -1
- data/lib/rails/auth/version.rb +1 -1
- data/spec/rails/auth/credentials_spec.rb +22 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64b07b9bd8dd9957bc0762d864c405c3d6c04da5
|
4
|
+
data.tar.gz: 4b87e9e0994d8d02b51c16efc1c98e3bad4402a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bf4cb730c096d16d98b31223d726a8885e7df1ce4178ba90549c02111dcd944a894378e54ec43a1636f9467400529c84fdd8f819561378a9f2ef60875d19d4a
|
7
|
+
data.tar.gz: 7151a42a23717f89a3bc00c6c6e2298148b0b98154ac909ba2969c40c17164380b02c23a1827aef1eee6a0455c7d52c9cb4972e63db7518668a7cf1a9e54ab66
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
### 2.0.3 (2016-07-20)
|
2
|
+
|
3
|
+
* [#39](https://github.com/square/rails-auth/pull/39)
|
4
|
+
Make credentials idempotent.
|
5
|
+
([@tarcieri])
|
6
|
+
|
7
|
+
* [#38](https://github.com/square/rails-auth/pull/38)
|
8
|
+
Monitor callback must respond to :call.
|
9
|
+
([@tarcieri])
|
10
|
+
|
1
11
|
### 2.0.2 (2016-07-19)
|
2
12
|
|
3
13
|
* [#37](https://github.com/square/rails-auth/pull/37)
|
@@ -10,7 +10,7 @@ module Rails
|
|
10
10
|
extend Forwardable
|
11
11
|
include Enumerable
|
12
12
|
|
13
|
-
def_delegators :@credentials, :
|
13
|
+
def_delegators :@credentials, :fetch, :empty?, :key?, :each, :to_hash
|
14
14
|
|
15
15
|
def self.from_rack_env(env)
|
16
16
|
new(env.fetch(Rails::Auth::Env::CREDENTIALS_ENV_KEY, {}))
|
@@ -22,10 +22,15 @@ module Rails
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def []=(type, value)
|
25
|
+
return if @credentials.key?(type) && @credentials[type] == value
|
25
26
|
raise TypeError, "expected String for type, got #{type.class}" unless type.is_a?(String)
|
26
27
|
raise AlreadyAuthorizedError, "credential '#{type}' has already been set" if @credentials.key?(type)
|
27
28
|
@credentials[type] = value
|
28
29
|
end
|
30
|
+
|
31
|
+
def [](type)
|
32
|
+
@credentials[type.to_s]
|
33
|
+
end
|
29
34
|
end
|
30
35
|
end
|
31
36
|
end
|
@@ -5,7 +5,7 @@ module Rails
|
|
5
5
|
# or failure. Useful for logging or monitoring systems for AuthZ failures
|
6
6
|
class Middleware
|
7
7
|
def initialize(app, callback)
|
8
|
-
raise
|
8
|
+
raise ArgumentError, "callback must respond to :call" unless callback.respond_to?(:call)
|
9
9
|
|
10
10
|
@app = app
|
11
11
|
@callback = callback
|
data/lib/rails/auth/version.rb
CHANGED
@@ -21,10 +21,29 @@ RSpec.describe Rails::Auth::Credentials do
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
|
25
|
-
|
24
|
+
context "when called twice for the same credential type" do
|
25
|
+
let(:example_credential) { double(:credential1) }
|
26
|
+
let(:second_credential) { double(:credential2) }
|
27
|
+
|
28
|
+
let(:example_env) { Rack::MockRequest.env_for("https://www.example.com") }
|
29
|
+
|
30
|
+
it "succeeds if the credentials are the same" do
|
31
|
+
allow(example_credential).to receive(:==).and_return(true)
|
32
|
+
|
33
|
+
Rails::Auth.add_credential(example_env, example_credential_type, example_credential)
|
34
|
+
|
35
|
+
expect do
|
36
|
+
Rails::Auth.add_credential(example_env, example_credential_type, second_credential)
|
37
|
+
end.to_not raise_error
|
38
|
+
end
|
39
|
+
|
40
|
+
it "raises Rails::Auth::AlreadyAuthorizedError if the credentials are different" do
|
41
|
+
allow(example_credential).to receive(:==).and_return(false)
|
42
|
+
|
43
|
+
Rails::Auth.add_credential(example_env, example_credential_type, example_credential)
|
44
|
+
|
26
45
|
expect do
|
27
|
-
|
46
|
+
Rails::Auth.add_credential(example_env, example_credential_type, second_credential)
|
28
47
|
end.to raise_error(Rails::Auth::AlreadyAuthorizedError)
|
29
48
|
end
|
30
49
|
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: 2.0.
|
4
|
+
version: 2.0.3
|
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-07-
|
11
|
+
date: 2016-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|