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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6a986cc9e5ccad0067a27efcb24d31decc3e7a12
4
- data.tar.gz: fd798bfdf54add7433fa9310bf2c274e82b0446c
3
+ metadata.gz: 778f7b2792642130800e0aef4ad721a01dd88e16
4
+ data.tar.gz: 31b9f1072e04c83111dc2a474940492e8f772b24
5
5
  SHA512:
6
- metadata.gz: e077f215921a2a723d8f27dae8f91144f683921e020c438d0bde2fc6c0bb300a802ca4040e85931e1ed475ac6da67ca663710cc59907147b060b5a361d9ee429
7
- data.tar.gz: a5e16f8d88a326d973e240e1960371b274225f36a3b45b737972fc97da1ddba10cb1d61bdb9a8e7403bb469d463968259e5340cc563a64f81a8b917e5b023756
6
+ metadata.gz: e036b37199c206b719a78d891c6323fe75dd3bc9ddf54f077aa42f4beee9a2325744e469834f04c8390a1fc8f682e8254e871c1443c5ac147d29282211165948
7
+ data.tar.gz: 4bbf83c4be4ca06576796991c5cf5d8ccda44b002b1e85ee83c3efb286b5ff1a3e493c4f1c13d90ab161c2ed450b265a59e922df9c72dc92bee34fed32d3010d
data/.travis.yml CHANGED
@@ -2,8 +2,7 @@ language: ruby
2
2
  script: "bundle exec rspec"
3
3
 
4
4
  rvm:
5
- - 1.9.3
6
- - 2.0.0
5
+ - 2.1.2
7
6
 
8
7
  gemfile:
9
8
  - gemfiles/rack1.5.gemfile
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- simple_admin_auth (0.1.0)
4
+ simple_admin_auth (0.1.2)
5
5
  omniauth
6
6
  sinatra
7
7
 
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 +1,9 @@
1
1
  require "bundler/gem_tasks"
2
+
3
+ task :update_gemfiles do
4
+ puts "Run all of the following:"
5
+ puts "bundle install"
6
+ Dir['gemfiles/*.gemfile'].each do |gemfile|
7
+ puts "BUNDLE_GEMFILE=#{gemfile} bundle install"
8
+ end
9
+ end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- simple_admin_auth (0.1.0)
4
+ simple_admin_auth (0.1.2)
5
5
  omniauth
6
6
  sinatra
7
7
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- simple_admin_auth (0.1.0)
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.0)
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.3.6)
112
+ sinatra (1.4.5)
113
113
  rack (~> 1.4)
114
- rack-protection (~> 1.3)
115
- tilt (~> 1.3, >= 1.3.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)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- simple_admin_auth (0.1.0)
4
+ simple_admin_auth (0.1.2)
5
5
  omniauth
6
6
  sinatra
7
7
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- simple_admin_auth (0.1.0)
4
+ simple_admin_auth (0.1.2)
5
5
  omniauth
6
6
  sinatra
7
7
 
@@ -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 !session[:admin_user].nil? && !session[:admin_user][:email].nil?
21
- email = session[:admin_user][: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
 
@@ -1,3 +1,3 @@
1
1
  module SimpleAdminAuth
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -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.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-08 00:00:00.000000000 Z
11
+ date: 2014-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth