authentication-zero 2.16.13 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd4aba188e6a8763ada4f0cc90f370e8980afd0903e3e5f17a5f4bcc5db7c8d6
4
- data.tar.gz: 8e16e20f5ed9d2cf1aadd469bdeffae20e1c51ab030bb5731697ae37dd749079
3
+ metadata.gz: 85fbe83273139a893939d4f20c3a06de269e0cea2b5fe3a7994f8d66919c3532
4
+ data.tar.gz: 63396f6a2ceb39fc3a49be717a6ffc7097c29e6782b7a351ca0d6f3bb7f2cae6
5
5
  SHA512:
6
- metadata.gz: dc0688a6b1fae46b456d7c7ce473f1a4414f13bf9bc29439c6d687a67e9122d58eb76e592ef2796c79f1b0e19816e66e6a92f7278dc9df31c9595382108016ce
7
- data.tar.gz: 06d51e04679f0821a4cb296f2e06f588c0614b75ae1f8ca6ce370cbca494d950280b617e8f6346539ddbe8d412838c9fdb9fceb4b6315d47b3471e30b9b7cd19
6
+ metadata.gz: '0899627eceb12252ec843541a19ec9da8de2e0d4ab12e76e43f34e1117597be485f58a090a66f825f2a1fdb1affe5c83cb55502e2deb7a681e2d70e7578ede31'
7
+ data.tar.gz: 8ee00bb247a6989e0c930b33ffefc5c546f6e2c4161d77297344343ec5585b6c80f5b11dd18cd06937b6264d4abb1d89b9f47d1ab80494201bf5d523cb289f86
@@ -5,15 +5,12 @@
5
5
  # This workflow will install a prebuilt Ruby version, install dependencies, and
6
6
  # run tests and linters.
7
7
  name: "Generate sample app and run tests"
8
- on:
9
- push:
10
- branches: ["*"]
8
+ on: [push]
9
+
11
10
  jobs:
12
11
  test_html:
13
12
  name: 🧪 Run HTML Tests
14
13
  runs-on: ubuntu-latest
15
- env:
16
- RAILS_ENV: test
17
14
  steps:
18
15
  - name: Checkout code
19
16
  uses: actions/checkout@v3
@@ -24,25 +21,39 @@ jobs:
24
21
  bundler-cache: true
25
22
 
26
23
  - name: Install the latest Rails gem
27
- 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
28
28
 
29
- - name: Create fresh Rails app then run generator and tests
30
- env:
31
- CI: true
29
+ - name: Create fresh Rails app and run generator
32
30
  run: |
33
31
  rails new test-app
32
+ cp .rubocop.yml test-app/.rubocop.yml
34
33
  cd test-app
35
- bundle add authentication-zero --github ${{ github.repository }} --branch ${{ github.ref_name }}
34
+ bundle add authentication-zero --path ..
36
35
  bin/rails generate authentication
37
36
  bundle install
38
37
  bin/rails db:migrate
38
+
39
+ - name: Rubocop
40
+ run: cd test-app && rubocop
41
+
42
+ - name: Install Brakeman
43
+ run: gem install brakeman
44
+
45
+ - name: Brakeman
46
+ run: cd test-app && brakeman
47
+
48
+ - name: Tests
49
+ run: |
50
+ cd test-app
39
51
  bin/rails test
40
52
  bin/rails test:system
53
+
41
54
  test_api:
42
55
  name: 🧪 Run API Tests
43
56
  runs-on: ubuntu-latest
44
- env:
45
- RAILS_ENV: test
46
57
  steps:
47
58
  - name: Checkout code
48
59
  uses: actions/checkout@v3
@@ -53,16 +64,30 @@ jobs:
53
64
  bundler-cache: true
54
65
 
55
66
  - name: Install the latest Rails gem
56
- run: gem install rails
67
+ run: gem install rails -v "~> 7.0.0"
57
68
 
58
- - name: Create fresh Rails app then run generator and tests
59
- env:
60
- CI: true
69
+ - name: Install Rubocop
70
+ run: gem install rubocop rubocop-performance rubocop-minitest rubocop-packaging rubocop-minitest rubocop-rails
71
+
72
+ - name: Create fresh Rails app and run generator
61
73
  run: |
62
- rails new test-app --api
74
+ rails new test-app
75
+ cp .rubocop.yml test-app/.rubocop.yml
63
76
  cd test-app
64
- bundle add authentication-zero --github ${{ github.repository }} --branch ${{ github.ref_name }}
65
- bin/rails generate authentication
77
+ bundle add authentication-zero --path ..
78
+ bin/rails generate authentication --api
66
79
  bundle install
67
80
  bin/rails db:migrate
68
- bin/rails test
81
+
82
+ - name: Rubocop
83
+ run: cd test-app && rubocop
84
+
85
+ - name: Install Brakeman
86
+ run: gem install brakeman
87
+
88
+ - name: Brakeman
89
+ run: cd test-app && brakeman
90
+
91
+ - name: Tests
92
+ run: cd test-app && bin/rails test
93
+
data/.rubocop.yml CHANGED
@@ -1,15 +1,8 @@
1
- inherit_from: https://raw.githubusercontent.com/rails/rails/master/.rubocop.yml
1
+ inherit_from: https://raw.githubusercontent.com/rails/rails/v7.0.4/.rubocop.yml
2
2
 
3
- Performance:
3
+ Style/HashSyntax:
4
4
  Exclude:
5
- - 'test/**/*'
5
+ - Gemfile
6
6
 
7
7
  Style/FrozenStringLiteralComment:
8
8
  Enabled: false
9
-
10
- Style/StringLiterals:
11
- Enabled: true
12
- EnforcedStyle: double_quotes
13
- Include:
14
- - 'app/**/*'
15
- - 'test/**/*'
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.1.2
1
+ 3.2.2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## Authentication Zero 2.16.15 ##
2
+
3
+ * Add sign-in as button functionallity (--masqueradable)
4
+
5
+ ## Authentication Zero 2.16.14 ##
6
+
7
+ * Remove password requirements
8
+ * Rubocop compliant
9
+ * Brakeman compliant
10
+
1
11
  ## Authentication Zero 2.16.13 ##
2
12
 
3
13
  * Enable resend invitation
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- authentication-zero (2.16.13)
4
+ authentication-zero (2.16.15)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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)
@@ -1,3 +1,3 @@
1
1
  module AuthenticationZero
2
- VERSION = "2.16.13"
2
+ VERSION = "2.16.15"
3
3
  end
@@ -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?
@@ -125,7 +127,7 @@ class AuthenticationGenerator < Rails::Generators::Base
125
127
  end
126
128
 
127
129
  def add_routes
128
- route "root 'home#index'" unless options.api?
130
+ route 'root "home#index"' unless options.api?
129
131
 
130
132
  if sudoable?
131
133
  route "resource :sudo, only: [:new, :create]", namespace: :sessions
@@ -135,10 +137,14 @@ 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
- route "post '/auth/:provider/callback', to: 'sessions/omniauth#create'"
140
- route "get '/auth/:provider/callback', to: 'sessions/omniauth#create'"
141
- route "get '/auth/failure', to: 'sessions/omniauth#failure'"
145
+ route 'post "/auth/:provider/callback", to: "sessions/omniauth#create"'
146
+ route 'get "/auth/:provider/callback", to: "sessions/omniauth#create"'
147
+ route 'get "/auth/failure", to: "sessions/omniauth#failure"'
142
148
  end
143
149
 
144
150
  if two_factor?
@@ -153,13 +159,14 @@ class AuthenticationGenerator < Rails::Generators::Base
153
159
  route "resource :password_reset, only: [:new, :edit, :create, :update]", namespace: :identity
154
160
  route "resource :email_verification, only: [:show, :create]", namespace: :identity
155
161
  route "resource :email, only: [:edit, :update]", namespace: :identity
162
+
156
163
  route "resource :invitation, only: [:new, :create]" if invitable?
157
164
  route "resource :password, only: [:edit, :update]"
158
165
  route "resources :sessions, only: [:index, :show, :destroy]"
159
- route "post 'sign_up', to: 'registrations#create'"
160
- route "get 'sign_up', to: 'registrations#new'" unless options.api?
161
- route "post 'sign_in', to: 'sessions#create'"
162
- route "get 'sign_in', to: 'sessions#new'" unless options.api?
166
+ route 'post "sign_up", to: "registrations#create"'
167
+ route 'get "sign_up", to: "registrations#new"' unless options.api?
168
+ route 'post "sign_in", to: "sessions#create"'
169
+ route 'get "sign_in", to: "sessions#new"' unless options.api?
163
170
  end
164
171
 
165
172
  def create_test_files
@@ -198,6 +205,10 @@ class AuthenticationGenerator < Rails::Generators::Base
198
205
  options.invitable? && !options.api?
199
206
  end
200
207
 
208
+ def masqueradable?
209
+ options.masqueradable? && !options.api?
210
+ end
211
+
201
212
  def sudoable?
202
213
  options.sudoable? && !options.api?
203
214
  end
@@ -2,7 +2,7 @@ class Identity::EmailsController < ApplicationController
2
2
  before_action :set_user
3
3
 
4
4
  def update
5
- if !@user.authenticate(params[:current_password])
5
+ if !@user.authenticate(params[:current_password])
6
6
  render json: { error: "The password you entered is incorrect" }, status: :bad_request
7
7
  elsif @user.update(user_params)
8
8
  render_show
@@ -5,7 +5,7 @@ class Identity::EmailsController < ApplicationController
5
5
  end
6
6
 
7
7
  def update
8
- if !@user.authenticate(params[:current_password])
8
+ if !@user.authenticate(params[:current_password])
9
9
  redirect_to edit_identity_email_path, alert: "The password you entered is incorrect"
10
10
  elsif @user.update(user_params)
11
11
  redirect_to_root
@@ -16,7 +16,7 @@ class InvitationsController < ApplicationController
16
16
 
17
17
  private
18
18
  def user_params
19
- params.permit(:email).merge(password: SecureRandom::base58, verified: true)
19
+ params.permit(:email).merge(password: SecureRandom.base58, verified: true)
20
20
  end
21
21
 
22
22
  def send_invitation_instructions
@@ -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
@@ -21,7 +21,7 @@ class Sessions::OmniauthController < ApplicationController
21
21
 
22
22
  private
23
23
  def user_params
24
- { email: omniauth.info.email, password: SecureRandom::base58, verified: true }
24
+ { email: omniauth.info.email, password: SecureRandom.base58, verified: true }
25
25
  end
26
26
 
27
27
  def omniauth_params
@@ -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 %>
@@ -16,7 +16,7 @@ class User < ApplicationRecord
16
16
  <%- end -%>
17
17
 
18
18
  validates :email, presence: true, uniqueness: true, format: { with: URI::MailTo::EMAIL_REGEXP }
19
- validates :password, allow_nil: true, length: { minimum: 12 }, format: { with: /(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])/ }
19
+ validates :password, allow_nil: true, length: { minimum: 12 }
20
20
  <%- if options.pwned? -%>
21
21
  validates :password, not_pwned: { message: "might easily be guessed" }
22
22
  <%- end -%>
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.13
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.3.7
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