authentication-zero 2.16.13 → 2.16.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/CI.yml +49 -11
- data/.rubocop.yml +3 -10
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +1 -1
- data/lib/authentication_zero/version.rb +1 -1
- data/lib/generators/authentication/authentication_generator.rb +9 -8
- data/lib/generators/authentication/templates/controllers/api/identity/emails_controller.rb.tt +1 -1
- data/lib/generators/authentication/templates/controllers/html/identity/emails_controller.rb.tt +1 -1
- data/lib/generators/authentication/templates/controllers/html/invitations_controller.rb.tt +1 -1
- data/lib/generators/authentication/templates/controllers/html/sessions/omniauth_controller.rb.tt +1 -1
- data/lib/generators/authentication/templates/models/user.rb.tt +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0f83db44ee39461a039edbf34e4ab4b1af7698fc537361607b120310e3d828e
|
4
|
+
data.tar.gz: ecbf7f8578a9612f30bd7d19d9c482c7d9dbf62e2a28fa148f25c7cb5eb3bad6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8b1ed8282c418a5941295a522640ec2bcbc43fcd5dd8f6743333a860051c7c2858301d019f4f3400e217e2a385527809ab7bee61ef49306e4f6aba88bbdad38
|
7
|
+
data.tar.gz: 48220896d353c7aa5c37584f84ec4bd75d189f2205440fe754256fd2cfb885d31a2e87859d8756ec54502ef1e5f6cad51eede0662b664a26dc9f2daa066ea8e6
|
data/.github/workflows/CI.yml
CHANGED
@@ -5,9 +5,7 @@
|
|
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]
|
11
9
|
jobs:
|
12
10
|
test_html:
|
13
11
|
name: 🧪 Run HTML Tests
|
@@ -26,16 +24,36 @@ jobs:
|
|
26
24
|
- name: Install the latest Rails gem
|
27
25
|
run: gem install rails
|
28
26
|
|
29
|
-
- name: Create fresh Rails app
|
30
|
-
env:
|
31
|
-
CI: true
|
27
|
+
- name: Create fresh Rails app and run generator
|
32
28
|
run: |
|
33
29
|
rails new test-app
|
34
30
|
cd test-app
|
31
|
+
wget https://raw.githubusercontent.com/lazaronixon/authentication-zero/master/.rubocop.yml
|
35
32
|
bundle add authentication-zero --github ${{ github.repository }} --branch ${{ github.ref_name }}
|
36
33
|
bin/rails generate authentication
|
37
34
|
bundle install
|
38
35
|
bin/rails db:migrate
|
36
|
+
|
37
|
+
|
38
|
+
- name: Install Rubocop
|
39
|
+
run: gem install rubocop rubocop-performance rubocop-minitest rubocop-packaging rubocop-minitest rubocop-rails
|
40
|
+
|
41
|
+
- name: Rubocop
|
42
|
+
run: |
|
43
|
+
cd test-app
|
44
|
+
rubocop
|
45
|
+
|
46
|
+
- name: Install brakeman
|
47
|
+
run: gem install brakeman
|
48
|
+
|
49
|
+
- name: Brakeman
|
50
|
+
run: |
|
51
|
+
cd test-app
|
52
|
+
brakeman
|
53
|
+
|
54
|
+
- name: Tests
|
55
|
+
run: |
|
56
|
+
cd test-app
|
39
57
|
bin/rails test
|
40
58
|
bin/rails test:system
|
41
59
|
test_api:
|
@@ -55,14 +73,34 @@ jobs:
|
|
55
73
|
- name: Install the latest Rails gem
|
56
74
|
run: gem install rails
|
57
75
|
|
58
|
-
- name: Create fresh Rails app
|
59
|
-
env:
|
60
|
-
CI: true
|
76
|
+
- name: Create fresh Rails app and run generator
|
61
77
|
run: |
|
62
|
-
rails new test-app
|
78
|
+
rails new test-app
|
63
79
|
cd test-app
|
80
|
+
wget https://raw.githubusercontent.com/lazaronixon/authentication-zero/master/.rubocop.yml
|
64
81
|
bundle add authentication-zero --github ${{ github.repository }} --branch ${{ github.ref_name }}
|
65
|
-
bin/rails generate authentication
|
82
|
+
bin/rails generate authentication --api
|
66
83
|
bundle install
|
67
84
|
bin/rails db:migrate
|
85
|
+
|
86
|
+
- name: Install Rubocop
|
87
|
+
run: gem install rubocop rubocop-performance rubocop-minitest rubocop-packaging rubocop-minitest rubocop-rails
|
88
|
+
|
89
|
+
- name: Rubocop
|
90
|
+
run: |
|
91
|
+
cd test-app
|
92
|
+
rubocop
|
93
|
+
|
94
|
+
- name: Install brakeman
|
95
|
+
run: gem install brakeman
|
96
|
+
|
97
|
+
- name: Brakeman
|
98
|
+
run: |
|
99
|
+
cd test-app
|
100
|
+
brakeman
|
101
|
+
|
102
|
+
- name: Tests
|
103
|
+
run: |
|
104
|
+
cd test-app
|
68
105
|
bin/rails test
|
106
|
+
|
data/.rubocop.yml
CHANGED
@@ -1,15 +1,8 @@
|
|
1
|
-
inherit_from: https://raw.githubusercontent.com/rails/rails/
|
1
|
+
inherit_from: https://raw.githubusercontent.com/rails/rails/v7.0.4/.rubocop.yml
|
2
2
|
|
3
|
-
|
3
|
+
Style/HashSyntax:
|
4
4
|
Exclude:
|
5
|
-
-
|
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/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -125,7 +125,7 @@ class AuthenticationGenerator < Rails::Generators::Base
|
|
125
125
|
end
|
126
126
|
|
127
127
|
def add_routes
|
128
|
-
route
|
128
|
+
route 'root "home#index"' unless options.api?
|
129
129
|
|
130
130
|
if sudoable?
|
131
131
|
route "resource :sudo, only: [:new, :create]", namespace: :sessions
|
@@ -136,9 +136,9 @@ class AuthenticationGenerator < Rails::Generators::Base
|
|
136
136
|
end
|
137
137
|
|
138
138
|
if omniauthable?
|
139
|
-
route
|
140
|
-
route
|
141
|
-
route
|
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"'
|
142
142
|
end
|
143
143
|
|
144
144
|
if two_factor?
|
@@ -153,13 +153,14 @@ class AuthenticationGenerator < Rails::Generators::Base
|
|
153
153
|
route "resource :password_reset, only: [:new, :edit, :create, :update]", namespace: :identity
|
154
154
|
route "resource :email_verification, only: [:show, :create]", namespace: :identity
|
155
155
|
route "resource :email, only: [:edit, :update]", namespace: :identity
|
156
|
+
|
156
157
|
route "resource :invitation, only: [:new, :create]" if invitable?
|
157
158
|
route "resource :password, only: [:edit, :update]"
|
158
159
|
route "resources :sessions, only: [:index, :show, :destroy]"
|
159
|
-
route
|
160
|
-
route
|
161
|
-
route
|
162
|
-
route
|
160
|
+
route 'post "sign_up", to: "registrations#create"'
|
161
|
+
route 'get "sign_up", to: "registrations#new"' unless options.api?
|
162
|
+
route 'post "sign_in", to: "sessions#create"'
|
163
|
+
route 'get "sign_in", to: "sessions#new"' unless options.api?
|
163
164
|
end
|
164
165
|
|
165
166
|
def create_test_files
|
data/lib/generators/authentication/templates/controllers/api/identity/emails_controller.rb.tt
CHANGED
@@ -2,7 +2,7 @@ class Identity::EmailsController < ApplicationController
|
|
2
2
|
before_action :set_user
|
3
3
|
|
4
4
|
def update
|
5
|
-
|
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
|
data/lib/generators/authentication/templates/controllers/html/identity/emails_controller.rb.tt
CHANGED
@@ -5,7 +5,7 @@ class Identity::EmailsController < ApplicationController
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def update
|
8
|
-
|
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
|
19
|
+
params.permit(:email).merge(password: SecureRandom.base58, verified: true)
|
20
20
|
end
|
21
21
|
|
22
22
|
def send_invitation_instructions
|
data/lib/generators/authentication/templates/controllers/html/sessions/omniauth_controller.rb.tt
CHANGED
@@ -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
|
24
|
+
{ email: omniauth.info.email, password: SecureRandom.base58, verified: true }
|
25
25
|
end
|
26
26
|
|
27
27
|
def omniauth_params
|
@@ -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 }
|
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 -%>
|