authentication-zero 2.15.8 → 2.16.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
  SHA256:
3
- metadata.gz: c007822422ed85c18af5d096f50e5480e0f9279fca974b3204f1fbec0691893a
4
- data.tar.gz: 85af3973c5fc9eab44ade1b0c427d6d283e1292b14977815222a4a0c4c9f79b5
3
+ metadata.gz: c00816db2934b9b60ab46d76d5126467640cb19474fa92714b8fa9100e37c1e0
4
+ data.tar.gz: 5890c1b1239b2a7ae7071b8a53c2ab1d9e9c51fcefc963d02ac7fe63034cbd9a
5
5
  SHA512:
6
- metadata.gz: e079761568f95e0a857a562be3aa55411ecd2ae57b7dd399345d8f0338d031e415d78f91c1f1f82af338b284674405c78a3e2dd4c554cb8bc24c4ea8ea3c24fc
7
- data.tar.gz: 9f2e58043fe1eb41e12bd76f37b4a2ac74b6a9e48f6c1dd5c14039b0a4ac979cc3057e956bdf8fca77898c2d59175f50c3c6d44d2283bf8a4f9c93e5702793c5
6
+ metadata.gz: '09f46b7b85266413e2cdec433fad41bcaab8cd17c085242e2073f96718db5a62f6057f9a09f2cbf2ee03021768fd2dae20fca6078afc03a74b563c0545761862'
7
+ data.tar.gz: 0cc1918f61712a284e46079c64954c0b944d785fa8bc70ebda8bfd2698cccde74863e7140123ebb1fdfce81d02d4ac94a9ea3dec5fdedef9c547c1fec92eb0b8
@@ -0,0 +1,70 @@
1
+ # This workflow uses actions that are not certified by GitHub. They are
2
+ # provided by a third-party and are governed by separate terms of service,
3
+ # privacy policy, and support documentation.
4
+ #
5
+ # This workflow will install a prebuilt Ruby version, install dependencies, and
6
+ # run tests and linters.
7
+ name: "Generate sample app and run tests"
8
+ on:
9
+ push:
10
+ branches: ["master"]
11
+ pull_request:
12
+ branches: ["master"]
13
+ jobs:
14
+ test_html:
15
+ name: 🧪 Run HTML Tests
16
+ runs-on: ubuntu-latest
17
+ env:
18
+ RAILS_ENV: test
19
+ steps:
20
+ - name: Checkout code
21
+ uses: actions/checkout@v3
22
+
23
+ - name: Install Ruby and gems
24
+ uses: ruby/setup-ruby@v1
25
+ with:
26
+ bundler-cache: true
27
+
28
+ - name: Install the latest Rails gem
29
+ run: gem install rails
30
+
31
+ - name: Create fresh Rails app then run generator and tests
32
+ env:
33
+ CI: true
34
+ run: |
35
+ rails new test-app
36
+ cd test-app
37
+ bundle add authentication-zero --github ${{ github.repository }} --branch ${{ github.ref_name }}
38
+ bin/rails generate authentication
39
+ bundle install
40
+ bin/rails db:migrate
41
+ bin/rails test
42
+ bin/rails test:system
43
+ test_api:
44
+ name: 🧪 Run API Tests
45
+ runs-on: ubuntu-latest
46
+ env:
47
+ RAILS_ENV: test
48
+ steps:
49
+ - name: Checkout code
50
+ uses: actions/checkout@v3
51
+
52
+ - name: Install Ruby and gems
53
+ uses: ruby/setup-ruby@v1
54
+ with:
55
+ bundler-cache: true
56
+
57
+ - name: Install the latest Rails gem
58
+ run: gem install rails
59
+
60
+ - name: Create fresh Rails app then run generator and tests
61
+ env:
62
+ CI: true
63
+ run: |
64
+ rails new test-app --api
65
+ cd test-app
66
+ bundle add authentication-zero --github ${{ github.repository }} --branch ${{ github.ref_name }}
67
+ bin/rails generate authentication
68
+ bundle install
69
+ bin/rails db:migrate
70
+ bin/rails test
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.1.2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## Authentication Zero 2.16.0 (May 2, 2022) ##
2
+
3
+ * Generate home controller
4
+ * Add default_url_options to environments
5
+
1
6
  ## Authentication Zero 2.13.0 (May 2, 2022) ##
2
7
 
3
8
  * Migrate tokens to a table structure
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- authentication-zero (2.15.8)
4
+ authentication-zero (2.16.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -42,68 +42,20 @@ The purpose of authentication zero is to generate a pre-built authentication sys
42
42
 
43
43
  Add this lines to your application's Gemfile:
44
44
 
45
- ```ruby
46
- gem "authentication-zero"
47
45
  ```
48
-
49
- Then run `bundle install`
50
-
51
- You'll need to set the root path in your routes.rb, for this example let's use the following:
52
-
53
- ```ruby
54
- root "home#index"
55
- ```
56
-
46
+ $ bundle add authentication-zero
57
47
  ```
58
- rails generate controller home index
59
- ```
60
-
61
- Add these lines to your `app/views/home/index.html.erb`:
62
-
63
- ```html+erb
64
- <p style="color: green"><%= notice %></p>
65
-
66
- <p>Signed as <%= Current.user.email %></p>
67
-
68
- <div>
69
- <%= link_to "Change email address", edit_identity_email_path %>
70
- </div>
71
48
 
72
- <div>
73
- <%= link_to "Change password", edit_password_path %>
74
- </div>
75
-
76
- <div>
77
- <%= link_to "Devices & Sessions", sessions_path %>
78
- </div>
79
-
80
- <div>
81
- <%# link_to "Activity Log", authentications_events_path %>
82
- </div>
83
-
84
- <div>
85
- <%# link_to "Two-Factor Authentication", new_two_factor_authentication_totp_path %>
86
- </div>
87
-
88
- <br>
49
+ ## Usage
89
50
 
90
- <%= button_to "Log out", Current.session, method: :delete %>
91
51
  ```
92
-
93
- And you'll need to set up the default URL options for the mailer in each environment. Here is a possible configuration for `config/environments/development.rb`:
94
-
95
- ```ruby
96
- config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
52
+ $ rails generate authentication
97
53
  ```
98
54
 
99
- ## Usage
100
-
101
55
  ```
102
- rails generate authentication
56
+ $ bundle install
103
57
  ```
104
58
 
105
- Then run `bundle install` again!
106
-
107
59
  ## Development
108
60
 
109
61
  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,3 +1,3 @@
1
1
  module AuthenticationZero
2
- VERSION = "2.15.8"
2
+ VERSION = "2.16.0"
3
3
  end
@@ -34,6 +34,11 @@ class AuthenticationGenerator < Rails::Generators::Base
34
34
  end
35
35
  end
36
36
 
37
+ def add_environment_configurations
38
+ application "config.action_mailer.default_url_options = { host: \"localhost\", port: 3000 }", env: "development"
39
+ application "config.action_mailer.default_url_options = { host: \"localhost\", port: 3000 }", env: "test"
40
+ end
41
+
37
42
  def create_configuration_files
38
43
  copy_file "config/redis/shared.yml", "config/redis/shared.yml" if redis?
39
44
  copy_file "config/initializers/omniauth.rb", "config/initializers/omniauth.rb" if omniauthable?
@@ -68,6 +73,7 @@ class AuthenticationGenerator < Rails::Generators::Base
68
73
  template "controllers/#{format_folder}/sessions_controller.rb", "app/controllers/sessions_controller.rb"
69
74
  template "controllers/#{format_folder}/passwords_controller.rb", "app/controllers/passwords_controller.rb"
70
75
  template "controllers/#{format_folder}/registrations_controller.rb", "app/controllers/registrations_controller.rb"
76
+ template "controllers/#{format_folder}/home_controller.rb", "app/controllers/home_controller.rb" unless options.api?
71
77
  template "controllers/#{format_folder}/sessions/sudos_controller.rb", "app/controllers/sessions/sudos_controller.rb" if options.sudoable?
72
78
  template "controllers/#{format_folder}/sessions/omniauth_controller.rb", "app/controllers/sessions/omniauth_controller.rb" if omniauthable?
73
79
  template "controllers/#{format_folder}/authentications/events_controller.rb", "app/controllers/authentications/events_controller.rb" if options.trackable?
@@ -81,6 +87,8 @@ class AuthenticationGenerator < Rails::Generators::Base
81
87
  directory "erb/user_mailer", "app/views/user_mailer"
82
88
  directory "erb/session_mailer", "app/views/session_mailer"
83
89
 
90
+ directory "erb/home", "app/views/home"
91
+
84
92
  directory "erb/identity", "app/views/identity"
85
93
  directory "erb/passwords", "app/views/passwords"
86
94
  directory "erb/registrations", "app/views/registrations"
@@ -100,6 +108,8 @@ class AuthenticationGenerator < Rails::Generators::Base
100
108
  end
101
109
 
102
110
  def add_routes
111
+ route "root 'home#index'" unless options.api?
112
+
103
113
  if omniauthable?
104
114
  route "post '/auth/:provider/callback', to: 'sessions/omniauth#create'"
105
115
  route "get '/auth/:provider/callback', to: 'sessions/omniauth#create'"
@@ -129,6 +139,7 @@ class AuthenticationGenerator < Rails::Generators::Base
129
139
 
130
140
  def create_test_files
131
141
  directory "test_unit/controllers/#{format_folder}", "test/controllers"
142
+ directory "test_unit/mailers/", "test/mailers"
132
143
  directory "test_unit/system", "test/system" unless options.api?
133
144
  template "test_unit/test_helper.rb", "test/test_helper.rb", force: true
134
145
  template "test_unit/application_system_test_case.rb", "test/application_system_test_case.rb", force: true unless options.api?
@@ -5,6 +5,7 @@ class Identity::EmailVerificationsController < ApplicationController
5
5
 
6
6
  def edit
7
7
  @user.update! verified: true
8
+ head :no_content
8
9
  end
9
10
 
10
11
  def create
@@ -0,0 +1,4 @@
1
+ class HomeController < ApplicationController
2
+ def index
3
+ end
4
+ end
@@ -0,0 +1,35 @@
1
+ <p style="color: green"><%%= notice %></p>
2
+
3
+ <%% if Current.user.present? %>
4
+ <p>Signed as <%%= Current.user.email %></p>
5
+
6
+ <div>
7
+ <%%= link_to "Change email address", edit_identity_email_path %>
8
+ </div>
9
+
10
+ <div>
11
+ <%%= link_to "Change password", edit_password_path %>
12
+ </div>
13
+
14
+ <div>
15
+ <%%= link_to "Devices & Sessions", sessions_path %>
16
+ </div>
17
+
18
+ <%- if options.trackable? -%>
19
+ <div>
20
+ <%# link_to "Activity Log", authentications_events_path %>
21
+ </div>
22
+
23
+ <%- end -%>
24
+ <%- if two_factor? -%>
25
+ <div>
26
+ <%# link_to "Two-Factor Authentication", new_two_factor_authentication_totp_path %>
27
+ </div>
28
+
29
+ <%- end -%>
30
+ <br>
31
+
32
+ <%%= button_to "Log out", Current.session, method: :delete %>
33
+ <%% else %>
34
+ Please <%%= link_to "sign in", sign_in_path %> or <%%= link_to "sign up", sign_up_path %>.
35
+ <%% end %>
@@ -13,7 +13,7 @@
13
13
  </div>
14
14
  <%% end %>
15
15
 
16
- <%%= form.hidden_field :token, value: params[:token] %>
16
+ <%%= form.hidden_field :sid, value: params[:sid] %>
17
17
 
18
18
  <div>
19
19
  <%%= form.label :password, "New password", style: "display: block" %>
@@ -1,7 +1,7 @@
1
1
  require "test_helper"
2
2
 
3
3
  class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
4
- driven_by :selenium, using: :chrome, screen_size: [1400, 1400]
4
+ driven_by :selenium, using: :headless_chrome, screen_size: [1400, 1400]
5
5
 
6
6
  def sign_in_as(user)
7
7
  visit sign_in_url
@@ -0,0 +1,13 @@
1
+ require "test_helper"
2
+
3
+ class SessionMailerTest < ActionMailer::TestCase
4
+ setup do
5
+ @session = users(:lazaro_nixon).sessions.create!
6
+ end
7
+
8
+ test "signed_in_notification" do
9
+ mail = SessionMailer.with(session: @session).signed_in_notification
10
+ assert_equal "New sign-in to your account", mail.subject
11
+ assert_equal [@session.user.email], mail.to
12
+ end
13
+ end
@@ -0,0 +1,19 @@
1
+ require "test_helper"
2
+
3
+ class UserMailerTest < ActionMailer::TestCase
4
+ setup do
5
+ @user = users(:lazaro_nixon)
6
+ end
7
+
8
+ test "password_reset" do
9
+ mail = UserMailer.with(user: @user).password_reset
10
+ assert_equal "Reset your password", mail.subject
11
+ assert_equal [@user.email], mail.to
12
+ end
13
+
14
+ test "email_verification" do
15
+ mail = UserMailer.with(user: @user).email_verification
16
+ assert_equal "Verify your email", mail.subject
17
+ assert_equal [@user.email], mail.to
18
+ end
19
+ end
@@ -8,7 +8,6 @@ class Identity::EmailsTest < ApplicationSystemTestCase
8
8
  test "updating the email" do
9
9
  click_on "Change email address"
10
10
 
11
- fill_in "Current password", with: "Secret1*3*5*"
12
11
  fill_in "New email", with: "new_email@hey.com"
13
12
  click_on "Save changes"
14
13
 
@@ -3,7 +3,7 @@ require "application_system_test_case"
3
3
  class Identity::PasswordResetsTest < ApplicationSystemTestCase
4
4
  setup do
5
5
  @user = users(:lazaro_nixon)
6
- @sid = @user.signed_id(purpose: :password_reset, expires_in: 20.minutes)
6
+ @sid = @user.password_reset_tokens.create.signed_id(expires_in: 20.minutes)
7
7
  end
8
8
 
9
9
  test "sending a password reset email" do
@@ -17,7 +17,7 @@ class Identity::PasswordResetsTest < ApplicationSystemTestCase
17
17
  end
18
18
 
19
19
  test "updating password" do
20
- visit edit_identity_password_reset_url(token: @sid)
20
+ visit edit_identity_password_reset_url(sid: @sid)
21
21
 
22
22
  fill_in "New password", with: "Secret6*4*2*"
23
23
  fill_in "Confirm new password", with: "Secret6*4*2*"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authentication-zero
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.15.8
4
+ version: 2.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nixon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-27 00:00:00.000000000 Z
11
+ date: 2022-12-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -18,8 +18,10 @@ extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
20
  - ".github/FUNDING.yml"
21
+ - ".github/workflows/CI.yml"
21
22
  - ".gitignore"
22
23
  - ".rubocop.yml"
24
+ - ".ruby-version"
23
25
  - CHANGELOG.md
24
26
  - CODE_OF_CONDUCT.md
25
27
  - Gemfile
@@ -47,6 +49,7 @@ files:
47
49
  - lib/generators/authentication/templates/controllers/api/sessions_controller.rb.tt
48
50
  - lib/generators/authentication/templates/controllers/html/application_controller.rb.tt
49
51
  - lib/generators/authentication/templates/controllers/html/authentications/events_controller.rb.tt
52
+ - lib/generators/authentication/templates/controllers/html/home_controller.rb.tt
50
53
  - lib/generators/authentication/templates/controllers/html/identity/email_verifications_controller.rb.tt
51
54
  - lib/generators/authentication/templates/controllers/html/identity/emails_controller.rb.tt
52
55
  - lib/generators/authentication/templates/controllers/html/identity/password_resets_controller.rb.tt
@@ -58,22 +61,20 @@ files:
58
61
  - lib/generators/authentication/templates/controllers/html/two_factor_authentication/challenges_controller.rb.tt
59
62
  - lib/generators/authentication/templates/controllers/html/two_factor_authentication/totps_controller.rb.tt
60
63
  - lib/generators/authentication/templates/erb/authentications/events/index.html.erb.tt
64
+ - lib/generators/authentication/templates/erb/home/index.html.erb.tt
61
65
  - lib/generators/authentication/templates/erb/identity/emails/edit.html.erb.tt
62
66
  - lib/generators/authentication/templates/erb/identity/password_resets/edit.html.erb.tt
63
67
  - lib/generators/authentication/templates/erb/identity/password_resets/new.html.erb.tt
64
68
  - lib/generators/authentication/templates/erb/passwords/edit.html.erb.tt
65
69
  - lib/generators/authentication/templates/erb/registrations/new.html.erb.tt
66
70
  - lib/generators/authentication/templates/erb/session_mailer/signed_in_notification.html.erb.tt
67
- - lib/generators/authentication/templates/erb/session_mailer/signed_in_notification.text.erb.tt
68
71
  - lib/generators/authentication/templates/erb/sessions/index.html.erb.tt
69
72
  - lib/generators/authentication/templates/erb/sessions/new.html.erb.tt
70
73
  - lib/generators/authentication/templates/erb/sessions/sudos/new.html.erb.tt
71
74
  - lib/generators/authentication/templates/erb/two_factor_authentication/challenges/new.html.erb.tt
72
75
  - lib/generators/authentication/templates/erb/two_factor_authentication/totps/new.html.erb.tt
73
76
  - lib/generators/authentication/templates/erb/user_mailer/email_verification.html.erb.tt
74
- - lib/generators/authentication/templates/erb/user_mailer/email_verification.text.erb.tt
75
77
  - lib/generators/authentication/templates/erb/user_mailer/password_reset.html.erb.tt
76
- - lib/generators/authentication/templates/erb/user_mailer/password_reset.text.erb.tt
77
78
  - lib/generators/authentication/templates/mailers/session_mailer.rb.tt
78
79
  - lib/generators/authentication/templates/mailers/user_mailer.rb.tt
79
80
  - lib/generators/authentication/templates/migrations/create_email_verification_tokens_migration.rb.tt
@@ -100,6 +101,8 @@ files:
100
101
  - lib/generators/authentication/templates/test_unit/controllers/html/passwords_controller_test.rb.tt
101
102
  - lib/generators/authentication/templates/test_unit/controllers/html/registrations_controller_test.rb.tt
102
103
  - lib/generators/authentication/templates/test_unit/controllers/html/sessions_controller_test.rb.tt
104
+ - lib/generators/authentication/templates/test_unit/mailers/session_mailer_test.rb.tt
105
+ - lib/generators/authentication/templates/test_unit/mailers/user_mailer_test.rb.tt
103
106
  - lib/generators/authentication/templates/test_unit/system/identity/emails_test.rb.tt
104
107
  - lib/generators/authentication/templates/test_unit/system/identity/password_resets_test.rb.tt
105
108
  - lib/generators/authentication/templates/test_unit/system/passwords_test.rb.tt
@@ -1,17 +0,0 @@
1
- Hey there,
2
-
3
- A new device just signed in to your account (<%%= @session.user.email %>).
4
-
5
- <%%= @session.user_agent %>
6
-
7
- <%%= @session.created_at %>
8
-
9
- <%%= @session.ip_address %>
10
-
11
- If this was you, carry on. We could notify you about sign-ins from this device again.
12
-
13
- If you don't recognize this device, someone else may have accessed your account. You should immediately [change your password]<%%= new_identity_password_reset_url %>.
14
-
15
- Tip: It's a good idea to periodically review all of the [devices and sessions]<%%= sessions_url %> in your account for suspicious activity.
16
-
17
- <p>Have questions or need help? Just reply to this email and our support team will help you sort it out.
@@ -1,13 +0,0 @@
1
- Hey there,
2
-
3
- This is to confirm that <%%= @user.email %> is the email you want to use on your account. If you ever lose your password, that's where we'll email a reset link.
4
-
5
- You must <%= code_verifiable? ? "put the code" : "hit the link" %> below to confirm that you received this email.
6
-
7
- <%- if code_verifiable? -%>
8
- <%%= @user.verification_code.value %>
9
- <%- else -%>
10
- [Yes, use this email for my account]<%%= edit_identity_email_verification_url(sid: @signed_id) %>
11
- <%- end -%>
12
-
13
- Have questions or need help? Just reply to this email and our support team will help you sort it out.
@@ -1,9 +0,0 @@
1
- Hey there,
2
-
3
- Can't remember your password for <%%= @user.email %>? That's OK, it happens. Just hit the link below to set a new one.
4
-
5
- [Reset my password]<%%= edit_identity_password_reset_url(sid: @signed_id) %>
6
-
7
- If you did not request a password reset you can safely ignore this email, it expires in 20 minutes. Only someone with access to this email account can reset your password.
8
-
9
- Have questions or need help? Just reply to this email and our support team will help you sort it out.