auther 2.0.0 → 2.1.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: 18370adb7c20520b5fe1a95290e6d0ebc387e26f
4
- data.tar.gz: 83be7320485a4b859bd51ba040145baad8bfd597
3
+ metadata.gz: 18b92be2eec96e15a96b6b5948d50047ca931f84
4
+ data.tar.gz: cc5ff3d9525debbaffa8fdcffc62699f3043f48f
5
5
  SHA512:
6
- metadata.gz: c83a3d37bebb80fe575e2961b4ba54c775cf2f9af45275d8f135417620b0e767255b85233ec542caf16d22f031c8b7491235d13dd6deccba1a47a8b5018ee94a
7
- data.tar.gz: 2a0ed3ede21308c3870e038a4bdad28a8a041fe5777114b3f115996a1371b95da7a549f437b2bab9e88a5c984c0d85a25593b8f6c605ca4db1f221cd01a67311
6
+ metadata.gz: 30217fb220fd13516234275e3c13e9da8e03b76b38fdde89b43f840804fd68ecc89860e4b40382c460cefde19192af186043ec38f94e1eb2fafb440869c4a3fb
7
+ data.tar.gz: fbd2f2b8e4d6a9ab9767a1a8332657c2e74f51b1d37cbb47d90b4f5b59c81387b649f5d9246dbbb853e9a5489f04be4113e2c2ad8ba672ff7dbfb556526ccda3
Binary file
data.tar.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -55,11 +55,11 @@ Add the following to your Gemfile:
55
55
 
56
56
  Run the generator to configure and initialize your application:
57
57
 
58
- bin/rails generate auther:install
58
+ rails generate auther:install
59
59
 
60
60
  # Usage
61
61
 
62
- Using the setup examples, from above, launch your Rails application and visit either of the following routes:
62
+ Launch your Rails application and visit either of the following routes:
63
63
 
64
64
  http://localhost:3000/login
65
65
  http://localhost:3000/admin/example # Assumes this route exists. Will redirect to /login if not authorized.
@@ -69,17 +69,6 @@ Use the following credentials to login:
69
69
  * Login: test@test.com
70
70
  * Password: password
71
71
 
72
- To encrypt/decrypt account credentials, launch a rails console and type the following:
73
-
74
- # Best if more than 150 characters and gibberish to read. Must be the same as defined in auther settings.
75
- cipher = Auther::Cipher.new "vuKrwD9XWoYuv@s99?tR(9VqryiL,KV{W7wFnejUa4QcVBP+D{2rD4JfuD(mXgA=$tNK4Pfn#NeGs3o3TZ3CqNc^Qb"
76
-
77
- # Do this to encrypt an unecrypted value.
78
- cipher.encrypt "test@test.com"
79
-
80
- # Do this to decrypt an encrypted value.
81
- cipher.decrypt "N3JzR213WlBISDZsMjJQNkRXbEVmYVczbVdnMHRYVHRud29lOWRCekp6ST0tLWpFMkROekUvWDBkOHZ4ZngxZHV6clE9PQ==--cd863c39991fa4bb9a35de918aa16da54514e331"
82
-
83
72
  # Customization
84
73
 
85
74
  ## Initializer
@@ -100,6 +89,18 @@ The initializer comes installed with the following settings:
100
89
  ]
101
90
  }
102
91
 
92
+ **IMPORTANT**: The encrypted login/password credentials must be changed and re-encrypted before deploying to production!
93
+ To encrypt/decrypt account credentials, launch a rails console and run the following:
94
+
95
+ # Best if more than 150 characters and gibberish to read. Must be the same as defined in auther settings.
96
+ cipher = Auther::Cipher.new "vuKrwD9XWoYuv@s99?tR(9VqryiL,KV{W7wFnejUa4QcVBP+D{2rD4JfuD(mXgA=$tNK4Pfn#NeGs3o3TZ3CqNc^Qb"
97
+
98
+ # Do this to encrypt an unecrypted value.
99
+ cipher.encrypt "test@test.com"
100
+
101
+ # Do this to decrypt an encrypted value.
102
+ cipher.decrypt "N3JzR213WlBISDZsMjJQNkRXbEVmYVczbVdnMHRYVHRud29lOWRCekp6ST0tLWpFMkROekUvWDBkOHZ4ZngxZHV6clE9PQ==--cd863c39991fa4bb9a35de918aa16da54514e331"
103
+
103
104
  The initializer can be customized as follows:
104
105
 
105
106
  * *title* - Optional. The HTML page title (as rendered within a browser tab). Default: "Authorization".
@@ -187,11 +188,18 @@ Auther settings:
187
188
 
188
189
  # Tests
189
190
 
190
- To test, do the following:
191
+ To test, run:
192
+
193
+ bundle exec rspec spec
194
+
195
+ # Upgrading
196
+
197
+ For those using Auther 1.x.x, there are a few minor changes to be applied in order to upgrade to 2.x.x:
191
198
 
192
- 0. cd to the gem root.
193
- 0. bundle install
194
- 0. bundle exec rspec spec
199
+ 0. Move the old Auther settings (i.e. `config/application.rb`) into an Auther initilizer (i.e.
200
+ `config/initializers/auther.rb`). Read the *Customization* section above for additional instruction.
201
+ 0. All account settings have changed from `login` and `password` to `encrypted_login` and `encrypted_password` keys.
202
+ 0. The `success_url` account settings have been renamed to `authorized_url`.
195
203
 
196
204
  # Troubleshooting
197
205
 
@@ -208,7 +216,7 @@ To test, do the following:
208
216
 
209
217
  # Contributions
210
218
 
211
- Read CONTRIBUTING for details.
219
+ Read [CONTRIBUTING](CONTRIBUTING.md) for details.
212
220
 
213
221
  # Credits
214
222
 
@@ -217,9 +225,9 @@ Developed by [Brooke Kuhlmann](http://www.alchemists.io) at [Alchemists](http://
217
225
  # License
218
226
 
219
227
  Copyright (c) 2014 [Alchemists](http://www.alchemists.io).
220
- Read the LICENSE for details.
228
+ Read the [LICENSE](LICENSE.md) for details.
221
229
 
222
230
  # History
223
231
 
224
- Read the CHANGELOG for details.
232
+ Read the [CHANGELOG](CHANGELOG.md) for details.
225
233
  Built with [Gemsmith](https://github.com/bkuhlmann/gemsmith).
@@ -54,9 +54,9 @@ module Auther
54
54
  details = %(Account: "#{account_name}". Blacklist: #{blacklist}. Request Path: "#{request_path}".)
55
55
 
56
56
  if authorized
57
- log_info %(Authorization failed! #{details})
58
- else
59
57
  log_info %(Authorization passed. #{details})
58
+ else
59
+ log_info %(Authorization failed! #{details})
60
60
  end
61
61
  end
62
62
 
@@ -73,14 +73,13 @@ module Auther
73
73
  paths.map { |path| path.chomp '/' }
74
74
  end
75
75
 
76
- def blacklisted_paths accounts
77
- paths = accounts.map { |account| clean_paths account.fetch(:paths) }
76
+ def blacklisted_paths
77
+ paths = settings.accounts.map { |account| clean_paths account.fetch(:paths) }
78
78
  paths.flatten.uniq
79
79
  end
80
80
 
81
- def blacklisted_matched_paths accounts, path
82
- paths = blacklisted_paths accounts
83
- paths.select { |blacklisted_path| path.include? blacklisted_path }
81
+ def blacklisted_matched_paths path
82
+ blacklisted_paths.select { |blacklisted_path| path.include? blacklisted_path }
84
83
  end
85
84
 
86
85
  def authenticated? account
@@ -103,21 +102,20 @@ module Auther
103
102
  end
104
103
 
105
104
  def account_authorized? account, path
106
- paths = clean_paths account.fetch(:paths)
105
+ all_paths = blacklisted_paths
106
+ account_paths = clean_paths account.fetch(:paths)
107
+ restricted_paths = all_paths - account_paths
107
108
 
108
- authorized = paths.include? path
109
- log_authorization authorized, account.fetch(:name), paths, request.path
109
+ authorized = !restricted_paths.include?(path)
110
+ log_authorization authorized, account.fetch(:name), all_paths, request.path
110
111
  authorized
111
112
  end
112
113
 
113
114
  def authorized? path
114
- accounts = settings.accounts
115
- all_blacklisted_paths = blacklisted_paths settings.accounts
116
-
117
- if blacklisted_matched_paths(accounts, path).any?
118
- log_info %(Requested path "#{request.path}" found in blacklisted paths: #{all_blacklisted_paths}.)
115
+ if blacklisted_matched_paths(path).any?
116
+ log_info %(Requested path "#{request.path}" found in blacklisted paths: #{blacklisted_paths}.)
119
117
  account = find_account
120
- account && authenticated?(account) && !account_authorized?(account, path)
118
+ account && authenticated?(account) && account_authorized?(account, path)
121
119
  else
122
120
  true
123
121
  end
@@ -1,3 +1,3 @@
1
1
  module Auther
2
- VERSION = "2.0.0"
2
+ VERSION = "2.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auther
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -30,7 +30,7 @@ cert_chain:
30
30
  SJpzzzZ8gO6BKn4fhd+ENNQ333Qy3nuNk07TVIaNnlgeHhowUDuD9T7Z8Lka0pt3
31
31
  4PteiTppsf0SSVAM9zSO5IuFngXMRwWgvjOfXE70f43RDuUVTCSyylc=
32
32
  -----END CERTIFICATE-----
33
- date: 2014-06-12 00:00:00.000000000 Z
33
+ date: 2014-06-17 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: pry-byebug
metadata.gz.sig CHANGED
Binary file