auther 11.0.1 → 11.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/{LICENSE.md → LICENSE.adoc} +29 -30
- data/README.adoc +287 -0
- data/lib/auther/identity.rb +4 -15
- data/lib/generators/auther/templates/config/initializers/auther.rb +6 -4
- metadata +35 -244
- metadata.gz.sig +0 -0
- data/README.md +0 -265
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 590812ac265799c3eb356e49267da0d75a2ea050820b9cf72676ccfa72e419ed
|
4
|
+
data.tar.gz: 4215dead012e7e3a544ac8f87511d47a43ff7507b3f247dbb64d531695b2e6a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5638be14962f52ea0edc46cb3d3acc559d86a77cb86fc29641049eed37849e73bf8b896fe61ca2b3f2f94e6ac90dc0da97b2466c9b8e5afb13a3d5f42fb0af2
|
7
|
+
data.tar.gz: 82353fd9fb2db14f060cddc04b09f2eaea209a4e511f77c8f701c3cd005fd820973734af3aa65e721e12bb920024f715fabd80d0f36ec4f111d0fc993ef683e1
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/{LICENSE.md → LICENSE.adoc}
RENAMED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
= Apache License
|
2
2
|
|
3
3
|
Version 2.0, January 2004
|
4
4
|
|
@@ -6,7 +6,7 @@ http://www.apache.org/licenses
|
|
6
6
|
|
7
7
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
8
8
|
|
9
|
-
|
9
|
+
== 1. Definitions
|
10
10
|
|
11
11
|
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by
|
12
12
|
Sections 1 through 9 of this document.
|
@@ -54,14 +54,14 @@ Contribution."
|
|
54
54
|
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a
|
55
55
|
Contribution has been received by Licensor and subsequently incorporated within the Work.
|
56
56
|
|
57
|
-
|
57
|
+
== 2. Grant of Copyright License
|
58
58
|
|
59
59
|
Subject to the terms and conditions of this License, each Contributor hereby grants to You a
|
60
60
|
perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to
|
61
61
|
reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and
|
62
62
|
distribute the Work and such Derivative Works in Source or Object form.
|
63
63
|
|
64
|
-
|
64
|
+
== 3. Grant of Patent License
|
65
65
|
|
66
66
|
Subject to the terms and conditions of this License, each Contributor hereby grants to You a
|
67
67
|
perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this
|
@@ -74,39 +74,38 @@ a Contribution incorporated within the Work constitutes direct or contributory p
|
|
74
74
|
then any patent licenses granted to You under this License for that Work shall terminate as of the
|
75
75
|
date such litigation is filed.
|
76
76
|
|
77
|
-
|
77
|
+
== 4. Redistribution
|
78
78
|
|
79
79
|
You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with
|
80
80
|
or without modifications, and in Source or Object form, provided that You meet the following
|
81
81
|
conditions:
|
82
82
|
|
83
|
-
|
83
|
+
. You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
84
84
|
|
85
|
-
|
86
|
-
|
85
|
+
. You must cause any modified files to carry prominent notices stating that You changed the files;
|
86
|
+
and
|
87
87
|
|
88
|
-
|
89
|
-
|
90
|
-
|
88
|
+
. You must retain, in the Source form of any Derivative Works that You distribute, all copyright,
|
89
|
+
patent, trademark, and attribution notices from the Source form of the Work, excluding those
|
90
|
+
notices that do not pertain to any part of the Derivative Works; and
|
91
91
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
construed as modifying the License.
|
92
|
+
. If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works
|
93
|
+
that You distribute must include a readable copy of the attribution notices contained within such
|
94
|
+
NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in
|
95
|
+
at least one of the following places: within a NOTICE text file distributed as part of the
|
96
|
+
Derivative Works; within the Source form or documentation, if provided along with the Derivative
|
97
|
+
Works; or, within a display generated by the Derivative Works, if and wherever such third-party
|
98
|
+
notices normally appear. The contents of the NOTICE file are for informational purposes only and
|
99
|
+
do not modify the License. You may add Your own attribution notices within Derivative Works that
|
100
|
+
You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such
|
101
|
+
additional attribution notices cannot be construed as modifying the License.
|
103
102
|
|
104
103
|
You may add Your own copyright statement to Your modifications and may provide additional or
|
105
104
|
different license terms and conditions for use, reproduction, or distribution of Your modifications,
|
106
105
|
or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of
|
107
106
|
the Work otherwise complies with the conditions stated in this License.
|
108
107
|
|
109
|
-
|
108
|
+
== 5. Submission of Contributions
|
110
109
|
|
111
110
|
Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the
|
112
111
|
Work by You to the Licensor shall be under the terms and conditions of this License, without any
|
@@ -114,13 +113,13 @@ additional terms or conditions. Notwithstanding the above, nothing herein shall
|
|
114
113
|
the terms of any separate license agreement you may have executed with Licensor regarding such
|
115
114
|
Contributions.
|
116
115
|
|
117
|
-
|
116
|
+
== 6. Trademarks
|
118
117
|
|
119
118
|
This License does not grant permission to use the trade names, trademarks, service marks, or product
|
120
119
|
names of the Licensor, except as required for reasonable and customary use in describing the origin
|
121
120
|
of the Work and reproducing the content of the NOTICE file.
|
122
121
|
|
123
|
-
|
122
|
+
== 7. Disclaimer of Warranty
|
124
123
|
|
125
124
|
Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each
|
126
125
|
Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
@@ -129,7 +128,7 @@ TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. Y
|
|
129
128
|
responsible for determining the appropriateness of using or redistributing the Work and assume any
|
130
129
|
risks associated with Your exercise of permissions under this License.
|
131
130
|
|
132
|
-
|
131
|
+
== 8. Limitation of Liability
|
133
132
|
|
134
133
|
In no event and under no legal theory, whether in tort (including negligence), contract, or
|
135
134
|
otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or
|
@@ -139,7 +138,7 @@ License or out of the use or inability to use the Work (including but not limite
|
|
139
138
|
loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial
|
140
139
|
damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
141
140
|
|
142
|
-
|
141
|
+
== 9. Accepting Warranty or Additional Liability
|
143
142
|
|
144
143
|
While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee
|
145
144
|
for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights
|
@@ -151,11 +150,11 @@ additional liability.
|
|
151
150
|
|
152
151
|
END OF TERMS AND CONDITIONS
|
153
152
|
|
154
|
-
Copyright 2014
|
153
|
+
Copyright 2014 link:https://www.alchemists.io/team/brooke_kuhlmann[Brooke Kuhlmann].
|
155
154
|
|
156
155
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
|
157
|
-
compliance with the License. You may obtain a
|
158
|
-
the License.
|
156
|
+
compliance with the License. You may obtain a link:https://www.apache.org/licenses/LICENSE-2.0[copy]
|
157
|
+
of the License.
|
159
158
|
|
160
159
|
Unless required by applicable law or agreed to in writing, software distributed under the License is
|
161
160
|
distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
data/README.adoc
ADDED
@@ -0,0 +1,287 @@
|
|
1
|
+
:toc: macro
|
2
|
+
:toclevels: 5
|
3
|
+
:figure-caption!:
|
4
|
+
|
5
|
+
= Auther
|
6
|
+
|
7
|
+
[link=http://badge.fury.io/rb/auther]
|
8
|
+
image::https://badge.fury.io/rb/auther.svg[Gem Version]
|
9
|
+
[link=https://www.alchemists.io/projects/code_quality]
|
10
|
+
image::https://img.shields.io/badge/code_style-alchemists-brightgreen.svg[Alchemists Style Guide]
|
11
|
+
[link=https://circleci.com/gh/bkuhlmann/auther]
|
12
|
+
image::https://circleci.com/gh/bkuhlmann/auther.svg?style=svg[Circle CI Status]
|
13
|
+
|
14
|
+
Provides simple, form-based authentication for apps that need security but don't want to deal with
|
15
|
+
the clunky UI of HTTP Basic Authentication or something as heavyweight as
|
16
|
+
link:https://github.com/plataformatec/devise[Devise]. It doesn't require a database and is
|
17
|
+
compatible with password managers like link:https://agilebits.com/onepassword[1Password] making for
|
18
|
+
a pleasant user experience.
|
19
|
+
|
20
|
+
toc::[]
|
21
|
+
|
22
|
+
== Features
|
23
|
+
|
24
|
+
* Supports form-based authentication compatible with password managers like
|
25
|
+
link:https://agilebits.com/onepassword[1Password].
|
26
|
+
|
27
|
+
image::https://www.alchemists.io/images/projects/auther/screenshots/form-without_errors.png[Form Without Errors Screenshot]
|
28
|
+
image::https://www.alchemists.io/images/projects/auther/screenshots/form-with_errors.png[Form With Errors Screenshot]
|
29
|
+
|
30
|
+
* Uses CSS Flexbox for lightweight styling.
|
31
|
+
* Uses encrypted account credentials to keep sensitive information secure.
|
32
|
+
* Supports multiple accounts with optional path exclude lists.
|
33
|
+
* Supports customizable routes, models, presenters, views, controllers, and loggers.
|
34
|
+
* Provides a generator for easy install and setup within an existing project.
|
35
|
+
* Provides auto-redirection to requested path for verified credentials.
|
36
|
+
|
37
|
+
== Requirements
|
38
|
+
|
39
|
+
. link:https://www.ruby-lang.org[Ruby]
|
40
|
+
. link:https://rubyonrails.org[Ruby on Rails]
|
41
|
+
|
42
|
+
== Setup
|
43
|
+
|
44
|
+
To install, run:
|
45
|
+
|
46
|
+
[source,bash]
|
47
|
+
----
|
48
|
+
gem install auther
|
49
|
+
----
|
50
|
+
|
51
|
+
Add the following to your Gemfile:
|
52
|
+
|
53
|
+
[source,ruby]
|
54
|
+
----
|
55
|
+
gem "auther"
|
56
|
+
----
|
57
|
+
|
58
|
+
Run the install generator to configure and initialize your application:
|
59
|
+
|
60
|
+
[source,bash]
|
61
|
+
----
|
62
|
+
rails generate auther:install
|
63
|
+
----
|
64
|
+
|
65
|
+
Run the credentials generator to generate credentials for your application:
|
66
|
+
|
67
|
+
[source,bash]
|
68
|
+
----
|
69
|
+
rails generate auther:credentials
|
70
|
+
----
|
71
|
+
|
72
|
+
If using link:https://direnv.net[direnv], for example, you can copy and paste the generated
|
73
|
+
credentials into your `.envrc` file. Example:
|
74
|
+
|
75
|
+
image::https://www.alchemists.io/images/projects/auther/screenshots/credentials_generator.jpg[Credentials Generator Screenshot]
|
76
|
+
|
77
|
+
== Usage
|
78
|
+
|
79
|
+
Launch your Rails application and visit the following: `http://localhost:3000/login`. Enter your
|
80
|
+
login and password as used for the `rails generate auther:credentials` generator and you'll be
|
81
|
+
logged in.
|
82
|
+
|
83
|
+
=== Initializer
|
84
|
+
|
85
|
+
The initializer (installed during setup) can be found here: `config/initializers/auther.rb`. The
|
86
|
+
initializer comes installed with the following settings:
|
87
|
+
|
88
|
+
[source,ruby]
|
89
|
+
----
|
90
|
+
Rails.application.config.auther_settings = {
|
91
|
+
accounts: [
|
92
|
+
{
|
93
|
+
name: "admin",
|
94
|
+
encrypted_login: ENV["AUTHER_ADMIN_LOGIN"],
|
95
|
+
encrypted_password: ENV["AUTHER_ADMIN_PASSWORD"],
|
96
|
+
paths: ["/admin"]
|
97
|
+
}
|
98
|
+
],
|
99
|
+
secret: ENV["AUTHER_SECRET"]
|
100
|
+
}
|
101
|
+
----
|
102
|
+
|
103
|
+
To encrypt/decrypt account credentials, launch a rails console and run the following:
|
104
|
+
|
105
|
+
[source,ruby]
|
106
|
+
----
|
107
|
+
# The secret as defined in `auther_settings` and/or produced by the credentials generator.
|
108
|
+
secret = SecureRandom.hex 16 # "426a7f46548a1a4518676a8e246517d8"
|
109
|
+
|
110
|
+
# The cipher for encrypting/decrypting values.
|
111
|
+
cipher = Auther::Cipher.new secret
|
112
|
+
|
113
|
+
# Use the following to encrypt an unecrypted value.
|
114
|
+
cipher.encrypt "test@test.com"
|
115
|
+
|
116
|
+
# Use the following to decrypt an encrypted value.
|
117
|
+
cipher.decrypt "hWToltdpl+uZJBPELKNC7Ij++jPkTuo=--nEdbOYL9fIRh14hY--fU+VSCd4+DDOhOmG1gzRfQ=="
|
118
|
+
----
|
119
|
+
|
120
|
+
The initializer can be customized as follows:
|
121
|
+
|
122
|
+
* `title` - Optional. The HTML page title (as rendered within a browser tab). Default:
|
123
|
+
`"Authorization"`.
|
124
|
+
* `label` - Optional. The page label (what would appear above the form). Default: `"Authorization"`.
|
125
|
+
* `secret` - Required. The secret passphrase used to encrypt/decrypt account credentials.
|
126
|
+
* `accounts` - Required. The array of accounts with different or similar access to the application.
|
127
|
+
** `name` - Required. The account name that uniquely identifies the account.
|
128
|
+
** `encrypted_login` - Required. The encrypted account login.
|
129
|
+
** `encrypted_password` - Required. The encrypted account password.
|
130
|
+
** `paths` - Required. The array of excluded paths for which only this account has access to.
|
131
|
+
** `authorized_url` - Optional. The URL to redirect to upon successful authorization. Authorized
|
132
|
+
redirection works in the order defined:
|
133
|
+
*** The excluded path (if requested prior to authorization but now authorized).
|
134
|
+
*** The authorized URL (if defined and the excluded path wasn't requested).
|
135
|
+
*** The root path (if none of the above).
|
136
|
+
** `deauthorized_url` - Optional. The URL to redirect to upon successful deauthorization (i.e.
|
137
|
+
logout). Deauthorized redirections works as follows (in the order defined):
|
138
|
+
*** The deauthorized URL (if defined).
|
139
|
+
*** The auth URL.
|
140
|
+
* `url` - Optional. The URL to redirect to when enforcing authentication. Default: `"/login"`.
|
141
|
+
* `logger` - Optional. The logger used to log path/account authorization messages. Default:
|
142
|
+
`Auther::NullLogger`.
|
143
|
+
|
144
|
+
=== Routes
|
145
|
+
|
146
|
+
The routes can be customized as follows (installed, by default, via the install generator):
|
147
|
+
|
148
|
+
[source,ruby]
|
149
|
+
----
|
150
|
+
Rails.application.routes.draw do
|
151
|
+
mount Auther::Engine => "/auther"
|
152
|
+
get "/login", to: "auther/session#new", as: "login"
|
153
|
+
delete "/logout", to: "auther/session#destroy", as: "logout"
|
154
|
+
end
|
155
|
+
----
|
156
|
+
|
157
|
+
=== Model
|
158
|
+
|
159
|
+
The `Auther::Account` is a struct that uses ActiveModel validations to aid in attribute validation.
|
160
|
+
This model could potentially be replaced with a database-backed object (would require controller
|
161
|
+
customization)...but you should question if you have outgrown the use of this gem and need a
|
162
|
+
different solution altogether if it comes to that.
|
163
|
+
|
164
|
+
=== Presenter
|
165
|
+
|
166
|
+
The `Auther::Presenter::Account` is a plain old Ruby object that uses ActiveModel validations to aid
|
167
|
+
in form validation. This presenter makes it easy to construct form data for input and validation.
|
168
|
+
|
169
|
+
=== View
|
170
|
+
|
171
|
+
The view can be customized by creating the following file within your Rails application (assumes
|
172
|
+
that the default `Auther::SessionController` implementation is sufficient):
|
173
|
+
`app/views/auther/session/new.html`.
|
174
|
+
|
175
|
+
The form uses the `@account` instance variable which is an instance of the
|
176
|
+
`Auther::Presenter::Account` presenter (as mentioned above). The form can be stylized by modifying
|
177
|
+
the styles found in the `auther.scss` stylesheet.
|
178
|
+
|
179
|
+
=== Controller
|
180
|
+
|
181
|
+
The `Auther::SessionController` inherits from the `Auther::BaseController`. To customize, it is
|
182
|
+
recommended that you add a controller to your app that inherits from the `Auther::BaseController`.
|
183
|
+
Example:
|
184
|
+
|
185
|
+
[source,ruby]
|
186
|
+
----
|
187
|
+
# Example Path: app/controllers/session_controller.rb
|
188
|
+
class SessionController < Auther::BaseController
|
189
|
+
layout "example"
|
190
|
+
end
|
191
|
+
----
|
192
|
+
|
193
|
+
This allows customization of session controller behavior to serve any special business needs. See
|
194
|
+
the `Auther::BaseController` for additional details or the `Auther::SessionController` for default
|
195
|
+
implementation.
|
196
|
+
|
197
|
+
=== Logging
|
198
|
+
|
199
|
+
As mentioned in the setup above, the logger can be customized as follows:
|
200
|
+
|
201
|
+
[source,ruby]
|
202
|
+
----
|
203
|
+
# This is the default logger silences all logging attempts.
|
204
|
+
Auther::NullLogger.new
|
205
|
+
|
206
|
+
# Can be used to log to the environment log.
|
207
|
+
ActiveSupport::Logger.new "log/#{Rails.env}.log"
|
208
|
+
|
209
|
+
# Can be used to log to standard output.
|
210
|
+
Logger.new STDOUT
|
211
|
+
----
|
212
|
+
|
213
|
+
When logging is enabled, you'll be able to see the following information in the server logs to help
|
214
|
+
debug custom Auther settings:
|
215
|
+
|
216
|
+
* Requested path and excluded path detection.
|
217
|
+
* Finding (or not finding) of account.
|
218
|
+
* Account authentication pass/fail.
|
219
|
+
* Account and path authorization pass/fail.
|
220
|
+
|
221
|
+
=== Troubleshooting
|
222
|
+
|
223
|
+
* If upgrading Rails, changing the cookie/session settings, generating a new secret base key, etc.
|
224
|
+
this might cause Auther authentication to fail. Make sure to clear your browser cookies in this
|
225
|
+
situation or use Google Chrome (incognito mode) to verify.
|
226
|
+
* If the authentication view/form looks broken (stylewise) this could be due to custom
|
227
|
+
`ActionView::Base.field_error_proc` settings defined by your app (usually via an initializer).
|
228
|
+
Auther uses this configuration `ActionView::Base.field_error_proc = proc { |html_tag, _|
|
229
|
+
html_tag.html_safe }` so that no additional markup is added to the DOM when errors are raised. If
|
230
|
+
you have customized this to something else, you might want to read the usage documentation
|
231
|
+
(mentioned above) to rebuild the authentication view/form for your specific business needs.
|
232
|
+
|
233
|
+
== Development
|
234
|
+
|
235
|
+
To contribute, run:
|
236
|
+
|
237
|
+
[source,bash]
|
238
|
+
----
|
239
|
+
git clone https://github.com/bkuhlmann/auther.git
|
240
|
+
cd auther
|
241
|
+
bin/setup
|
242
|
+
----
|
243
|
+
|
244
|
+
You can also use the IRB console for direct access to all objects:
|
245
|
+
|
246
|
+
[source,bash]
|
247
|
+
----
|
248
|
+
bin/console
|
249
|
+
----
|
250
|
+
|
251
|
+
== Tests
|
252
|
+
|
253
|
+
To test, run:
|
254
|
+
|
255
|
+
[source,bash]
|
256
|
+
----
|
257
|
+
bundle exec rake
|
258
|
+
----
|
259
|
+
|
260
|
+
== Versioning
|
261
|
+
|
262
|
+
Read link:https://semver.org[Semantic Versioning] for details. Briefly, it means:
|
263
|
+
|
264
|
+
* Major (X.y.z) - Incremented for any backwards incompatible public API changes.
|
265
|
+
* Minor (x.Y.z) - Incremented for new, backwards compatible, public API enhancements/fixes.
|
266
|
+
* Patch (x.y.Z) - Incremented for small, backwards compatible, bug fixes.
|
267
|
+
|
268
|
+
== Code of Conduct
|
269
|
+
|
270
|
+
Please note that this project is released with a link:CODE_OF_CONDUCT.adoc[CODE OF CONDUCT]. By
|
271
|
+
participating in this project you agree to abide by its terms.
|
272
|
+
|
273
|
+
== Contributions
|
274
|
+
|
275
|
+
Read link:CONTRIBUTING.adoc[CONTRIBUTING] for details.
|
276
|
+
|
277
|
+
== License
|
278
|
+
|
279
|
+
Read link:LICENSE.adoc[LICENSE] for details.
|
280
|
+
|
281
|
+
== History
|
282
|
+
|
283
|
+
Read link:CHANGES.adoc[CHANGES] for details.
|
284
|
+
|
285
|
+
== Credits
|
286
|
+
|
287
|
+
Engineered by link:https://www.alchemists.io/team/brooke_kuhlmann[Brooke Kuhlmann].
|
data/lib/auther/identity.rb
CHANGED
@@ -3,20 +3,9 @@
|
|
3
3
|
module Auther
|
4
4
|
# Gem identity information.
|
5
5
|
module Identity
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
def self.label
|
11
|
-
"Auther"
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.version
|
15
|
-
"11.0.1"
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.version_label
|
19
|
-
"#{label} #{version}"
|
20
|
-
end
|
6
|
+
NAME = "auther"
|
7
|
+
LABEL = "Auther"
|
8
|
+
VERSION = "11.5.0"
|
9
|
+
VERSION_LABEL = "#{LABEL} #{VERSION}"
|
21
10
|
end
|
22
11
|
end
|
@@ -2,10 +2,12 @@
|
|
2
2
|
|
3
3
|
Rails.application.config.auther_settings = {
|
4
4
|
accounts: [
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
{
|
6
|
+
name: "admin",
|
7
|
+
encrypted_login: ENV["AUTHER_ADMIN_LOGIN"],
|
8
|
+
encrypted_password: ENV["AUTHER_ADMIN_PASSWORD"],
|
9
|
+
paths: ["/admin"]
|
10
|
+
}
|
9
11
|
],
|
10
12
|
secret: ENV["AUTHER_SECRET"]
|
11
13
|
}
|
metadata
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: auther
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 11.0
|
4
|
+
version: 11.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brooke Kuhlmann
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
MIIC/
|
14
|
-
|
15
|
-
|
13
|
+
MIIC/jCCAeagAwIBAgIBAzANBgkqhkiG9w0BAQsFADAlMSMwIQYDVQQDDBpicm9v
|
14
|
+
a2UvREM9YWxjaGVtaXN0cy9EQz1pbzAeFw0yMDAzMTUxNDQ1MzJaFw0yMTAzMTUx
|
15
|
+
NDQ1MzJaMCUxIzAhBgNVBAMMGmJyb29rZS9EQz1hbGNoZW1pc3RzL0RDPWlvMIIB
|
16
16
|
IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA6l1qpXTiomH1RfMRloyw7MiE
|
17
17
|
xyVx/x8Yc3EupdH7uhNaTXQGyORN6aOY//1QXXMHIZ9tW74nZLhesWMSUMYy0XhB
|
18
18
|
brs+KkurHnc9FnEJAbG7ebGvl/ncqZt72nQvaxpDxvuCBHgJAz+8i5wl6FhLw+oT
|
@@ -20,15 +20,15 @@ cert_chain:
|
|
20
20
|
D5vkU0YlAm1r98BymuJlcQ1qdkVEI1d48ph4kcS0S0nv1RiuyVb6TCAR3Nu3VaVq
|
21
21
|
3fPzZKJLZBx67UvXdbdicWPiUR75elI4PXpLIic3xytaF52ZJYyKZCNZJhNwfQID
|
22
22
|
AQABozkwNzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU0nzow9vc
|
23
|
-
2CdikiiE3fJhP/
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
23
|
+
2CdikiiE3fJhP/gY4ggwDQYJKoZIhvcNAQELBQADggEBAIHhAlD3po4sTYqacXaQ
|
24
|
+
XI9jIhrfMy//2PgbHWcETtlJPBeNUbbSNBABcllUHKqYsVDlSvSmss034KSWNR8F
|
25
|
+
bF1GcloicyvcCC4y6IoW4it0COAcdeaaxkxiBSgKdQFpff9REnDlIKK4uQ9lLxIo
|
26
|
+
Y2G5xubiziKZkyfWFuSr67PIjW3Bu673D1JVBArhA1qbgQmYQcy1CkGOjo+iO8Nf
|
27
|
+
7u/QSfBHb+r/bXhKscDgPpnKwbUmvgO2+94zJG9KsrmIydlzYfsD09aXKx0t6Xy4
|
28
|
+
2XV8FRa7/JimI07sPLC13eLY3xd/aYTi85Z782KIA4j0G8XEEWAX0ouBhlXPocZv
|
29
|
+
QWc=
|
30
30
|
-----END CERTIFICATE-----
|
31
|
-
date: 2020-
|
31
|
+
date: 2020-12-14 00:00:00.000000000 Z
|
32
32
|
dependencies:
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: rails
|
@@ -45,268 +45,58 @@ dependencies:
|
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '6.0'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
48
|
+
name: refinements
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
53
|
+
version: '7.16'
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
60
|
+
version: '7.16'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
|
-
name:
|
62
|
+
name: sass-rails
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
65
|
- - "~>"
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
67
|
+
version: '6.0'
|
68
68
|
type: :runtime
|
69
69
|
prerelease: false
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
72
|
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
75
|
-
- !ruby/object:Gem::Dependency
|
76
|
-
name: ammeter
|
77
|
-
requirement: !ruby/object:Gem::Requirement
|
78
|
-
requirements:
|
79
|
-
- - "~>"
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
version: '1.1'
|
82
|
-
type: :development
|
83
|
-
prerelease: false
|
84
|
-
version_requirements: !ruby/object:Gem::Requirement
|
85
|
-
requirements:
|
86
|
-
- - "~>"
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version: '1.1'
|
89
|
-
- !ruby/object:Gem::Dependency
|
90
|
-
name: bundler-audit
|
91
|
-
requirement: !ruby/object:Gem::Requirement
|
92
|
-
requirements:
|
93
|
-
- - "~>"
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
version: '0.6'
|
96
|
-
type: :development
|
97
|
-
prerelease: false
|
98
|
-
version_requirements: !ruby/object:Gem::Requirement
|
99
|
-
requirements:
|
100
|
-
- - "~>"
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
version: '0.6'
|
103
|
-
- !ruby/object:Gem::Dependency
|
104
|
-
name: gemsmith
|
105
|
-
requirement: !ruby/object:Gem::Requirement
|
106
|
-
requirements:
|
107
|
-
- - "~>"
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: '14.0'
|
110
|
-
type: :development
|
111
|
-
prerelease: false
|
112
|
-
version_requirements: !ruby/object:Gem::Requirement
|
113
|
-
requirements:
|
114
|
-
- - "~>"
|
115
|
-
- !ruby/object:Gem::Version
|
116
|
-
version: '14.0'
|
117
|
-
- !ruby/object:Gem::Dependency
|
118
|
-
name: git-cop
|
119
|
-
requirement: !ruby/object:Gem::Requirement
|
120
|
-
requirements:
|
121
|
-
- - "~>"
|
122
|
-
- !ruby/object:Gem::Version
|
123
|
-
version: '4.0'
|
124
|
-
type: :development
|
125
|
-
prerelease: false
|
126
|
-
version_requirements: !ruby/object:Gem::Requirement
|
127
|
-
requirements:
|
128
|
-
- - "~>"
|
129
|
-
- !ruby/object:Gem::Version
|
130
|
-
version: '4.0'
|
131
|
-
- !ruby/object:Gem::Dependency
|
132
|
-
name: guard-rspec
|
133
|
-
requirement: !ruby/object:Gem::Requirement
|
134
|
-
requirements:
|
135
|
-
- - "~>"
|
136
|
-
- !ruby/object:Gem::Version
|
137
|
-
version: '4.7'
|
138
|
-
type: :development
|
139
|
-
prerelease: false
|
140
|
-
version_requirements: !ruby/object:Gem::Requirement
|
141
|
-
requirements:
|
142
|
-
- - "~>"
|
143
|
-
- !ruby/object:Gem::Version
|
144
|
-
version: '4.7'
|
145
|
-
- !ruby/object:Gem::Dependency
|
146
|
-
name: pg
|
147
|
-
requirement: !ruby/object:Gem::Requirement
|
148
|
-
requirements:
|
149
|
-
- - "~>"
|
150
|
-
- !ruby/object:Gem::Version
|
151
|
-
version: '1.2'
|
152
|
-
type: :development
|
153
|
-
prerelease: false
|
154
|
-
version_requirements: !ruby/object:Gem::Requirement
|
155
|
-
requirements:
|
156
|
-
- - "~>"
|
157
|
-
- !ruby/object:Gem::Version
|
158
|
-
version: '1.2'
|
159
|
-
- !ruby/object:Gem::Dependency
|
160
|
-
name: pry
|
161
|
-
requirement: !ruby/object:Gem::Requirement
|
162
|
-
requirements:
|
163
|
-
- - "~>"
|
164
|
-
- !ruby/object:Gem::Version
|
165
|
-
version: '0.12'
|
166
|
-
type: :development
|
167
|
-
prerelease: false
|
168
|
-
version_requirements: !ruby/object:Gem::Requirement
|
169
|
-
requirements:
|
170
|
-
- - "~>"
|
171
|
-
- !ruby/object:Gem::Version
|
172
|
-
version: '0.12'
|
173
|
-
- !ruby/object:Gem::Dependency
|
174
|
-
name: pry-byebug
|
175
|
-
requirement: !ruby/object:Gem::Requirement
|
176
|
-
requirements:
|
177
|
-
- - "~>"
|
178
|
-
- !ruby/object:Gem::Version
|
179
|
-
version: '3.7'
|
180
|
-
type: :development
|
181
|
-
prerelease: false
|
182
|
-
version_requirements: !ruby/object:Gem::Requirement
|
183
|
-
requirements:
|
184
|
-
- - "~>"
|
185
|
-
- !ruby/object:Gem::Version
|
186
|
-
version: '3.7'
|
187
|
-
- !ruby/object:Gem::Dependency
|
188
|
-
name: rake
|
189
|
-
requirement: !ruby/object:Gem::Requirement
|
190
|
-
requirements:
|
191
|
-
- - "~>"
|
192
|
-
- !ruby/object:Gem::Version
|
193
|
-
version: '13.0'
|
194
|
-
type: :development
|
195
|
-
prerelease: false
|
196
|
-
version_requirements: !ruby/object:Gem::Requirement
|
197
|
-
requirements:
|
198
|
-
- - "~>"
|
199
|
-
- !ruby/object:Gem::Version
|
200
|
-
version: '13.0'
|
201
|
-
- !ruby/object:Gem::Dependency
|
202
|
-
name: reek
|
203
|
-
requirement: !ruby/object:Gem::Requirement
|
204
|
-
requirements:
|
205
|
-
- - "~>"
|
206
|
-
- !ruby/object:Gem::Version
|
207
|
-
version: '5.6'
|
208
|
-
type: :development
|
209
|
-
prerelease: false
|
210
|
-
version_requirements: !ruby/object:Gem::Requirement
|
211
|
-
requirements:
|
212
|
-
- - "~>"
|
213
|
-
- !ruby/object:Gem::Version
|
214
|
-
version: '5.6'
|
215
|
-
- !ruby/object:Gem::Dependency
|
216
|
-
name: rspec-rails
|
217
|
-
requirement: !ruby/object:Gem::Requirement
|
218
|
-
requirements:
|
219
|
-
- - "~>"
|
220
|
-
- !ruby/object:Gem::Version
|
221
|
-
version: '3.9'
|
222
|
-
type: :development
|
223
|
-
prerelease: false
|
224
|
-
version_requirements: !ruby/object:Gem::Requirement
|
225
|
-
requirements:
|
226
|
-
- - "~>"
|
227
|
-
- !ruby/object:Gem::Version
|
228
|
-
version: '3.9'
|
229
|
-
- !ruby/object:Gem::Dependency
|
230
|
-
name: rubocop
|
231
|
-
requirement: !ruby/object:Gem::Requirement
|
232
|
-
requirements:
|
233
|
-
- - "~>"
|
234
|
-
- !ruby/object:Gem::Version
|
235
|
-
version: '0.79'
|
236
|
-
type: :development
|
237
|
-
prerelease: false
|
238
|
-
version_requirements: !ruby/object:Gem::Requirement
|
239
|
-
requirements:
|
240
|
-
- - "~>"
|
241
|
-
- !ruby/object:Gem::Version
|
242
|
-
version: '0.79'
|
243
|
-
- !ruby/object:Gem::Dependency
|
244
|
-
name: rubocop-performance
|
245
|
-
requirement: !ruby/object:Gem::Requirement
|
246
|
-
requirements:
|
247
|
-
- - "~>"
|
248
|
-
- !ruby/object:Gem::Version
|
249
|
-
version: '1.5'
|
250
|
-
type: :development
|
251
|
-
prerelease: false
|
252
|
-
version_requirements: !ruby/object:Gem::Requirement
|
253
|
-
requirements:
|
254
|
-
- - "~>"
|
255
|
-
- !ruby/object:Gem::Version
|
256
|
-
version: '1.5'
|
257
|
-
- !ruby/object:Gem::Dependency
|
258
|
-
name: rubocop-rake
|
259
|
-
requirement: !ruby/object:Gem::Requirement
|
260
|
-
requirements:
|
261
|
-
- - "~>"
|
262
|
-
- !ruby/object:Gem::Version
|
263
|
-
version: '0.5'
|
264
|
-
type: :development
|
265
|
-
prerelease: false
|
266
|
-
version_requirements: !ruby/object:Gem::Requirement
|
267
|
-
requirements:
|
268
|
-
- - "~>"
|
269
|
-
- !ruby/object:Gem::Version
|
270
|
-
version: '0.5'
|
271
|
-
- !ruby/object:Gem::Dependency
|
272
|
-
name: rubocop-rspec
|
273
|
-
requirement: !ruby/object:Gem::Requirement
|
274
|
-
requirements:
|
275
|
-
- - "~>"
|
276
|
-
- !ruby/object:Gem::Version
|
277
|
-
version: '1.37'
|
278
|
-
type: :development
|
279
|
-
prerelease: false
|
280
|
-
version_requirements: !ruby/object:Gem::Requirement
|
281
|
-
requirements:
|
282
|
-
- - "~>"
|
283
|
-
- !ruby/object:Gem::Version
|
284
|
-
version: '1.37'
|
74
|
+
version: '6.0'
|
285
75
|
- !ruby/object:Gem::Dependency
|
286
|
-
name:
|
76
|
+
name: slim-rails
|
287
77
|
requirement: !ruby/object:Gem::Requirement
|
288
78
|
requirements:
|
289
79
|
- - "~>"
|
290
80
|
- !ruby/object:Gem::Version
|
291
|
-
version: '
|
292
|
-
type: :
|
81
|
+
version: '3.2'
|
82
|
+
type: :runtime
|
293
83
|
prerelease: false
|
294
84
|
version_requirements: !ruby/object:Gem::Requirement
|
295
85
|
requirements:
|
296
86
|
- - "~>"
|
297
87
|
- !ruby/object:Gem::Version
|
298
|
-
version: '
|
299
|
-
description:
|
88
|
+
version: '3.2'
|
89
|
+
description:
|
300
90
|
email:
|
301
91
|
- brooke@alchemists.io
|
302
92
|
executables: []
|
303
93
|
extensions: []
|
304
94
|
extra_rdoc_files:
|
305
|
-
- README.
|
306
|
-
- LICENSE.
|
95
|
+
- README.adoc
|
96
|
+
- LICENSE.adoc
|
307
97
|
files:
|
308
|
-
- LICENSE.
|
309
|
-
- README.
|
98
|
+
- LICENSE.adoc
|
99
|
+
- README.adoc
|
310
100
|
- app/assets/stylesheets/auther/application.scss
|
311
101
|
- app/assets/stylesheets/auther/auther.scss
|
312
102
|
- app/controllers/auther/base_controller.rb
|
@@ -328,14 +118,15 @@ files:
|
|
328
118
|
- lib/generators/auther/credentials/credentials_generator.rb
|
329
119
|
- lib/generators/auther/install/install_generator.rb
|
330
120
|
- lib/generators/auther/templates/config/initializers/auther.rb
|
331
|
-
homepage: https://
|
121
|
+
homepage: https://www.alchemists.io/projects/auther
|
332
122
|
licenses:
|
333
123
|
- Apache-2.0
|
334
124
|
metadata:
|
335
|
-
source_code_uri: https://github.com/bkuhlmann/auther
|
336
|
-
changelog_uri: https://github.com/bkuhlmann/auther/blob/master/CHANGES.md
|
337
125
|
bug_tracker_uri: https://github.com/bkuhlmann/auther/issues
|
338
|
-
|
126
|
+
changelog_uri: https://www.alchemists.io/projects/auther/changes.html
|
127
|
+
documentation_uri: https://www.alchemists.io/projects/auther
|
128
|
+
source_code_uri: https://github.com/bkuhlmann/auther
|
129
|
+
post_install_message:
|
339
130
|
rdoc_options: []
|
340
131
|
require_paths:
|
341
132
|
- lib
|
@@ -350,8 +141,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
350
141
|
- !ruby/object:Gem::Version
|
351
142
|
version: '0'
|
352
143
|
requirements: []
|
353
|
-
rubygems_version: 3.
|
354
|
-
signing_key:
|
144
|
+
rubygems_version: 3.2.0
|
145
|
+
signing_key:
|
355
146
|
specification_version: 4
|
356
147
|
summary: Enhances Rails with multi-account, form-based, database-less, application-wide
|
357
148
|
authentication.
|
metadata.gz.sig
CHANGED
Binary file
|
data/README.md
DELETED
@@ -1,265 +0,0 @@
|
|
1
|
-
<p align="center">
|
2
|
-
<img src="auther.png" alt="Auther Icon"/>
|
3
|
-
</p>
|
4
|
-
|
5
|
-
# Auther
|
6
|
-
|
7
|
-
[![Gem Version](https://badge.fury.io/rb/auther.svg)](http://badge.fury.io/rb/auther)
|
8
|
-
[![Code Climate Maintainability](https://api.codeclimate.com/v1/badges/3172d51796930fcdfad8/maintainability)](https://codeclimate.com/github/bkuhlmann/auther/maintainability)
|
9
|
-
[![Code Climate Test Coverage](https://api.codeclimate.com/v1/badges/3172d51796930fcdfad8/test_coverage)](https://codeclimate.com/github/bkuhlmann/auther/test_coverage)
|
10
|
-
[![Circle CI Status](https://circleci.com/gh/bkuhlmann/auther.svg?style=svg)](https://circleci.com/gh/bkuhlmann/auther)
|
11
|
-
|
12
|
-
Provides simple, form-based authentication for apps that need security but don't want to deal with
|
13
|
-
the clunky UI of HTTP Basic Authentication or something as heavyweight as
|
14
|
-
[Devise](https://github.com/plataformatec/devise). It doesn't require a database and is compatible
|
15
|
-
with password managers like [1Password](https://agilebits.com/onepassword) making for a pleasant
|
16
|
-
user experience.
|
17
|
-
|
18
|
-
<!-- Tocer[start]: Auto-generated, don't remove. -->
|
19
|
-
|
20
|
-
## Table of Contents
|
21
|
-
|
22
|
-
- [Features](#features)
|
23
|
-
- [Requirements](#requirements)
|
24
|
-
- [Setup](#setup)
|
25
|
-
- [Usage](#usage)
|
26
|
-
- [Initializer](#initializer)
|
27
|
-
- [Routes](#routes)
|
28
|
-
- [Model](#model)
|
29
|
-
- [Presenter](#presenter)
|
30
|
-
- [View](#view)
|
31
|
-
- [Controller](#controller)
|
32
|
-
- [Logging](#logging)
|
33
|
-
- [Troubleshooting](#troubleshooting)
|
34
|
-
- [Tests](#tests)
|
35
|
-
- [Versioning](#versioning)
|
36
|
-
- [Code of Conduct](#code-of-conduct)
|
37
|
-
- [Contributions](#contributions)
|
38
|
-
- [License](#license)
|
39
|
-
- [History](#history)
|
40
|
-
- [Credits](#credits)
|
41
|
-
|
42
|
-
<!-- Tocer[finish]: Auto-generated, don't remove. -->
|
43
|
-
|
44
|
-
## Features
|
45
|
-
|
46
|
-
- Supports form-based authentication compatible with password managers like
|
47
|
-
[1Password](https://agilebits.com/onepassword).
|
48
|
-
|
49
|
-
![Form Without Errors Screenshot](doc/screenshots/form-without_errors.png)
|
50
|
-
![Form With Errors Screenshot](doc/screenshots/form-with_errors.png)
|
51
|
-
|
52
|
-
- Uses CSS Flexbox for lightweight styling.
|
53
|
-
- Uses encrypted account credentials to keep sensitive information secure.
|
54
|
-
- Supports multiple accounts with optional path exclude lists.
|
55
|
-
- Supports customizable routes, models, presenters, views, controllers, and loggers.
|
56
|
-
- Provides a generator for easy install and setup within an existing project.
|
57
|
-
- Provides auto-redirection to requested path for verified credentials.
|
58
|
-
|
59
|
-
## Requirements
|
60
|
-
|
61
|
-
1. [Ruby 2.7.x](https://www.ruby-lang.org).
|
62
|
-
1. [Ruby on Rails 6.0.x](http://rubyonrails.org).
|
63
|
-
|
64
|
-
## Setup
|
65
|
-
|
66
|
-
Type the following to install:
|
67
|
-
|
68
|
-
gem install auther
|
69
|
-
|
70
|
-
Add the following to your Gemfile:
|
71
|
-
|
72
|
-
gem "auther"
|
73
|
-
|
74
|
-
Run the install generator to configure and initialize your application:
|
75
|
-
|
76
|
-
rails generate auther:install
|
77
|
-
|
78
|
-
Run the credentials generator to generate credentials for your application:
|
79
|
-
|
80
|
-
rails generate auther:credentials
|
81
|
-
|
82
|
-
If using [direnv](https://direnv.net), for example, you can copy and paste the generated credentials
|
83
|
-
into your `.envrc` file. Example:
|
84
|
-
|
85
|
-
![Credentials Generator Screenshot](doc/screenshots/credentials_generator.jpg)
|
86
|
-
|
87
|
-
## Usage
|
88
|
-
|
89
|
-
Launch your Rails application and visit the following:
|
90
|
-
|
91
|
-
http://localhost:3000/login
|
92
|
-
|
93
|
-
Enter your login and password as used for the `rails generate auther:credentials` generator and
|
94
|
-
you'll be logged in.
|
95
|
-
|
96
|
-
### Initializer
|
97
|
-
|
98
|
-
The initializer (installed during setup) can be found here:
|
99
|
-
|
100
|
-
config/initializers/auther.rb
|
101
|
-
|
102
|
-
The initializer comes installed with the following settings:
|
103
|
-
|
104
|
-
Rails.application.config.auther_settings = {
|
105
|
-
accounts: [
|
106
|
-
name: "admin",
|
107
|
-
encrypted_login: ENV["AUTHER_ADMIN_LOGIN"],
|
108
|
-
encrypted_password: ENV["AUTHER_ADMIN_PASSWORD"],
|
109
|
-
paths: ["/admin"]
|
110
|
-
],
|
111
|
-
secret: ENV["AUTHER_SECRET"]
|
112
|
-
}
|
113
|
-
|
114
|
-
To encrypt/decrypt account credentials, launch a rails console and run the following:
|
115
|
-
|
116
|
-
# The secret as defined in `auther_settings` and/or produced by the credentials generator.
|
117
|
-
secret = SecureRandom.hex 16 # "426a7f46548a1a4518676a8e246517d8"
|
118
|
-
|
119
|
-
# The cipher for encrypting/decrypting values.
|
120
|
-
cipher = Auther::Cipher.new secret
|
121
|
-
|
122
|
-
# Use the following to encrypt an unecrypted value.
|
123
|
-
cipher.encrypt "test@test.com"
|
124
|
-
|
125
|
-
# Use the following to decrypt an encrypted value.
|
126
|
-
cipher.decrypt "hWToltdpl+uZJBPELKNC7Ij++jPkTuo=--nEdbOYL9fIRh14hY--fU+VSCd4+DDOhOmG1gzRfQ=="
|
127
|
-
|
128
|
-
The initializer can be customized as follows:
|
129
|
-
|
130
|
-
- *title* - Optional. The HTML page title (as rendered within a browser tab). Default:
|
131
|
-
"Authorization".
|
132
|
-
- *label* - Optional. The page label (what would appear above the form). Default: "Authorization".
|
133
|
-
- *secret* - Required. The secret passphrase used to encrypt/decrypt account credentials.
|
134
|
-
- *accounts* - Required. The array of accounts with different or similar access to the application.
|
135
|
-
- *name* - Required. The account name that uniquely identifies the account.
|
136
|
-
- *encrypted_login* - Required. The encrypted account login.
|
137
|
-
- *encrypted_password* - Required. The encrypted account password.
|
138
|
-
- *paths* - Required. The array of excluded paths for which only this account has access to.
|
139
|
-
- *authorized_url* - Optional. The URL to redirect to upon successful authorization. Authorized
|
140
|
-
redirection works in the order defined:
|
141
|
-
- The excluded path (if requested prior to authorization but now authorized).
|
142
|
-
- The authorized URL (if defined and the excluded path wasn't requested).
|
143
|
-
- The root path (if none of the above).
|
144
|
-
- *deauthorized_url* - Optional. The URL to redirect to upon successful deauthorization (i.e.
|
145
|
-
logout). Deauthorized redirections works as follows (in the order defined):
|
146
|
-
- The deauthorized URL (if defined).
|
147
|
-
- The auth URL.
|
148
|
-
- *url* - Optional. The URL to redirect to when enforcing authentication. Default: “/login”.
|
149
|
-
- *logger* - Optional. The logger used to log path/account authorization messages. Default:
|
150
|
-
`Auther::NullLogger`.
|
151
|
-
|
152
|
-
### Routes
|
153
|
-
|
154
|
-
The routes can be customized as follows (installed, by default, via the install generator):
|
155
|
-
|
156
|
-
Rails.application.routes.draw do
|
157
|
-
mount Auther::Engine => "/auther"
|
158
|
-
get "/login", to: "auther/session#new", as: "login"
|
159
|
-
delete "/logout", to: "auther/session#destroy", as: "logout"
|
160
|
-
end
|
161
|
-
|
162
|
-
### Model
|
163
|
-
|
164
|
-
The [Auther::Account](app/models/auther/account.rb) is a struct that uses ActiveModel validations to
|
165
|
-
aid in attribute validation. This model could potentially be replaced with a database-backed object
|
166
|
-
(would require controller customization)...but you should question if you have outgrown the use of
|
167
|
-
this gem and need a different solution altogether if it comes to that.
|
168
|
-
|
169
|
-
### Presenter
|
170
|
-
|
171
|
-
The [Auther::Presenter::Account](app/presenters/auther/account.rb) is a plain old Ruby object that
|
172
|
-
uses ActiveModel validations to aid in form validation. This presenter makes it easy to construct
|
173
|
-
form data for input and validation.
|
174
|
-
|
175
|
-
### View
|
176
|
-
|
177
|
-
The view can be customized by creating the following file within your Rails application (assumes
|
178
|
-
that the default Auther::SessionController implementation is sufficient):
|
179
|
-
|
180
|
-
app/views/auther/session/new.html
|
181
|
-
|
182
|
-
The form uses the `@account` instance variable which is an instance of the
|
183
|
-
Auther::Presenter::Account presenter (as mentioned above). The form can be stylized by modifying the
|
184
|
-
styles found in the [auther.scss](app/assets/stylesheets/auther/auther.scss) stylesheet.
|
185
|
-
|
186
|
-
### Controller
|
187
|
-
|
188
|
-
The [Auther::SessionController](app/controllers/auther/session_controller.rb) inherits from the
|
189
|
-
[Auther::BaseController](app/controllers/auther/base_controller.rb). To customize, it is recommended
|
190
|
-
that you add a controller to your app that inherits from the Auther::BaseController. Example:
|
191
|
-
|
192
|
-
# Example Path: app/controllers/session_controller.rb
|
193
|
-
class SessionController < Auther::BaseController
|
194
|
-
layout "example"
|
195
|
-
end
|
196
|
-
|
197
|
-
This allows customization of session controller behavior to serve any special business needs. See
|
198
|
-
the `Auther::BaseController` for additional details or the `Auther::SessionController` for default
|
199
|
-
implementation.
|
200
|
-
|
201
|
-
### Logging
|
202
|
-
|
203
|
-
As mentioned in the setup above, the logger can be customized as follows:
|
204
|
-
|
205
|
-
Auther::NullLogger.new # This is the default logger (which is no logging at all).
|
206
|
-
ActiveSupport::Logger.new("log/#{Rails.env}.log") # Can be used to log to the environment log.
|
207
|
-
Logger.new(STDOUT) # Can be used to log to standard output.
|
208
|
-
|
209
|
-
When logging is enabled, you'll be able to see the following information in the server logs to help
|
210
|
-
debug custom Auther settings:
|
211
|
-
|
212
|
-
- Requested path and excluded path detection.
|
213
|
-
- Finding (or not finding) of account.
|
214
|
-
- Account authentication pass/fail.
|
215
|
-
- Account and path authorization pass/fail.
|
216
|
-
|
217
|
-
### Troubleshooting
|
218
|
-
|
219
|
-
- If upgrading Rails, changing the cookie/session settings, generating a new secret base key, etc.
|
220
|
-
this might cause Auther authentication to fail. Make sure to clear your browser cookies in this
|
221
|
-
situation or use Google Chrome (incognito mode) to verify.
|
222
|
-
- If the authentication view/form looks broken (stylewise) this could be due to custom
|
223
|
-
`ActionView::Base.field_error_proc` settings defined by your app (usually via an initializer).
|
224
|
-
Auther uses this configuration `ActionView::Base.field_error_proc = proc { |html_tag, _|
|
225
|
-
html_tag.html_safe }` so that no additional markup is added to the DOM when errors are raised. If
|
226
|
-
you have customized this to something else, you might want to read the usage documentation
|
227
|
-
(mentioned above) to rebuild the authentication view/form for your specific business needs.
|
228
|
-
|
229
|
-
## Tests
|
230
|
-
|
231
|
-
To test, run:
|
232
|
-
|
233
|
-
bundle exec rake
|
234
|
-
|
235
|
-
## Versioning
|
236
|
-
|
237
|
-
Read [Semantic Versioning](https://semver.org) for details. Briefly, it means:
|
238
|
-
|
239
|
-
- Major (X.y.z) - Incremented for any backwards incompatible public API changes.
|
240
|
-
- Minor (x.Y.z) - Incremented for new, backwards compatible, public API enhancements/fixes.
|
241
|
-
- Patch (x.y.Z) - Incremented for small, backwards compatible, bug fixes.
|
242
|
-
|
243
|
-
## Code of Conduct
|
244
|
-
|
245
|
-
Please note that this project is released with a [CODE OF CONDUCT](CODE_OF_CONDUCT.md). By
|
246
|
-
participating in this project you agree to abide by its terms.
|
247
|
-
|
248
|
-
## Contributions
|
249
|
-
|
250
|
-
Read [CONTRIBUTING](CONTRIBUTING.md) for details.
|
251
|
-
|
252
|
-
## License
|
253
|
-
|
254
|
-
Copyright 2014 [Alchemists](https://www.alchemists.io).
|
255
|
-
Read [LICENSE](LICENSE.md) for details.
|
256
|
-
|
257
|
-
## History
|
258
|
-
|
259
|
-
Read [CHANGES](CHANGES.md) for details.
|
260
|
-
Built with [Gemsmith](https://github.com/bkuhlmann/gemsmith).
|
261
|
-
|
262
|
-
## Credits
|
263
|
-
|
264
|
-
Developed by [Brooke Kuhlmann](https://www.alchemists.io) at
|
265
|
-
[Alchemists](https://www.alchemists.io).
|