authentication-zero 2.16.14 → 2.16.15
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/.github/workflows/CI.yml +21 -34
- data/.ruby-version +1 -1
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -0
- data/lib/authentication_zero/version.rb +1 -1
- data/lib/generators/authentication/authentication_generator.rb +10 -0
- data/lib/generators/authentication/templates/controllers/html/masquerades_controller.rb.tt +20 -0
- data/lib/generators/authentication/templates/erb/home/index.html.erb.tt +5 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85fbe83273139a893939d4f20c3a06de269e0cea2b5fe3a7994f8d66919c3532
|
4
|
+
data.tar.gz: 63396f6a2ceb39fc3a49be717a6ffc7097c29e6782b7a351ca0d6f3bb7f2cae6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0899627eceb12252ec843541a19ec9da8de2e0d4ab12e76e43f34e1117597be485f58a090a66f825f2a1fdb1affe5c83cb55502e2deb7a681e2d70e7578ede31'
|
7
|
+
data.tar.gz: 8ee00bb247a6989e0c930b33ffefc5c546f6e2c4161d77297344343ec5585b6c80f5b11dd18cd06937b6264d4abb1d89b9f47d1ab80494201bf5d523cb289f86
|
data/.github/workflows/CI.yml
CHANGED
@@ -6,12 +6,11 @@
|
|
6
6
|
# run tests and linters.
|
7
7
|
name: "Generate sample app and run tests"
|
8
8
|
on: [push]
|
9
|
+
|
9
10
|
jobs:
|
10
11
|
test_html:
|
11
12
|
name: 🧪 Run HTML Tests
|
12
13
|
runs-on: ubuntu-latest
|
13
|
-
env:
|
14
|
-
RAILS_ENV: test
|
15
14
|
steps:
|
16
15
|
- name: Checkout code
|
17
16
|
uses: actions/checkout@v3
|
@@ -22,45 +21,39 @@ jobs:
|
|
22
21
|
bundler-cache: true
|
23
22
|
|
24
23
|
- name: Install the latest Rails gem
|
25
|
-
run: gem install rails
|
24
|
+
run: gem install rails -v "~> 7.0.0"
|
25
|
+
|
26
|
+
- name: Install Rubocop
|
27
|
+
run: gem install rubocop rubocop-performance rubocop-minitest rubocop-packaging rubocop-minitest rubocop-rails
|
26
28
|
|
27
29
|
- name: Create fresh Rails app and run generator
|
28
30
|
run: |
|
29
31
|
rails new test-app
|
32
|
+
cp .rubocop.yml test-app/.rubocop.yml
|
30
33
|
cd test-app
|
31
|
-
|
32
|
-
bundle add authentication-zero --github ${{ github.repository }} --branch ${{ github.ref_name }}
|
34
|
+
bundle add authentication-zero --path ..
|
33
35
|
bin/rails generate authentication
|
34
36
|
bundle install
|
35
37
|
bin/rails db:migrate
|
36
38
|
|
37
|
-
|
38
|
-
- name: Install Rubocop
|
39
|
-
run: gem install rubocop rubocop-performance rubocop-minitest rubocop-packaging rubocop-minitest rubocop-rails
|
40
|
-
|
41
39
|
- name: Rubocop
|
42
|
-
run:
|
43
|
-
cd test-app
|
44
|
-
rubocop
|
40
|
+
run: cd test-app && rubocop
|
45
41
|
|
46
|
-
- name: Install
|
42
|
+
- name: Install Brakeman
|
47
43
|
run: gem install brakeman
|
48
44
|
|
49
45
|
- name: Brakeman
|
50
|
-
run:
|
51
|
-
cd test-app
|
52
|
-
brakeman
|
46
|
+
run: cd test-app && brakeman
|
53
47
|
|
54
48
|
- name: Tests
|
55
49
|
run: |
|
56
50
|
cd test-app
|
57
51
|
bin/rails test
|
58
52
|
bin/rails test:system
|
53
|
+
|
59
54
|
test_api:
|
60
55
|
name: 🧪 Run API Tests
|
61
56
|
runs-on: ubuntu-latest
|
62
|
-
env:
|
63
|
-
RAILS_ENV: test
|
64
57
|
steps:
|
65
58
|
- name: Checkout code
|
66
59
|
uses: actions/checkout@v3
|
@@ -71,36 +64,30 @@ jobs:
|
|
71
64
|
bundler-cache: true
|
72
65
|
|
73
66
|
- name: Install the latest Rails gem
|
74
|
-
run: gem install rails
|
67
|
+
run: gem install rails -v "~> 7.0.0"
|
68
|
+
|
69
|
+
- name: Install Rubocop
|
70
|
+
run: gem install rubocop rubocop-performance rubocop-minitest rubocop-packaging rubocop-minitest rubocop-rails
|
75
71
|
|
76
72
|
- name: Create fresh Rails app and run generator
|
77
73
|
run: |
|
78
74
|
rails new test-app
|
75
|
+
cp .rubocop.yml test-app/.rubocop.yml
|
79
76
|
cd test-app
|
80
|
-
|
81
|
-
bundle add authentication-zero --github ${{ github.repository }} --branch ${{ github.ref_name }}
|
77
|
+
bundle add authentication-zero --path ..
|
82
78
|
bin/rails generate authentication --api
|
83
79
|
bundle install
|
84
80
|
bin/rails db:migrate
|
85
81
|
|
86
|
-
- name: Install Rubocop
|
87
|
-
run: gem install rubocop rubocop-performance rubocop-minitest rubocop-packaging rubocop-minitest rubocop-rails
|
88
|
-
|
89
82
|
- name: Rubocop
|
90
|
-
run:
|
91
|
-
cd test-app
|
92
|
-
rubocop
|
83
|
+
run: cd test-app && rubocop
|
93
84
|
|
94
|
-
- name: Install
|
85
|
+
- name: Install Brakeman
|
95
86
|
run: gem install brakeman
|
96
87
|
|
97
88
|
- name: Brakeman
|
98
|
-
run:
|
99
|
-
cd test-app
|
100
|
-
brakeman
|
89
|
+
run: cd test-app && brakeman
|
101
90
|
|
102
91
|
- name: Tests
|
103
|
-
run:
|
104
|
-
cd test-app
|
105
|
-
bin/rails test
|
92
|
+
run: cd test-app && bin/rails test
|
106
93
|
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.2.2
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -31,6 +31,7 @@ Since Authentication Zero generates this code into your application instead of b
|
|
31
31
|
- Two factor authentication (--two-factor)
|
32
32
|
- Social Login with OmniAuth (--omniauthable)
|
33
33
|
- Send invitations (--invitable)
|
34
|
+
- Sign-in as button functionallity (--masqueradable)
|
34
35
|
- Verify email using a link with token
|
35
36
|
- Verify email using a six random digits code for api (--code-verifiable)
|
36
37
|
- Ask password before sensitive data changes, aka: sudo (--sudoable)
|
@@ -14,6 +14,7 @@ class AuthenticationGenerator < Rails::Generators::Base
|
|
14
14
|
class_option :trackable, type: :boolean, desc: "Add activity log support"
|
15
15
|
class_option :two_factor, type: :boolean, desc: "Add two factor authentication"
|
16
16
|
class_option :invitable, type: :boolean, desc: "Add sending invitations"
|
17
|
+
class_option :masqueradable, type: :boolean, desc: "Add sign-in as button functionallity"
|
17
18
|
|
18
19
|
source_root File.expand_path("templates", __dir__)
|
19
20
|
|
@@ -86,6 +87,7 @@ class AuthenticationGenerator < Rails::Generators::Base
|
|
86
87
|
template "controllers/#{format_folder}/sessions_controller.rb", "app/controllers/sessions_controller.rb"
|
87
88
|
template "controllers/#{format_folder}/passwords_controller.rb", "app/controllers/passwords_controller.rb"
|
88
89
|
template "controllers/#{format_folder}/invitations_controller.rb", "app/controllers/invitations_controller.rb" if invitable?
|
90
|
+
template "controllers/#{format_folder}/masquerades_controller.rb", "app/controllers/masquerades_controller.rb" if masqueradable?
|
89
91
|
template "controllers/#{format_folder}/registrations_controller.rb", "app/controllers/registrations_controller.rb"
|
90
92
|
template "controllers/#{format_folder}/home_controller.rb", "app/controllers/home_controller.rb" unless options.api?
|
91
93
|
template "controllers/#{format_folder}/sessions/sudos_controller.rb", "app/controllers/sessions/sudos_controller.rb" if sudoable?
|
@@ -135,6 +137,10 @@ class AuthenticationGenerator < Rails::Generators::Base
|
|
135
137
|
route "resource :passwordless, only: [:new, :edit, :create]", namespace: :sessions
|
136
138
|
end
|
137
139
|
|
140
|
+
if masqueradable?
|
141
|
+
route 'post "users/:user_id/masquerade", to: "masquerades#create", as: :user_masquerade'
|
142
|
+
end
|
143
|
+
|
138
144
|
if omniauthable?
|
139
145
|
route 'post "/auth/:provider/callback", to: "sessions/omniauth#create"'
|
140
146
|
route 'get "/auth/:provider/callback", to: "sessions/omniauth#create"'
|
@@ -199,6 +205,10 @@ class AuthenticationGenerator < Rails::Generators::Base
|
|
199
205
|
options.invitable? && !options.api?
|
200
206
|
end
|
201
207
|
|
208
|
+
def masqueradable?
|
209
|
+
options.masqueradable? && !options.api?
|
210
|
+
end
|
211
|
+
|
202
212
|
def sudoable?
|
203
213
|
options.sudoable? && !options.api?
|
204
214
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class MasqueradesController < ApplicationController
|
2
|
+
before_action :authorize
|
3
|
+
before_action :set_user
|
4
|
+
|
5
|
+
def create
|
6
|
+
session = @user.sessions.create!
|
7
|
+
cookies.signed.permanent[:session_token] = { value: session.id, httponly: true }
|
8
|
+
|
9
|
+
redirect_to root_path, notice: "Signed in successfully"
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
def set_user
|
14
|
+
@user = User.find(params[:user_id])
|
15
|
+
end
|
16
|
+
|
17
|
+
def authorize
|
18
|
+
redirect_to(root_path, alert: "You must be in development") unless Rails.env.development?
|
19
|
+
end
|
20
|
+
end
|
@@ -24,6 +24,11 @@
|
|
24
24
|
<%%= link_to "Send invitation", new_invitation_path %>
|
25
25
|
</div>
|
26
26
|
<%- end -%>
|
27
|
+
<%- if masqueradable? %>
|
28
|
+
<div>
|
29
|
+
<%%= button_to "Signin as last user", user_masquerade_path(User.last) %>
|
30
|
+
</div>
|
31
|
+
<%- end -%>
|
27
32
|
<%- if two_factor? %>
|
28
33
|
<div>
|
29
34
|
<%%= link_to "Two-Factor Authentication", new_two_factor_authentication_totp_path %>
|
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: 2.16.
|
4
|
+
version: 2.16.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nixon
|
@@ -52,6 +52,7 @@ files:
|
|
52
52
|
- lib/generators/authentication/templates/controllers/html/identity/emails_controller.rb.tt
|
53
53
|
- lib/generators/authentication/templates/controllers/html/identity/password_resets_controller.rb.tt
|
54
54
|
- lib/generators/authentication/templates/controllers/html/invitations_controller.rb.tt
|
55
|
+
- lib/generators/authentication/templates/controllers/html/masquerades_controller.rb.tt
|
55
56
|
- lib/generators/authentication/templates/controllers/html/passwords_controller.rb.tt
|
56
57
|
- lib/generators/authentication/templates/controllers/html/registrations_controller.rb.tt
|
57
58
|
- lib/generators/authentication/templates/controllers/html/sessions/omniauth_controller.rb.tt
|
@@ -135,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
136
|
- !ruby/object:Gem::Version
|
136
137
|
version: '0'
|
137
138
|
requirements: []
|
138
|
-
rubygems_version: 3.
|
139
|
+
rubygems_version: 3.4.10
|
139
140
|
signing_key:
|
140
141
|
specification_version: 4
|
141
142
|
summary: An authentication system generator for Rails applications
|