authentication-zero 0.0.23 → 0.0.24
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/Gemfile.lock +1 -1
- data/README.md +3 -1
- data/lib/authentication_zero/version.rb +1 -1
- data/lib/generators/authentication/authentication_generator.rb +56 -26
- data/lib/generators/authentication/templates/{app/controllers → controllers}/api/cancellations_controller.rb.tt +0 -0
- data/lib/generators/authentication/templates/{app/controllers → controllers}/api/emails_controller.rb.tt +0 -0
- data/lib/generators/authentication/templates/{app/controllers → controllers}/api/password_resets_controller.rb.tt +2 -1
- data/lib/generators/authentication/templates/{app/controllers → controllers}/api/passwords_controller.rb.tt +0 -0
- data/lib/generators/authentication/templates/{app/controllers → controllers}/api/registrations_controller.rb.tt +0 -0
- data/lib/generators/authentication/templates/{app/controllers → controllers}/api/sessions_controller.rb.tt +0 -0
- data/lib/generators/authentication/templates/{app/controllers → controllers}/html/cancellations_controller.rb.tt +0 -0
- data/lib/generators/authentication/templates/{app/controllers → controllers}/html/emails_controller.rb.tt +0 -0
- data/lib/generators/authentication/templates/{app/controllers → controllers}/html/password_resets_controller.rb.tt +2 -1
- data/lib/generators/authentication/templates/{app/controllers → controllers}/html/passwords_controller.rb.tt +0 -0
- data/lib/generators/authentication/templates/{app/controllers → controllers}/html/registrations_controller.rb.tt +0 -0
- data/lib/generators/authentication/templates/{app/controllers → controllers}/html/sessions_controller.rb.tt +0 -0
- data/lib/generators/authentication/templates/{app/views → erb}/cancellations/new.html.erb.tt +0 -0
- data/lib/generators/authentication/templates/{app/views → erb}/email_mailer/changed.html.erb.tt +0 -0
- data/lib/generators/authentication/templates/{app/views → erb}/email_mailer/changed.text.erb.tt +0 -0
- data/lib/generators/authentication/templates/{app/views → erb}/emails/edit.html.erb.tt +0 -0
- data/lib/generators/authentication/templates/{app/views → erb}/password_mailer/changed.html.erb.tt +0 -0
- data/lib/generators/authentication/templates/{app/views → erb}/password_mailer/changed.text.erb.tt +0 -0
- data/lib/generators/authentication/templates/{app/views → erb}/password_mailer/reset.html.erb.tt +0 -0
- data/lib/generators/authentication/templates/{app/views → erb}/password_mailer/reset.text.erb.tt +0 -0
- data/lib/generators/authentication/templates/{app/views → erb}/password_resets/edit.html.erb.tt +0 -0
- data/lib/generators/authentication/templates/{app/views → erb}/password_resets/new.html.erb.tt +0 -0
- data/lib/generators/authentication/templates/{app/views → erb}/passwords/edit.html.erb.tt +0 -0
- data/lib/generators/authentication/templates/{app/views → erb}/registrations/new.html.erb.tt +0 -0
- data/lib/generators/authentication/templates/{app/views → erb}/sessions/new.html.erb.tt +0 -0
- data/lib/generators/authentication/templates/{app/mailers → mailers}/email_mailer.rb.tt +0 -0
- data/lib/generators/authentication/templates/{app/mailers → mailers}/password_mailer.rb.tt +1 -1
- data/lib/generators/authentication/templates/{app/models → models}/current.rb.tt +0 -0
- data/lib/generators/authentication/templates/{app/models → models}/model.rb.tt +0 -0
- data/lib/generators/authentication/templates/test_unit/controllers/api/password_resets_controller_test.rb.tt +2 -2
- data/lib/generators/authentication/templates/test_unit/controllers/html/password_resets_controller_test.rb.tt +2 -2
- data/lib/generators/authentication/templates/test_unit/system/password_resets_test.rb.tt +1 -1
- metadata +30 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69456b50110f6870da499c900b547905e2e2fa01fa52986facfa491d821cde04
|
4
|
+
data.tar.gz: f72563012edb915900884a5366226114f71001b6e9f1c6344032c6badde97542
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 196723b836ad2dd346eb82db9b24ced90117bcb03d457858efa6ef20b86ee29bc31926750ca6bd5bfea8765be1bf940f3821f11e023847a2884c01bc4bb7fb50
|
7
|
+
data.tar.gz: 9d8a6716734676a35cfe9c3db895a7dab12c07c277acff45ee5a78f9a923957e001d3db81aa197bfa15a097da13bd4afdab86e34031cd6fee51d65268129121f
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -27,7 +27,7 @@ The purpose of authentication zero is to generate a pre-built authentication sys
|
|
27
27
|
- [Action mailer](https://api.rubyonrails.org/classes/ActionMailer/Base.html): Action Mailer allows you to send email from your application using a mailer model and views.
|
28
28
|
- [Log filtering](https://guides.rubyonrails.org/action_controller_overview.html#log-filtering): Parameters 'token' and 'password' are marked [FILTERED] in the log.
|
29
29
|
- [Functional Tests](https://guides.rubyonrails.org/testing.html#functional-tests-for-your-controllers): In Rails, testing the various actions of a controller is a form of writing functional tests.
|
30
|
-
- [System Testing]
|
30
|
+
- [System Testing](https://guides.rubyonrails.org/testing.html#system-testing): System tests allow you to test user interactions with your application, running tests in either a real or a headless browser.
|
31
31
|
|
32
32
|
## Installation
|
33
33
|
|
@@ -83,6 +83,8 @@ config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
|
|
83
83
|
$ rails generate authentication user
|
84
84
|
```
|
85
85
|
|
86
|
+
Then run `bundle install` again!
|
87
|
+
|
86
88
|
## Development
|
87
89
|
|
88
90
|
To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
@@ -1,28 +1,40 @@
|
|
1
1
|
require "rails/generators/active_record"
|
2
2
|
|
3
3
|
class AuthenticationGenerator < Rails::Generators::NamedBase
|
4
|
-
include ActiveRecord::Generators::Migration
|
5
|
-
|
6
4
|
class_option :api, type: :boolean, desc: "Generates API authentication"
|
5
|
+
|
6
|
+
class_option :migration, type: :boolean
|
7
|
+
class_option :test_framework, type: :string, desc: "Test framework to be invoked"
|
8
|
+
|
9
|
+
class_option :fixture, type: :boolean
|
7
10
|
class_option :system_tests, type: :string, desc: "Skip system test files"
|
8
11
|
|
12
|
+
class_option :skip_routes, type: :boolean
|
13
|
+
class_option :template_engine, type: :string, desc: "Template engine to be invoked"
|
14
|
+
|
9
15
|
source_root File.expand_path("templates", __dir__)
|
10
16
|
|
11
17
|
def add_bcrypt
|
12
|
-
uncomment_lines
|
18
|
+
uncomment_lines "Gemfile", /bcrypt/
|
13
19
|
end
|
14
20
|
|
15
|
-
def
|
16
|
-
|
21
|
+
def create_migration
|
22
|
+
if options.migration
|
23
|
+
invoke "migration", ["create_#{table_name}", "email:string:uniq", "password:digest", "session_token:string:uniq"]
|
24
|
+
end
|
17
25
|
end
|
18
26
|
|
19
|
-
def
|
20
|
-
template "
|
21
|
-
template "
|
27
|
+
def create_model
|
28
|
+
template "models/model.rb", "app/models/#{file_name}.rb"
|
29
|
+
template "models/current.rb", "app/models/current.rb"
|
22
30
|
end
|
23
31
|
|
32
|
+
hook_for :fixture_replacement
|
33
|
+
|
24
34
|
def create_fixture_file
|
25
|
-
|
35
|
+
if options.fixture
|
36
|
+
template "#{test_framework}/fixtures.yml", "test/fixtures/#{fixture_file_name}.yml"
|
37
|
+
end
|
26
38
|
end
|
27
39
|
|
28
40
|
def add_application_controller_methods
|
@@ -57,42 +69,60 @@ class AuthenticationGenerator < Rails::Generators::NamedBase
|
|
57
69
|
end
|
58
70
|
|
59
71
|
def create_controllers
|
60
|
-
directory "
|
72
|
+
directory "controllers/#{format_folder}", "app/controllers"
|
61
73
|
end
|
62
74
|
|
63
75
|
def create_views
|
64
76
|
if options.api
|
65
|
-
directory "
|
66
|
-
directory "
|
77
|
+
directory "#{template_engine}/email_mailer", "app/views/email_mailer"
|
78
|
+
directory "#{template_engine}/password_mailer", "app/views/password_mailer"
|
67
79
|
else
|
68
|
-
directory "
|
80
|
+
directory "#{template_engine}", "app/views"
|
69
81
|
end
|
70
82
|
end
|
71
83
|
|
72
84
|
def create_mailers
|
73
|
-
template "
|
74
|
-
template "
|
85
|
+
template "mailers/email_mailer.rb", "app/mailers/email_mailer.rb"
|
86
|
+
template "mailers/password_mailer.rb", "app/mailers/password_mailer.rb"
|
75
87
|
end
|
76
88
|
|
77
89
|
def add_routes
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
90
|
+
unless options.skip_routes
|
91
|
+
route "resource :password_resets, only: [:new, :edit, :create, :update]"
|
92
|
+
route "resource :cancellations, only: [:new, :create]"
|
93
|
+
route "resource :passwords, only: [:edit, :update]"
|
94
|
+
route "resource :emails, only: [:edit, :update]"
|
95
|
+
route "delete 'sign_out', to: 'sessions#destroy'"
|
96
|
+
route "post 'sign_up', to: 'registrations#create'"
|
97
|
+
route "get 'sign_up', to: 'registrations#new'" unless options.api?
|
98
|
+
route "post 'sign_in', to: 'sessions#create'"
|
99
|
+
route "get 'sign_in', to: 'sessions#new'" unless options.api?
|
100
|
+
end
|
87
101
|
end
|
88
102
|
|
89
103
|
def create_test_files
|
90
|
-
directory "
|
91
|
-
directory "
|
104
|
+
directory "#{test_framework}/controllers/#{format_folder}", "test/controllers"
|
105
|
+
directory "#{system_tests}/system", "test/system" if system_tests?
|
92
106
|
end
|
93
107
|
|
94
108
|
private
|
95
109
|
def format_folder
|
96
110
|
options.api ? "api" : "html"
|
97
111
|
end
|
112
|
+
|
113
|
+
def template_engine
|
114
|
+
options.template_engine
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_framework
|
118
|
+
options.test_framework
|
119
|
+
end
|
120
|
+
|
121
|
+
def system_tests
|
122
|
+
options.system_tests
|
123
|
+
end
|
124
|
+
|
125
|
+
def system_tests?
|
126
|
+
!options.api? && options.system_tests
|
127
|
+
end
|
98
128
|
end
|
File without changes
|
File without changes
|
@@ -1,5 +1,6 @@
|
|
1
1
|
class PasswordResetsController < ApplicationController
|
2
2
|
skip_before_action :authenticate
|
3
|
+
|
3
4
|
before_action :set_<%= singular_table_name %>, only: %i[ edit update ]
|
4
5
|
|
5
6
|
def edit
|
@@ -24,7 +25,7 @@ class PasswordResetsController < ApplicationController
|
|
24
25
|
|
25
26
|
private
|
26
27
|
def set_<%= singular_table_name %>
|
27
|
-
@<%= singular_table_name %> = <%= class_name %>.find_signed!(params[:token], purpose:
|
28
|
+
@<%= singular_table_name %> = <%= class_name %>.find_signed!(params[:token], purpose: :password_reset)
|
28
29
|
rescue ActiveSupport::MessageVerifier::InvalidSignature
|
29
30
|
render json: { error: "Your token has expired, please request a new one" }, status: :bad_request
|
30
31
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,5 +1,6 @@
|
|
1
1
|
class PasswordResetsController < ApplicationController
|
2
2
|
skip_before_action :authenticate
|
3
|
+
|
3
4
|
before_action :set_<%= singular_table_name %>, only: %i[ edit update ]
|
4
5
|
|
5
6
|
def new
|
@@ -27,7 +28,7 @@ class PasswordResetsController < ApplicationController
|
|
27
28
|
|
28
29
|
private
|
29
30
|
def set_<%= singular_table_name %>
|
30
|
-
@<%= singular_table_name %> = <%= class_name %>.find_signed!(params[:token], purpose:
|
31
|
+
@<%= singular_table_name %> = <%= class_name %>.find_signed!(params[:token], purpose: :password_reset)
|
31
32
|
rescue ActiveSupport::MessageVerifier::InvalidSignature
|
32
33
|
redirect_to new_password_resets_path, alert: "Your token has expired, please request a new one"
|
33
34
|
end
|
File without changes
|
File without changes
|
File without changes
|
data/lib/generators/authentication/templates/{app/views → erb}/cancellations/new.html.erb.tt
RENAMED
File without changes
|
data/lib/generators/authentication/templates/{app/views → erb}/email_mailer/changed.html.erb.tt
RENAMED
File without changes
|
data/lib/generators/authentication/templates/{app/views → erb}/email_mailer/changed.text.erb.tt
RENAMED
File without changes
|
File without changes
|
data/lib/generators/authentication/templates/{app/views → erb}/password_mailer/changed.html.erb.tt
RENAMED
File without changes
|
data/lib/generators/authentication/templates/{app/views → erb}/password_mailer/changed.text.erb.tt
RENAMED
File without changes
|
data/lib/generators/authentication/templates/{app/views → erb}/password_mailer/reset.html.erb.tt
RENAMED
File without changes
|
data/lib/generators/authentication/templates/{app/views → erb}/password_mailer/reset.text.erb.tt
RENAMED
File without changes
|
data/lib/generators/authentication/templates/{app/views → erb}/password_resets/edit.html.erb.tt
RENAMED
File without changes
|
data/lib/generators/authentication/templates/{app/views → erb}/password_resets/new.html.erb.tt
RENAMED
File without changes
|
File without changes
|
data/lib/generators/authentication/templates/{app/views → erb}/registrations/new.html.erb.tt
RENAMED
File without changes
|
File without changes
|
File without changes
|
@@ -4,7 +4,7 @@ class PasswordMailer < ApplicationMailer
|
|
4
4
|
end
|
5
5
|
|
6
6
|
def reset
|
7
|
-
@signed_id = params[:<%= singular_table_name %>].signed_id(purpose:
|
7
|
+
@signed_id = params[:<%= singular_table_name %>].signed_id(purpose: :password_reset, expires_in: 20.minutes)
|
8
8
|
mail to: params[:<%= singular_table_name %>].email
|
9
9
|
end
|
10
10
|
end
|
File without changes
|
File without changes
|
@@ -3,8 +3,8 @@ require "test_helper"
|
|
3
3
|
class PasswordResetsControllerTest < ActionDispatch::IntegrationTest
|
4
4
|
setup do
|
5
5
|
@<%= singular_table_name %> = <%= table_name %>(:lazaro_nixon)
|
6
|
-
@sid = @<%= singular_table_name %>.signed_id(purpose:
|
7
|
-
@sid_exp = @<%= singular_table_name %>.signed_id(purpose:
|
6
|
+
@sid = @<%= singular_table_name %>.signed_id(purpose: :password_reset, expires_in: 20.minutes)
|
7
|
+
@sid_exp = @<%= singular_table_name %>.signed_id(purpose: :password_reset, expires_in: 0.minutes)
|
8
8
|
end
|
9
9
|
|
10
10
|
test "should get edit" do
|
@@ -3,8 +3,8 @@ require "test_helper"
|
|
3
3
|
class PasswordResetsControllerTest < ActionDispatch::IntegrationTest
|
4
4
|
setup do
|
5
5
|
@<%= singular_table_name %> = <%= table_name %>(:lazaro_nixon)
|
6
|
-
@sid = @<%= singular_table_name %>.signed_id(purpose:
|
7
|
-
@sid_exp = @<%= singular_table_name %>.signed_id(purpose:
|
6
|
+
@sid = @<%= singular_table_name %>.signed_id(purpose: :password_reset, expires_in: 20.minutes)
|
7
|
+
@sid_exp = @<%= singular_table_name %>.signed_id(purpose: :password_reset, expires_in: 0.minutes)
|
8
8
|
end
|
9
9
|
|
10
10
|
test "should get new" do
|
@@ -3,7 +3,7 @@ require "application_system_test_case"
|
|
3
3
|
class PasswordResetsTest < ApplicationSystemTestCase
|
4
4
|
setup do
|
5
5
|
@<%= singular_table_name %> = <%= table_name %>(:lazaro_nixon)
|
6
|
-
@sid = @<%= singular_table_name %>.signed_id(purpose:
|
6
|
+
@sid = @<%= singular_table_name %>.signed_id(purpose: :password_reset, expires_in: 20.minutes)
|
7
7
|
end
|
8
8
|
|
9
9
|
test "sending a password reset email" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authentication-zero
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.24
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nixon
|
@@ -31,35 +31,35 @@ files:
|
|
31
31
|
- lib/authentication_zero/version.rb
|
32
32
|
- lib/generators/authentication/USAGE
|
33
33
|
- lib/generators/authentication/authentication_generator.rb
|
34
|
-
- lib/generators/authentication/templates/
|
35
|
-
- lib/generators/authentication/templates/
|
36
|
-
- lib/generators/authentication/templates/
|
37
|
-
- lib/generators/authentication/templates/
|
38
|
-
- lib/generators/authentication/templates/
|
39
|
-
- lib/generators/authentication/templates/
|
40
|
-
- lib/generators/authentication/templates/
|
41
|
-
- lib/generators/authentication/templates/
|
42
|
-
- lib/generators/authentication/templates/
|
43
|
-
- lib/generators/authentication/templates/
|
44
|
-
- lib/generators/authentication/templates/
|
45
|
-
- lib/generators/authentication/templates/
|
46
|
-
- lib/generators/authentication/templates/
|
47
|
-
- lib/generators/authentication/templates/
|
48
|
-
- lib/generators/authentication/templates/
|
49
|
-
- lib/generators/authentication/templates/
|
50
|
-
- lib/generators/authentication/templates/
|
51
|
-
- lib/generators/authentication/templates/
|
52
|
-
- lib/generators/authentication/templates/
|
53
|
-
- lib/generators/authentication/templates/
|
54
|
-
- lib/generators/authentication/templates/
|
55
|
-
- lib/generators/authentication/templates/
|
56
|
-
- lib/generators/authentication/templates/
|
57
|
-
- lib/generators/authentication/templates/
|
58
|
-
- lib/generators/authentication/templates/
|
59
|
-
- lib/generators/authentication/templates/
|
60
|
-
- lib/generators/authentication/templates/
|
61
|
-
- lib/generators/authentication/templates/
|
62
|
-
- lib/generators/authentication/templates/
|
34
|
+
- lib/generators/authentication/templates/controllers/api/cancellations_controller.rb.tt
|
35
|
+
- lib/generators/authentication/templates/controllers/api/emails_controller.rb.tt
|
36
|
+
- lib/generators/authentication/templates/controllers/api/password_resets_controller.rb.tt
|
37
|
+
- lib/generators/authentication/templates/controllers/api/passwords_controller.rb.tt
|
38
|
+
- lib/generators/authentication/templates/controllers/api/registrations_controller.rb.tt
|
39
|
+
- lib/generators/authentication/templates/controllers/api/sessions_controller.rb.tt
|
40
|
+
- lib/generators/authentication/templates/controllers/html/cancellations_controller.rb.tt
|
41
|
+
- lib/generators/authentication/templates/controllers/html/emails_controller.rb.tt
|
42
|
+
- lib/generators/authentication/templates/controllers/html/password_resets_controller.rb.tt
|
43
|
+
- lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
|
44
|
+
- lib/generators/authentication/templates/controllers/html/registrations_controller.rb.tt
|
45
|
+
- lib/generators/authentication/templates/controllers/html/sessions_controller.rb.tt
|
46
|
+
- lib/generators/authentication/templates/erb/cancellations/new.html.erb.tt
|
47
|
+
- lib/generators/authentication/templates/erb/email_mailer/changed.html.erb.tt
|
48
|
+
- lib/generators/authentication/templates/erb/email_mailer/changed.text.erb.tt
|
49
|
+
- lib/generators/authentication/templates/erb/emails/edit.html.erb.tt
|
50
|
+
- lib/generators/authentication/templates/erb/password_mailer/changed.html.erb.tt
|
51
|
+
- lib/generators/authentication/templates/erb/password_mailer/changed.text.erb.tt
|
52
|
+
- lib/generators/authentication/templates/erb/password_mailer/reset.html.erb.tt
|
53
|
+
- lib/generators/authentication/templates/erb/password_mailer/reset.text.erb.tt
|
54
|
+
- lib/generators/authentication/templates/erb/password_resets/edit.html.erb.tt
|
55
|
+
- lib/generators/authentication/templates/erb/password_resets/new.html.erb.tt
|
56
|
+
- lib/generators/authentication/templates/erb/passwords/edit.html.erb.tt
|
57
|
+
- lib/generators/authentication/templates/erb/registrations/new.html.erb.tt
|
58
|
+
- lib/generators/authentication/templates/erb/sessions/new.html.erb.tt
|
59
|
+
- lib/generators/authentication/templates/mailers/email_mailer.rb.tt
|
60
|
+
- lib/generators/authentication/templates/mailers/password_mailer.rb.tt
|
61
|
+
- lib/generators/authentication/templates/models/current.rb.tt
|
62
|
+
- lib/generators/authentication/templates/models/model.rb.tt
|
63
63
|
- lib/generators/authentication/templates/test_unit/controllers/api/cancellations_controller_test.rb.tt
|
64
64
|
- lib/generators/authentication/templates/test_unit/controllers/api/emails_controller_test.rb.tt
|
65
65
|
- lib/generators/authentication/templates/test_unit/controllers/api/password_resets_controller_test.rb.tt
|