kaze 2.1.1 → 2.2.1
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/CHANGELOG.md +63 -1
- data/README.md +21 -1
- data/lib/kaze/commands/app/base_stack.rb +37 -3
- data/lib/kaze/commands/app/hotwire_stack.rb +5 -3
- data/lib/kaze/commands/app/inertia_react_stack.rb +4 -3
- data/lib/kaze/commands/app/inertia_vue_stack.rb +4 -3
- data/lib/kaze/version.rb +1 -1
- data/stubs/default/app/forms/auth/login_form.rb +6 -1
- data/stubs/default/app/forms/auth/two_factor_challenge_form.rb +24 -0
- data/stubs/default/app/forms/confirm_two_factor_form.rb +5 -0
- data/stubs/default/app/forms/disable_two_factor_form.rb +7 -0
- data/stubs/default/app/models/concerns/two_factor_authenticatable.rb +112 -0
- data/stubs/default/app/models/session_guard.rb +8 -1
- data/stubs/default/app/models/two_factor_challenge.rb +55 -0
- data/stubs/default/app/models/user.rb +1 -0
- data/stubs/default/config/initializers/active_record_encryption.rb +20 -0
- data/stubs/default/config/routes.rb +9 -0
- data/stubs/default/db/migrate/20240101000001_add_two_factor_to_users.rb +15 -0
- data/stubs/default/test/integration/auth/rate_limiting_test.rb +64 -0
- data/stubs/default/test/integration/auth/two_factor_challenge_test.rb +114 -0
- data/stubs/default/test/integration/settings/two_factor_test.rb +104 -0
- data/stubs/default/test/models/two_factor_authenticatable_test.rb +143 -0
- data/stubs/default/test/test_helper.rb +16 -0
- data/stubs/hotwire/app/controllers/auth/authenticated_session_controller.rb +32 -1
- data/stubs/hotwire/app/controllers/auth/two_factor_challenge_controller.rb +59 -0
- data/stubs/hotwire/app/controllers/concerns/set_two_factor_challenge.rb +8 -0
- data/stubs/hotwire/app/controllers/settings/two_factor_controller.rb +48 -0
- data/stubs/hotwire/app/views/auth/two_factor_challenge.html.erb +21 -0
- data/stubs/hotwire/app/views/layouts/_settings.html.erb +1 -0
- data/stubs/hotwire/app/views/settings/two_factor/_confirming.html.erb +20 -0
- data/stubs/hotwire/app/views/settings/two_factor/_disabled.html.erb +8 -0
- data/stubs/hotwire/app/views/settings/two_factor/_enabled.html.erb +29 -0
- data/stubs/hotwire/app/views/settings/two_factor/edit.html.erb +16 -0
- data/stubs/inertia-common/app/controllers/auth/authenticated_session_controller.rb +30 -1
- data/stubs/inertia-common/app/controllers/auth/two_factor_challenge_controller.rb +53 -0
- data/stubs/inertia-common/app/controllers/concerns/set_two_factor_challenge.rb +8 -0
- data/stubs/inertia-common/app/controllers/settings/two_factor_controller.rb +60 -0
- data/stubs/inertia-react-ts/app/javascript/Layouts/SettingsLayout.tsx +5 -1
- data/stubs/inertia-react-ts/app/javascript/Pages/Auth/TwoFactorChallenge.tsx +71 -0
- data/stubs/inertia-react-ts/app/javascript/Pages/Settings/TwoFactor.tsx +199 -0
- data/stubs/inertia-vue-ts/app/javascript/Layouts/SettingsLayout.vue +5 -1
- data/stubs/inertia-vue-ts/app/javascript/Pages/Auth/TwoFactorChallenge.vue +60 -0
- data/stubs/inertia-vue-ts/app/javascript/Pages/Settings/TwoFactor.vue +147 -0
- metadata +27 -1
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { Head, useForm } from '@inertiajs/vue3'
|
|
3
|
+
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout.vue'
|
|
4
|
+
import SettingsLayout from '@/Layouts/SettingsLayout.vue'
|
|
5
|
+
import Heading from '@/Components/Heading.vue'
|
|
6
|
+
import InputError from '@/Components/InputError.vue'
|
|
7
|
+
import { Button } from '@/Components/ui/button'
|
|
8
|
+
import { Input } from '@/Components/ui/input'
|
|
9
|
+
import { Label } from '@/Components/ui/label'
|
|
10
|
+
import {
|
|
11
|
+
two_factor_destroy_path,
|
|
12
|
+
two_factor_edit_path,
|
|
13
|
+
two_factor_recovery_codes_path,
|
|
14
|
+
two_factor_store_path,
|
|
15
|
+
two_factor_update_path,
|
|
16
|
+
} from '@/routes'
|
|
17
|
+
import { BreadcrumbItem } from '@/types'
|
|
18
|
+
|
|
19
|
+
defineProps<{
|
|
20
|
+
enabled: boolean
|
|
21
|
+
pending: boolean
|
|
22
|
+
qrCode: string | null
|
|
23
|
+
secret: string | null
|
|
24
|
+
recoveryCodes: string[]
|
|
25
|
+
}>()
|
|
26
|
+
|
|
27
|
+
const breadcrumbs: BreadcrumbItem[] = [
|
|
28
|
+
{
|
|
29
|
+
title: 'Two factor settings',
|
|
30
|
+
href: two_factor_edit_path(),
|
|
31
|
+
},
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
const enableForm = useForm({})
|
|
35
|
+
const confirmForm = useForm({ code: '' })
|
|
36
|
+
const regenerateForm = useForm({})
|
|
37
|
+
const disableForm = useForm({ password: '' })
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<template>
|
|
41
|
+
<Head title="Two factor settings" />
|
|
42
|
+
|
|
43
|
+
<AuthenticatedLayout :breadcrumbs="breadcrumbs">
|
|
44
|
+
<SettingsLayout>
|
|
45
|
+
<div class="space-y-6">
|
|
46
|
+
<Heading
|
|
47
|
+
variant="small"
|
|
48
|
+
title="Two factor authentication"
|
|
49
|
+
description="Add a second step to signing in, using an authenticator app"
|
|
50
|
+
/>
|
|
51
|
+
|
|
52
|
+
<template v-if="enabled">
|
|
53
|
+
<p class="text-sm text-muted-foreground">
|
|
54
|
+
Two factor authentication is on. You will be asked for a code each time you sign in.
|
|
55
|
+
</p>
|
|
56
|
+
|
|
57
|
+
<div class="space-y-3 rounded-xl border border-sidebar-border/70 p-4 dark:border-sidebar-border">
|
|
58
|
+
<div class="text-sm font-medium">Recovery codes</div>
|
|
59
|
+
|
|
60
|
+
<p class="text-sm text-muted-foreground">
|
|
61
|
+
Keep these somewhere safe. Each one can be used once to sign in if you cannot reach your authenticator
|
|
62
|
+
app.
|
|
63
|
+
</p>
|
|
64
|
+
|
|
65
|
+
<ul class="grid grid-cols-2 gap-1 font-mono text-xs">
|
|
66
|
+
<li v-for="recoveryCode in recoveryCodes" :key="recoveryCode">{{ recoveryCode }}</li>
|
|
67
|
+
</ul>
|
|
68
|
+
|
|
69
|
+
<form @submit.prevent="regenerateForm.post(two_factor_recovery_codes_path())">
|
|
70
|
+
<Button variant="outline" :disabled="regenerateForm.processing">Generate new codes</Button>
|
|
71
|
+
</form>
|
|
72
|
+
</div>
|
|
73
|
+
|
|
74
|
+
<form class="space-y-6" @submit.prevent="disableForm.delete(two_factor_destroy_path())">
|
|
75
|
+
<div>
|
|
76
|
+
<Label for="password">Current password</Label>
|
|
77
|
+
|
|
78
|
+
<Input
|
|
79
|
+
id="password"
|
|
80
|
+
v-model="disableForm.password"
|
|
81
|
+
type="password"
|
|
82
|
+
name="password"
|
|
83
|
+
class="mt-1 block w-full max-w-xs"
|
|
84
|
+
autocomplete="current-password"
|
|
85
|
+
/>
|
|
86
|
+
|
|
87
|
+
<InputError :message="disableForm.errors.password" class="mt-2" />
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
<Button variant="destructive" :disabled="disableForm.processing">
|
|
91
|
+
Turn off two factor authentication
|
|
92
|
+
</Button>
|
|
93
|
+
</form>
|
|
94
|
+
</template>
|
|
95
|
+
|
|
96
|
+
<template v-else-if="pending">
|
|
97
|
+
<p class="text-sm text-muted-foreground">
|
|
98
|
+
Scan this with your authenticator app, then enter the code it shows to finish turning it on.
|
|
99
|
+
</p>
|
|
100
|
+
|
|
101
|
+
<!-- eslint-disable-next-line vue/no-v-html -->
|
|
102
|
+
<div
|
|
103
|
+
v-if="qrCode"
|
|
104
|
+
class="w-44 rounded-lg border border-sidebar-border/70 bg-white p-2 dark:border-sidebar-border"
|
|
105
|
+
v-html="qrCode"
|
|
106
|
+
/>
|
|
107
|
+
|
|
108
|
+
<p class="text-sm text-muted-foreground">
|
|
109
|
+
Cannot scan it? Enter this key instead:
|
|
110
|
+
<code class="rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground">{{ secret }}</code>
|
|
111
|
+
</p>
|
|
112
|
+
|
|
113
|
+
<form class="space-y-6" @submit.prevent="confirmForm.patch(two_factor_update_path())">
|
|
114
|
+
<div>
|
|
115
|
+
<Label for="code">Code</Label>
|
|
116
|
+
|
|
117
|
+
<Input
|
|
118
|
+
id="code"
|
|
119
|
+
v-model="confirmForm.code"
|
|
120
|
+
name="code"
|
|
121
|
+
class="mt-1 block w-full max-w-xs"
|
|
122
|
+
inputmode="numeric"
|
|
123
|
+
autocomplete="one-time-code"
|
|
124
|
+
autofocus
|
|
125
|
+
/>
|
|
126
|
+
|
|
127
|
+
<InputError :message="confirmForm.errors.code" class="mt-2" />
|
|
128
|
+
</div>
|
|
129
|
+
|
|
130
|
+
<Button :disabled="confirmForm.processing">Confirm</Button>
|
|
131
|
+
</form>
|
|
132
|
+
</template>
|
|
133
|
+
|
|
134
|
+
<template v-else>
|
|
135
|
+
<p class="text-sm text-muted-foreground">
|
|
136
|
+
Two factor authentication is off. Turn it on and you will be asked for a code from your authenticator app
|
|
137
|
+
each time you sign in.
|
|
138
|
+
</p>
|
|
139
|
+
|
|
140
|
+
<form @submit.prevent="enableForm.post(two_factor_store_path())">
|
|
141
|
+
<Button :disabled="enableForm.processing">Turn on two factor authentication</Button>
|
|
142
|
+
</form>
|
|
143
|
+
</template>
|
|
144
|
+
</div>
|
|
145
|
+
</SettingsLayout>
|
|
146
|
+
</AuthenticatedLayout>
|
|
147
|
+
</template>
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kaze
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Cuong Giang
|
|
@@ -92,7 +92,10 @@ files:
|
|
|
92
92
|
- stubs/default/app/forms/auth/new_password_form.rb
|
|
93
93
|
- stubs/default/app/forms/auth/register_form.rb
|
|
94
94
|
- stubs/default/app/forms/auth/send_password_reset_link_form.rb
|
|
95
|
+
- stubs/default/app/forms/auth/two_factor_challenge_form.rb
|
|
96
|
+
- stubs/default/app/forms/confirm_two_factor_form.rb
|
|
95
97
|
- stubs/default/app/forms/delete_user_form.rb
|
|
98
|
+
- stubs/default/app/forms/disable_two_factor_form.rb
|
|
96
99
|
- stubs/default/app/forms/update_password_form.rb
|
|
97
100
|
- stubs/default/app/forms/update_profile_information_form.rb
|
|
98
101
|
- stubs/default/app/mailers/application_mailer.rb
|
|
@@ -100,8 +103,10 @@ files:
|
|
|
100
103
|
- stubs/default/app/models/application_record.rb
|
|
101
104
|
- stubs/default/app/models/concerns/can_reset_password.rb
|
|
102
105
|
- stubs/default/app/models/concerns/must_verify_email.rb
|
|
106
|
+
- stubs/default/app/models/concerns/two_factor_authenticatable.rb
|
|
103
107
|
- stubs/default/app/models/current.rb
|
|
104
108
|
- stubs/default/app/models/session_guard.rb
|
|
109
|
+
- stubs/default/app/models/two_factor_challenge.rb
|
|
105
110
|
- stubs/default/app/models/user.rb
|
|
106
111
|
- stubs/default/app/validators/current_password_validator.rb
|
|
107
112
|
- stubs/default/app/validators/email_validator.rb
|
|
@@ -112,16 +117,22 @@ files:
|
|
|
112
117
|
- stubs/default/app/views/user_mailer/reset_password.html.erb
|
|
113
118
|
- stubs/default/app/views/user_mailer/verify_email.html.erb
|
|
114
119
|
- stubs/default/bin/dev
|
|
120
|
+
- stubs/default/config/initializers/active_record_encryption.rb
|
|
115
121
|
- stubs/default/config/routes.rb
|
|
116
122
|
- stubs/default/db/migrate/20240101000000_create_users.rb
|
|
123
|
+
- stubs/default/db/migrate/20240101000001_add_two_factor_to_users.rb
|
|
117
124
|
- stubs/default/test/factories/users.rb
|
|
118
125
|
- stubs/default/test/integration/appearance_test.rb
|
|
119
126
|
- stubs/default/test/integration/auth/authentication_test.rb
|
|
120
127
|
- stubs/default/test/integration/auth/email_verification_test.rb
|
|
121
128
|
- stubs/default/test/integration/auth/password_reset_test.rb
|
|
129
|
+
- stubs/default/test/integration/auth/rate_limiting_test.rb
|
|
122
130
|
- stubs/default/test/integration/auth/registration_test.rb
|
|
131
|
+
- stubs/default/test/integration/auth/two_factor_challenge_test.rb
|
|
123
132
|
- stubs/default/test/integration/password_update_test.rb
|
|
124
133
|
- stubs/default/test/integration/profile_test.rb
|
|
134
|
+
- stubs/default/test/integration/settings/two_factor_test.rb
|
|
135
|
+
- stubs/default/test/models/two_factor_authenticatable_test.rb
|
|
125
136
|
- stubs/default/test/test_helper.rb
|
|
126
137
|
- stubs/hotwire/app/assets/tailwind/application.css
|
|
127
138
|
- stubs/hotwire/app/components/application_logo_component.rb
|
|
@@ -148,16 +159,19 @@ files:
|
|
|
148
159
|
- stubs/hotwire/app/controllers/auth/new_password_controller.rb
|
|
149
160
|
- stubs/hotwire/app/controllers/auth/password_reset_link_controller.rb
|
|
150
161
|
- stubs/hotwire/app/controllers/auth/registered_user_controller.rb
|
|
162
|
+
- stubs/hotwire/app/controllers/auth/two_factor_challenge_controller.rb
|
|
151
163
|
- stubs/hotwire/app/controllers/auth/verified_email_controller.rb
|
|
152
164
|
- stubs/hotwire/app/controllers/concerns/authenticate.rb
|
|
153
165
|
- stubs/hotwire/app/controllers/concerns/redirect_if_authenticated.rb
|
|
154
166
|
- stubs/hotwire/app/controllers/concerns/set_current_auth.rb
|
|
167
|
+
- stubs/hotwire/app/controllers/concerns/set_two_factor_challenge.rb
|
|
155
168
|
- stubs/hotwire/app/controllers/concerns/sidebar_state.rb
|
|
156
169
|
- stubs/hotwire/app/controllers/concerns/validate_signature.rb
|
|
157
170
|
- stubs/hotwire/app/controllers/dashboard_controller.rb
|
|
158
171
|
- stubs/hotwire/app/controllers/settings/appearance_controller.rb
|
|
159
172
|
- stubs/hotwire/app/controllers/settings/password_controller.rb
|
|
160
173
|
- stubs/hotwire/app/controllers/settings/profile_controller.rb
|
|
174
|
+
- stubs/hotwire/app/controllers/settings/two_factor_controller.rb
|
|
161
175
|
- stubs/hotwire/app/controllers/welcome_controller.rb
|
|
162
176
|
- stubs/hotwire/app/javascript/alpinejs.stub
|
|
163
177
|
- stubs/hotwire/app/javascript/application.js
|
|
@@ -165,6 +179,7 @@ files:
|
|
|
165
179
|
- stubs/hotwire/app/views/auth/login.html.erb
|
|
166
180
|
- stubs/hotwire/app/views/auth/register.html.erb
|
|
167
181
|
- stubs/hotwire/app/views/auth/reset_password.html.erb
|
|
182
|
+
- stubs/hotwire/app/views/auth/two_factor_challenge.html.erb
|
|
168
183
|
- stubs/hotwire/app/views/auth/verify_email.html.erb
|
|
169
184
|
- stubs/hotwire/app/views/dashboard/index.html.erb
|
|
170
185
|
- stubs/hotwire/app/views/layouts/_appearance.html.erb
|
|
@@ -183,6 +198,10 @@ files:
|
|
|
183
198
|
- stubs/hotwire/app/views/settings/profile/_update_profile_information_form.html.erb
|
|
184
199
|
- stubs/hotwire/app/views/settings/profile/destroy.turbo_stream.erb
|
|
185
200
|
- stubs/hotwire/app/views/settings/profile/edit.html.erb
|
|
201
|
+
- stubs/hotwire/app/views/settings/two_factor/_confirming.html.erb
|
|
202
|
+
- stubs/hotwire/app/views/settings/two_factor/_disabled.html.erb
|
|
203
|
+
- stubs/hotwire/app/views/settings/two_factor/_enabled.html.erb
|
|
204
|
+
- stubs/hotwire/app/views/settings/two_factor/edit.html.erb
|
|
186
205
|
- stubs/hotwire/app/views/welcome/index.html.erb
|
|
187
206
|
- stubs/hotwire/config/importmap.rb
|
|
188
207
|
- stubs/inertia-common/app/controllers/application_controller.rb
|
|
@@ -191,17 +210,20 @@ files:
|
|
|
191
210
|
- stubs/inertia-common/app/controllers/auth/new_password_controller.rb
|
|
192
211
|
- stubs/inertia-common/app/controllers/auth/password_reset_link_controller.rb
|
|
193
212
|
- stubs/inertia-common/app/controllers/auth/registered_user_controller.rb
|
|
213
|
+
- stubs/inertia-common/app/controllers/auth/two_factor_challenge_controller.rb
|
|
194
214
|
- stubs/inertia-common/app/controllers/auth/verified_email_controller.rb
|
|
195
215
|
- stubs/inertia-common/app/controllers/concerns/authenticate.rb
|
|
196
216
|
- stubs/inertia-common/app/controllers/concerns/handle_inertia_requests.rb
|
|
197
217
|
- stubs/inertia-common/app/controllers/concerns/redirect_if_authenticated.rb
|
|
198
218
|
- stubs/inertia-common/app/controllers/concerns/set_current_auth.rb
|
|
219
|
+
- stubs/inertia-common/app/controllers/concerns/set_two_factor_challenge.rb
|
|
199
220
|
- stubs/inertia-common/app/controllers/concerns/validate_signature.rb
|
|
200
221
|
- stubs/inertia-common/app/controllers/concerns/verify_csrf_token.rb
|
|
201
222
|
- stubs/inertia-common/app/controllers/dashboard_controller.rb
|
|
202
223
|
- stubs/inertia-common/app/controllers/settings/appearance_controller.rb
|
|
203
224
|
- stubs/inertia-common/app/controllers/settings/password_controller.rb
|
|
204
225
|
- stubs/inertia-common/app/controllers/settings/profile_controller.rb
|
|
226
|
+
- stubs/inertia-common/app/controllers/settings/two_factor_controller.rb
|
|
205
227
|
- stubs/inertia-common/app/controllers/welcome_controller.rb
|
|
206
228
|
- stubs/inertia-common/bin/vite
|
|
207
229
|
- stubs/inertia-common/config/initializers/inertia_rails.rb
|
|
@@ -243,6 +265,7 @@ files:
|
|
|
243
265
|
- stubs/inertia-react-ts/app/javascript/Pages/Auth/Login.tsx
|
|
244
266
|
- stubs/inertia-react-ts/app/javascript/Pages/Auth/Register.tsx
|
|
245
267
|
- stubs/inertia-react-ts/app/javascript/Pages/Auth/ResetPassword.tsx
|
|
268
|
+
- stubs/inertia-react-ts/app/javascript/Pages/Auth/TwoFactorChallenge.tsx
|
|
246
269
|
- stubs/inertia-react-ts/app/javascript/Pages/Auth/VerifyEmail.tsx
|
|
247
270
|
- stubs/inertia-react-ts/app/javascript/Pages/Dashboard.tsx
|
|
248
271
|
- stubs/inertia-react-ts/app/javascript/Pages/Settings/Appearance.tsx
|
|
@@ -252,6 +275,7 @@ files:
|
|
|
252
275
|
- stubs/inertia-react-ts/app/javascript/Pages/Settings/Partials/UpdateProfileInformationForm.tsx
|
|
253
276
|
- stubs/inertia-react-ts/app/javascript/Pages/Settings/Password.tsx
|
|
254
277
|
- stubs/inertia-react-ts/app/javascript/Pages/Settings/Profile.tsx
|
|
278
|
+
- stubs/inertia-react-ts/app/javascript/Pages/Settings/TwoFactor.tsx
|
|
255
279
|
- stubs/inertia-react-ts/app/javascript/Pages/Welcome.tsx
|
|
256
280
|
- stubs/inertia-react-ts/app/javascript/entrypoints/application.tsx
|
|
257
281
|
- stubs/inertia-react-ts/app/javascript/entrypoints/bootstrap.ts
|
|
@@ -372,6 +396,7 @@ files:
|
|
|
372
396
|
- stubs/inertia-vue-ts/app/javascript/Pages/Auth/Login.vue
|
|
373
397
|
- stubs/inertia-vue-ts/app/javascript/Pages/Auth/Register.vue
|
|
374
398
|
- stubs/inertia-vue-ts/app/javascript/Pages/Auth/ResetPassword.vue
|
|
399
|
+
- stubs/inertia-vue-ts/app/javascript/Pages/Auth/TwoFactorChallenge.vue
|
|
375
400
|
- stubs/inertia-vue-ts/app/javascript/Pages/Auth/VerifyEmail.vue
|
|
376
401
|
- stubs/inertia-vue-ts/app/javascript/Pages/Dashboard.vue
|
|
377
402
|
- stubs/inertia-vue-ts/app/javascript/Pages/Settings/Appearance.vue
|
|
@@ -381,6 +406,7 @@ files:
|
|
|
381
406
|
- stubs/inertia-vue-ts/app/javascript/Pages/Settings/Partials/UpdateProfileInformationForm.vue
|
|
382
407
|
- stubs/inertia-vue-ts/app/javascript/Pages/Settings/Password.vue
|
|
383
408
|
- stubs/inertia-vue-ts/app/javascript/Pages/Settings/Profile.vue
|
|
409
|
+
- stubs/inertia-vue-ts/app/javascript/Pages/Settings/TwoFactor.vue
|
|
384
410
|
- stubs/inertia-vue-ts/app/javascript/Pages/Welcome.vue
|
|
385
411
|
- stubs/inertia-vue-ts/app/javascript/composables/useInitials.ts
|
|
386
412
|
- stubs/inertia-vue-ts/app/javascript/entrypoints/application.ts
|