simple_admin_auth 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -2
- data/Gemfile.lock +1 -1
- data/README.md +4 -0
- data/Rakefile +8 -0
- data/gemfiles/rack1.5.gemfile.lock +1 -1
- data/gemfiles/rails3.2.gemfile.lock +5 -5
- data/gemfiles/rails4.0.gemfile.lock +1 -1
- data/gemfiles/rails4.1.gemfile.lock +1 -1
- data/lib/simple_admin_auth/authenticated.rb +8 -2
- data/lib/simple_admin_auth/version.rb +1 -1
- data/spec/authenticate_spec.rb +13 -0
- 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: 778f7b2792642130800e0aef4ad721a01dd88e16
|
4
|
+
data.tar.gz: 31b9f1072e04c83111dc2a474940492e8f772b24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e036b37199c206b719a78d891c6323fe75dd3bc9ddf54f077aa42f4beee9a2325744e469834f04c8390a1fc8f682e8254e871c1443c5ac147d29282211165948
|
7
|
+
data.tar.gz: 4bbf83c4be4ca06576796991c5cf5d8ccda44b002b1e85ee83c3efb286b5ff1a3e493c4f1c13d90ab161c2ed450b265a59e922df9c72dc92bee34fed32d3010d
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -123,6 +123,10 @@ Note that this relies on internal behaviour of this gem, and might not be compat
|
|
123
123
|
|
124
124
|
## Changelog
|
125
125
|
|
126
|
+
### 0.1.2
|
127
|
+
|
128
|
+
* Rails 4.1 compatibility, contributed by @drubin.
|
129
|
+
|
126
130
|
### 0.1.1
|
127
131
|
|
128
132
|
* Allow whitelisting of emails. Contributed by @drubin.
|
data/Rakefile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../
|
3
3
|
specs:
|
4
|
-
simple_admin_auth (0.1.
|
4
|
+
simple_admin_auth (0.1.2)
|
5
5
|
omniauth
|
6
6
|
sinatra
|
7
7
|
|
@@ -77,7 +77,7 @@ GEM
|
|
77
77
|
rack (1.4.5)
|
78
78
|
rack-cache (1.2)
|
79
79
|
rack (>= 0.4)
|
80
|
-
rack-protection (1.5.
|
80
|
+
rack-protection (1.5.3)
|
81
81
|
rack
|
82
82
|
rack-ssl (1.3.3)
|
83
83
|
rack
|
@@ -109,10 +109,10 @@ GEM
|
|
109
109
|
rspec-expectations (2.13.0)
|
110
110
|
diff-lcs (>= 1.1.3, < 2.0)
|
111
111
|
rspec-mocks (2.13.1)
|
112
|
-
sinatra (1.
|
112
|
+
sinatra (1.4.5)
|
113
113
|
rack (~> 1.4)
|
114
|
-
rack-protection (~> 1.
|
115
|
-
tilt (~> 1.3, >= 1.3.
|
114
|
+
rack-protection (~> 1.4)
|
115
|
+
tilt (~> 1.3, >= 1.3.4)
|
116
116
|
sprockets (2.2.2)
|
117
117
|
hike (~> 1.2)
|
118
118
|
multi_json (~> 1.0)
|
@@ -16,9 +16,10 @@ module SimpleAdminAuth
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def self.is_admin?(session)
|
19
|
+
admin_session = get_session_key(session, :admin_user)
|
19
20
|
valid_admin = false
|
20
|
-
if !
|
21
|
-
email =
|
21
|
+
if !admin_session.nil? && !get_session_key(admin_session, :email).nil?
|
22
|
+
email = get_session_key(admin_session, :email)
|
22
23
|
if !SimpleAdminAuth::Configuration.email_white_list.nil?
|
23
24
|
if SimpleAdminAuth::Configuration.email_white_list.include?(email)
|
24
25
|
valid_admin = true
|
@@ -29,6 +30,11 @@ module SimpleAdminAuth
|
|
29
30
|
end
|
30
31
|
valid_admin
|
31
32
|
end
|
33
|
+
|
34
|
+
private
|
35
|
+
def self.get_session_key(hash, symbol)
|
36
|
+
(hash[symbol] || hash[symbol.to_s])
|
37
|
+
end
|
32
38
|
end
|
33
39
|
|
34
40
|
|
data/spec/authenticate_spec.rb
CHANGED
@@ -26,6 +26,15 @@ describe SimpleAdminAuth::Authenticate do
|
|
26
26
|
}
|
27
27
|
end
|
28
28
|
|
29
|
+
let(:admin_string_sessions) do
|
30
|
+
{
|
31
|
+
admin_user:{
|
32
|
+
'email'=> 'admin@example.com',
|
33
|
+
'name'=> 'dummy'
|
34
|
+
}
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
29
38
|
before do
|
30
39
|
SimpleAdminAuth::Configuration.email_white_list = nil
|
31
40
|
end
|
@@ -34,6 +43,10 @@ describe SimpleAdminAuth::Authenticate do
|
|
34
43
|
auth.is_admin?(admin_session).should eq(true)
|
35
44
|
end
|
36
45
|
|
46
|
+
it 'should authenticate if admin email is set in a string key' do
|
47
|
+
auth.is_admin?(admin_string_sessions).should eq(true)
|
48
|
+
end
|
49
|
+
|
37
50
|
it 'should not authenticate with empty session ' do
|
38
51
|
auth.is_admin?({}).should eq(false)
|
39
52
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_admin_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ralf Kistner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: omniauth
|