@baseplate-dev/plugin-auth 0.6.15 → 0.6.17
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.
- package/CHANGELOG.md +36 -0
- package/dist/better-auth/admin/generators/admin-crud-manage-roles-action/admin-crud-manage-roles-action.generator.d.ts +14 -28
- package/dist/better-auth/admin/generators/admin-crud-manage-roles-action/generated/index.d.ts +14 -28
- package/dist/better-auth/admin/generators/admin-crud-manage-roles-action/generated/template-renderers.d.ts +7 -14
- package/dist/better-auth/admin/generators/admin-crud-manage-roles-action/generated/typed-templates.d.ts +7 -14
- package/dist/better-auth/admin/generators/admin-crud-reset-password-action/admin-crud-reset-password-action.generator.d.ts +14 -28
- package/dist/better-auth/admin/generators/admin-crud-reset-password-action/generated/index.d.ts +14 -28
- package/dist/better-auth/admin/generators/admin-crud-reset-password-action/generated/template-renderers.d.ts +7 -14
- package/dist/better-auth/admin/generators/admin-crud-reset-password-action/generated/typed-templates.d.ts +14 -28
- package/dist/better-auth/admin/generators/admin-crud-roles-column/admin-crud-roles-column.generator.d.ts +7 -14
- package/dist/better-auth/generators/fastify/better-auth-module/better-auth-module.generator.d.ts +9 -2
- package/dist/better-auth/generators/fastify/better-auth-module/better-auth-module.generator.js +6 -2
- package/dist/better-auth/generators/fastify/better-auth-module/generated/index.d.ts +16 -2
- package/dist/better-auth/generators/fastify/better-auth-module/generated/template-renderers.d.ts +8 -1
- package/dist/better-auth/generators/fastify/better-auth-module/generated/typed-templates.d.ts +8 -1
- package/dist/better-auth/generators/fastify/better-auth-module/templates/module/services/auth.ts +5 -1
- package/dist/better-auth/generators/react/better-auth-pages/better-auth-pages.generator.d.ts +7 -14
- package/dist/better-auth/generators/react/better-auth-pages/generated/index.d.ts +42 -84
- package/dist/better-auth/generators/react/better-auth-pages/generated/template-renderers.d.ts +7 -14
- package/dist/better-auth/generators/react/better-auth-pages/generated/typed-templates.d.ts +70 -140
- package/dist/better-auth/generators/react/react-better-auth/generated/index.d.ts +14 -28
- package/dist/better-auth/generators/react/react-better-auth/generated/template-renderers.d.ts +7 -14
- package/dist/better-auth/generators/react/react-better-auth/generated/typed-templates.d.ts +7 -14
- package/dist/better-auth/generators/react/react-better-auth/react-better-auth.generator.d.ts +7 -14
- package/dist/local-auth/admin/generators/admin-crud-manage-roles-action/admin-crud-manage-roles-action.generator.d.ts +14 -28
- package/dist/local-auth/admin/generators/admin-crud-manage-roles-action/generated/index.d.ts +14 -28
- package/dist/local-auth/admin/generators/admin-crud-manage-roles-action/generated/template-renderers.d.ts +7 -14
- package/dist/local-auth/admin/generators/admin-crud-manage-roles-action/generated/typed-templates.d.ts +7 -14
- package/dist/local-auth/admin/generators/admin-crud-reset-password-action/admin-crud-reset-password-action.generator.d.ts +14 -28
- package/dist/local-auth/admin/generators/admin-crud-reset-password-action/generated/index.d.ts +14 -28
- package/dist/local-auth/admin/generators/admin-crud-reset-password-action/generated/template-renderers.d.ts +7 -14
- package/dist/local-auth/admin/generators/admin-crud-reset-password-action/generated/typed-templates.d.ts +14 -28
- package/dist/local-auth/admin/generators/admin-crud-roles-column/admin-crud-roles-column.generator.d.ts +7 -14
- package/dist/local-auth/core/generators/auth-apollo/auth-apollo.generator.d.ts +1 -0
- package/dist/local-auth/core/generators/auth-email-password/auth-email-password.generator.d.ts +2 -1
- package/dist/local-auth/core/generators/auth-email-password/generated/index.d.ts +6 -3
- package/dist/local-auth/core/generators/auth-email-password/generated/template-renderers.d.ts +2 -1
- package/dist/local-auth/core/generators/auth-email-password/generated/typed-templates.d.ts +6 -3
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/email-verification.service.js +2 -2
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/email-verification.service.ts +2 -2
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/password-reset.service.js +2 -2
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/password-reset.service.ts +2 -2
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/user-password.service.js +6 -3
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/user-password.service.ts +6 -3
- package/dist/local-auth/core/generators/auth-module/auth-module.generator.d.ts +7 -2
- package/dist/local-auth/core/generators/auth-module/auth-module.generator.js +3 -1
- package/dist/local-auth/core/generators/auth-module/generated/index.d.ts +18 -3
- package/dist/local-auth/core/generators/auth-module/generated/template-renderers.d.ts +6 -1
- package/dist/local-auth/core/generators/auth-module/generated/typed-templates.d.ts +14 -3
- package/dist/local-auth/core/generators/auth-module/templates/module/services/user-session.service.js +18 -16
- package/dist/local-auth/core/generators/auth-module/templates/module/services/user-session.service.ts +18 -16
- package/dist/local-auth/core/generators/auth-module/templates/module/utils/session-cookie.js +6 -6
- package/dist/local-auth/core/generators/auth-module/templates/module/utils/session-cookie.ts +6 -6
- package/dist/local-auth/core/generators/auth-routes/auth-routes.generator.d.ts +7 -14
- package/dist/local-auth/core/generators/auth-routes/generated/index.d.ts +42 -84
- package/dist/local-auth/core/generators/auth-routes/generated/template-renderers.d.ts +7 -14
- package/dist/local-auth/core/generators/auth-routes/generated/typed-templates.d.ts +63 -126
- package/dist/local-auth/core/generators/react-session/generated/index.d.ts +14 -28
- package/dist/local-auth/core/generators/react-session/generated/template-renderers.d.ts +7 -14
- package/dist/local-auth/core/generators/react-session/generated/typed-templates.d.ts +14 -28
- package/dist/local-auth/core/generators/react-session/react-session.generator.d.ts +7 -14
- package/dist/placeholder-auth/core/generators/placeholder-auth-module/placeholder-auth-module.generator.d.ts +1 -1
- package/dist/placeholder-auth/core/generators/placeholder-auth-module/placeholder-auth-module.generator.js +3 -1
- package/dist/web/assets/{_virtual_mf-localSharedImportMap___mfe_internal__plugin_mf_2_auth-D2O_GHnM.js → _virtual_mf-localSharedImportMap___mfe_internal__plugin_mf_2_auth-ChkXxpXe.js} +24 -24
- package/dist/web/assets/{_virtual_mf___mfe_internal__plugin_mf_2_auth__loadShare___mf_0_baseplate_mf_2_dev_mf_1_project_mf_2_builder_mf_2_lib__loadShare__.js-DPxqayXr.js → _virtual_mf___mfe_internal__plugin_mf_2_auth__loadShare___mf_0_baseplate_mf_2_dev_mf_1_project_mf_2_builder_mf_2_lib__loadShare__.js-CO5Pvo0y.js} +6 -5
- package/dist/web/assets/{_virtual_mf___mfe_internal__plugin_mf_2_auth__loadShare___mf_0_baseplate_mf_2_dev_mf_1_project_mf_2_builder_mf_2_lib_mf_1_web__loadShare__.js-DGL7vJhO.js → _virtual_mf___mfe_internal__plugin_mf_2_auth__loadShare___mf_0_baseplate_mf_2_dev_mf_1_project_mf_2_builder_mf_2_lib_mf_1_web__loadShare__.js-37vlYRxk.js} +2 -2
- package/dist/web/assets/{_virtual_mf___mfe_internal__plugin_mf_2_auth__loadShare___mf_0_baseplate_mf_2_dev_mf_1_ui_mf_2_components__loadShare__.js-IL2CfUDN.js → _virtual_mf___mfe_internal__plugin_mf_2_auth__loadShare___mf_0_baseplate_mf_2_dev_mf_1_ui_mf_2_components__loadShare__.js-DRSNXPPo.js} +11120 -4828
- package/dist/web/assets/{_virtual_mf___mfe_internal__plugin_mf_2_auth__loadShare___mf_0_tanstack_mf_1_react_mf_2_router__loadShare__.js-olZgW088.js → _virtual_mf___mfe_internal__plugin_mf_2_auth__loadShare___mf_0_tanstack_mf_1_react_mf_2_router__loadShare__.js-DfiQqvVC.js} +4179 -2900
- package/dist/web/assets/{_virtual_mf___mfe_internal__plugin_mf_2_auth__loadShare__zod__loadShare__.js-Do-7VDVw.js → _virtual_mf___mfe_internal__plugin_mf_2_auth__loadShare__zod__loadShare__.js-BEZ7A-cz.js} +2 -3
- package/dist/web/assets/arduino-BXtgMpyb.js +21 -0
- package/dist/web/assets/auth-BxAE0rgh.js +1 -0
- package/dist/web/assets/bash-Zh_IyzBN.js +192 -0
- package/dist/web/assets/basic-3mvohyEL.js +28 -0
- package/dist/web/assets/c-6gdx-Hqg.js +74 -0
- package/dist/web/assets/clike-Ds9lUsCq.js +41 -0
- package/dist/web/assets/{common-2qsch56z.js → common-ByxS61u8.js} +8 -6
- package/dist/web/assets/{common-D-CUPN3f.js → common-CKl_XlvH.js} +3 -3
- package/dist/web/assets/{common-BJslFOaI.js → common-TDf_PrjX.js} +3 -3
- package/dist/web/assets/{common-2sTWj7X2.js → common-UpVCKZeW.js} +8 -6
- package/dist/web/assets/{common-DtVPzGI9.js → common-crSwCD36.js} +3 -3
- package/dist/web/assets/{common-BY8yEk1M.js → common-iHaemino.js} +3 -3
- package/dist/web/assets/cpp-DRYAY5P6.js +82 -0
- package/dist/web/assets/csharp-RJBSoHJ6.js +301 -0
- package/dist/web/assets/css-D7TbgetL.js +70 -0
- package/dist/web/assets/diff-CtSa_15w.js +54 -0
- package/dist/web/assets/{dist-SBfmsOB2.js → dist-CrLSslv6.js} +2 -2
- package/dist/web/assets/{dist-DiQ4J8N0.js → dist-DY7ZXvq4.js} +1408 -916
- package/dist/web/assets/{get-auth-plugin-definition-gCzcUybB.js → get-auth-plugin-definition-kDCtXq_6.js} +2 -2
- package/dist/web/assets/go-D9nlw8GJ.js +36 -0
- package/dist/web/assets/{hostInit-BPDI3Q4j.js → hostInit-Cruek6c6.js} +2 -2
- package/dist/web/assets/ini-CU-wHLTy.js +51 -0
- package/dist/web/assets/java-Asfw0WtJ.js +116 -0
- package/dist/web/assets/javascript-fpnGEVws.js +124 -0
- package/dist/web/assets/json-DN8T4yFI.js +38 -0
- package/dist/web/assets/kotlin-zNWfDPVY.js +83 -0
- package/dist/web/assets/less-ZXX1tgaG.js +42 -0
- package/dist/web/assets/lua-D9bD4wrb.js +28 -0
- package/dist/web/assets/makefile-CKoRpler.js +40 -0
- package/dist/web/assets/markdown-ewV-vLcZ.js +278 -0
- package/dist/web/assets/markup-D2krQlDZ.js +176 -0
- package/dist/web/assets/markup-templating-c_XBo6vX.js +94 -0
- package/dist/web/assets/mf-entry-bootstrap-0-dfed0275.js +35 -0
- package/dist/web/assets/mf-entry-bootstrap-1-5275674a.js +35 -0
- package/dist/web/assets/{mf-entry-bootstrap-0-b337c957.js → mf-entry-bootstrap-2-39fb9255.js} +2 -2
- package/dist/web/assets/mf-entry-bootstrap-3-49e64336.js +35 -0
- package/dist/web/assets/{model-utils-BoeoBppL.js → model-utils-C0WDb_Ec.js} +269 -26
- package/dist/web/assets/{models-Bb8Sa9xa.js → models-BZmCbizK.js} +3 -3
- package/dist/web/assets/{models-CExR9mVk.js → models-DSvs_3bA.js} +3 -3
- package/dist/web/assets/objectivec-PkUOhxeb.js +25 -0
- package/dist/web/assets/perl-Cul_ma_h.js +92 -0
- package/dist/web/assets/php-CfWLJZIj.js +298 -0
- package/dist/web/assets/{plugin-definition-BSgRuyCf.js → plugin-definition-CYj29S3q.js} +3 -3
- package/dist/web/assets/{plugin-definition-DoLu-enC.js → plugin-definition-DOMmPL2Z.js} +3 -3
- package/dist/web/assets/python-CURlmZ7M.js +73 -0
- package/dist/web/assets/r-8lr7pbGm.js +30 -0
- package/dist/web/assets/regex-CxQ7DXCx.js +96 -0
- package/dist/web/assets/{rolldown-runtime-FZ4Itg2g.js → rolldown-runtime-7_rZTKki.js} +1 -1
- package/dist/web/assets/ruby-BlM93DKO.js +175 -0
- package/dist/web/assets/rust-CpZXpaj0.js +107 -0
- package/dist/web/assets/sass-DG0YAnL7.js +65 -0
- package/dist/web/assets/scss-BDRIqhak.js +70 -0
- package/dist/web/assets/sql-C-bL8_gT.js +40 -0
- package/dist/web/assets/{styles-Cc26Bbxc.css → styles-DIj1cIPB.css} +119 -1
- package/dist/web/assets/{styles-DWNihayS.js → styles-yjbHBTlw.js} +8 -8
- package/dist/web/assets/swift-rQ52kfab.js +107 -0
- package/dist/web/assets/typescript-C5BVqltI.js +57 -0
- package/dist/web/assets/vbnet-_PL7-T9d.js +32 -0
- package/dist/web/assets/{virtualExposes-ZQ3-2Iup.js → virtualExposes-CbPBmicF.js} +1 -1
- package/dist/web/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__plugin-auth__remoteEntry_js-joyeTHHj.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__plugin-auth__remoteEntry_js-XM6iYVxf.js} +5 -5
- package/dist/web/assets/{virtual_mf-exposes-ssr___mfe_internal__plugin-auth__remoteEntry_js-Cxtxsg7w.js → virtual_mf-exposes-ssr___mfe_internal__plugin-auth__remoteEntry_js-DGjg7Brm.js} +15 -15
- package/dist/web/assets/{virtual_mf-exposes___mfe_internal__plugin-auth__remoteEntry_js-BzJkYZS3.js → virtual_mf-exposes___mfe_internal__plugin-auth__remoteEntry_js-B6BXIeF1.js} +15 -15
- package/dist/web/assets/{vite-preload-helper-iIio8xkS.js → vite-preload-helper-ARKYL6bp.js} +5 -1
- package/dist/web/assets/{web-pdVFZ-id.js → web-1eTcxMhf.js} +3 -3
- package/dist/web/assets/{web-sVeHdqQo.js → web-CDAKPPK9.js} +13 -13
- package/dist/web/assets/{web-CbftiK5A.js → web-CXAHKjIY.js} +19 -19
- package/dist/web/assets/{web-DUQ-iyMI.js → web-D0MSKfyv.js} +31 -30
- package/dist/web/assets/{web-BbZNg5Ko.js → web-DbeAaDTV.js} +16 -16
- package/dist/web/assets/{web-QvGnMr85.js → web-VqBA3jxZ.js} +13 -13
- package/dist/web/assets/{web-BWF6Fc7g.js → web-miDovYk_.js} +3 -3
- package/dist/web/assets/workerBundle-BjsY-uXx.js +10 -0
- package/dist/web/assets/yaml-C9m3vuV5.js +90 -0
- package/dist/web/index.html +5 -2
- package/dist/web/remoteEntry.js +1 -1
- package/dist/web/remoteEntry.ssr.js +2 -2
- package/package.json +38 -41
- package/dist/web/assets/auth-BA-e6ORB.js +0 -1
- package/dist/web/assets/index-BocHdii2.js +0 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
import { EMAIL_VERIFICATION_TOKEN_EXPIRY_SEC } from '$constantsPassword';
|
|
3
3
|
import { createAuthVerification, validateAuthVerification, } from '%authModuleImports';
|
|
4
|
-
import {
|
|
4
|
+
import { getConfig } from '%configServiceImports';
|
|
5
5
|
import { BadRequestError } from '%errorHandlerServiceImports';
|
|
6
6
|
import { prisma } from '%prismaImports';
|
|
7
7
|
import { memoizeRateLimiter } from '%rateLimitImports';
|
|
@@ -50,7 +50,7 @@ export async function requestEmailVerification({ userId, context, }) {
|
|
|
50
50
|
expiresInSec: EMAIL_VERIFICATION_TOKEN_EXPIRY_SEC,
|
|
51
51
|
});
|
|
52
52
|
// Construct verification URL using configured domain
|
|
53
|
-
const verifyLink = `${
|
|
53
|
+
const verifyLink = `${getConfig().AUTH_FRONTEND_URL}/auth/verify-email?token=${encodeURIComponent(token)}`;
|
|
54
54
|
await services.email.send(TPL_ACCOUNT_VERIFICATION_EMAIL, {
|
|
55
55
|
to: user.email,
|
|
56
56
|
data: { verifyLink },
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
createAuthVerification,
|
|
11
11
|
validateAuthVerification,
|
|
12
12
|
} from '%authModuleImports';
|
|
13
|
-
import {
|
|
13
|
+
import { getConfig } from '%configServiceImports';
|
|
14
14
|
import { BadRequestError } from '%errorHandlerServiceImports';
|
|
15
15
|
import { prisma } from '%prismaImports';
|
|
16
16
|
import { memoizeRateLimiter } from '%rateLimitImports';
|
|
@@ -91,7 +91,7 @@ export async function requestEmailVerification({
|
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
// Construct verification URL using configured domain
|
|
94
|
-
const verifyLink = `${
|
|
94
|
+
const verifyLink = `${getConfig().AUTH_FRONTEND_URL}/auth/verify-email?token=${encodeURIComponent(token)}`;
|
|
95
95
|
|
|
96
96
|
await services.email.send(TPL_ACCOUNT_VERIFICATION_EMAIL, {
|
|
97
97
|
to: user.email,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { PASSWORD_MAX_LENGTH, PASSWORD_MIN_LENGTH, PASSWORD_RESET_TOKEN_EXPIRY_SEC, } from '$constantsPassword';
|
|
3
3
|
import { resetLoginRateLimits } from '$servicesUserPassword';
|
|
4
4
|
import { createAuthVerification, validateAuthVerification, } from '%authModuleImports';
|
|
5
|
-
import {
|
|
5
|
+
import { getConfig } from '%configServiceImports';
|
|
6
6
|
import { BadRequestError, handleZodRequestValidationError, } from '%errorHandlerServiceImports';
|
|
7
7
|
import { createPasswordHash } from '%passwordHasherServiceImports';
|
|
8
8
|
import { prisma } from '%prismaImports';
|
|
@@ -59,7 +59,7 @@ export async function requestPasswordReset({ email: rawEmail, context, }) {
|
|
|
59
59
|
expiresInSec: PASSWORD_RESET_TOKEN_EXPIRY_SEC,
|
|
60
60
|
});
|
|
61
61
|
// Construct reset URL using configured domain
|
|
62
|
-
const resetLink = `${
|
|
62
|
+
const resetLink = `${getConfig().AUTH_FRONTEND_URL}/auth/reset-password?token=${encodeURIComponent(token)}`;
|
|
63
63
|
// Send email asynchronously (queue-based)
|
|
64
64
|
await services.email.send(TPL_PASSWORD_RESET_EMAIL, {
|
|
65
65
|
to: user.email,
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
createAuthVerification,
|
|
13
13
|
validateAuthVerification,
|
|
14
14
|
} from '%authModuleImports';
|
|
15
|
-
import {
|
|
15
|
+
import { getConfig } from '%configServiceImports';
|
|
16
16
|
import {
|
|
17
17
|
BadRequestError,
|
|
18
18
|
handleZodRequestValidationError,
|
|
@@ -108,7 +108,7 @@ export async function requestPasswordReset({
|
|
|
108
108
|
});
|
|
109
109
|
|
|
110
110
|
// Construct reset URL using configured domain
|
|
111
|
-
const resetLink = `${
|
|
111
|
+
const resetLink = `${getConfig().AUTH_FRONTEND_URL}/auth/reset-password?token=${encodeURIComponent(token)}`;
|
|
112
112
|
|
|
113
113
|
// Send email asynchronously (queue-based)
|
|
114
114
|
await services.email.send(TPL_PASSWORD_RESET_EMAIL, {
|
|
@@ -94,8 +94,8 @@ export async function authenticateUserWithEmailAndPassword({ input, context, })
|
|
|
94
94
|
const clientIp = context.reqInfo.ip;
|
|
95
95
|
const emailIpKey = `${email}_${clientIp}`;
|
|
96
96
|
// Check IP-based rate limit (slow brute force protection)
|
|
97
|
-
const ipResult = await getLoginIpLimiter().
|
|
98
|
-
if (!ipResult.allowed) {
|
|
97
|
+
const ipResult = await getLoginIpLimiter().get(clientIp);
|
|
98
|
+
if (ipResult && !ipResult.allowed) {
|
|
99
99
|
throw new TooManyRequestsError('Too many login attempts. Please try again later or reset your password.', 'login-ip-rate-limited', { retryAfterMs: ipResult.msBeforeNext });
|
|
100
100
|
}
|
|
101
101
|
// Check consecutive failures rate limit (fast brute force protection)
|
|
@@ -116,7 +116,10 @@ export async function authenticateUserWithEmailAndPassword({ input, context, })
|
|
|
116
116
|
const isValid = await verifyPasswordHash(userAccount?.password, password);
|
|
117
117
|
if (!isValid || !userAccount) {
|
|
118
118
|
// Track failed attempt
|
|
119
|
-
await
|
|
119
|
+
await Promise.all([
|
|
120
|
+
getLoginIpLimiter().consume(clientIp),
|
|
121
|
+
getLoginConsecutiveFailsLimiter().consume(emailIpKey),
|
|
122
|
+
]);
|
|
120
123
|
throw new BadRequestError('Invalid email or password', 'invalid-credentials');
|
|
121
124
|
}
|
|
122
125
|
// Reset consecutive failures on successful login
|
|
@@ -169,8 +169,8 @@ export async function authenticateUserWithEmailAndPassword({
|
|
|
169
169
|
const emailIpKey = `${email}_${clientIp}`;
|
|
170
170
|
|
|
171
171
|
// Check IP-based rate limit (slow brute force protection)
|
|
172
|
-
const ipResult = await getLoginIpLimiter().
|
|
173
|
-
if (!ipResult.allowed) {
|
|
172
|
+
const ipResult = await getLoginIpLimiter().get(clientIp);
|
|
173
|
+
if (ipResult && !ipResult.allowed) {
|
|
174
174
|
throw new TooManyRequestsError(
|
|
175
175
|
'Too many login attempts. Please try again later or reset your password.',
|
|
176
176
|
'login-ip-rate-limited',
|
|
@@ -204,7 +204,10 @@ export async function authenticateUserWithEmailAndPassword({
|
|
|
204
204
|
const isValid = await verifyPasswordHash(userAccount?.password, password);
|
|
205
205
|
if (!isValid || !userAccount) {
|
|
206
206
|
// Track failed attempt
|
|
207
|
-
await
|
|
207
|
+
await Promise.all([
|
|
208
|
+
getLoginIpLimiter().consume(clientIp),
|
|
209
|
+
getLoginConsecutiveFailsLimiter().consume(emailIpKey),
|
|
210
|
+
]);
|
|
208
211
|
throw new BadRequestError(
|
|
209
212
|
'Invalid email or password',
|
|
210
213
|
'invalid-credentials',
|
|
@@ -50,7 +50,8 @@ export declare const authModuleGenerator: import("@baseplate-dev/sync").Generato
|
|
|
50
50
|
};
|
|
51
51
|
}>>;
|
|
52
52
|
configServiceImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
53
|
-
|
|
53
|
+
getConfig: {};
|
|
54
|
+
isDevelopment: {};
|
|
54
55
|
}>>;
|
|
55
56
|
errorHandlerServiceImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
56
57
|
BadRequestError: {};
|
|
@@ -84,6 +85,10 @@ export declare const authModuleGenerator: import("@baseplate-dev/sync").Generato
|
|
|
84
85
|
EnqueueOptions: {
|
|
85
86
|
isTypeOnly: true;
|
|
86
87
|
};
|
|
88
|
+
hasFinalAttemptFailureHandler: {};
|
|
89
|
+
QueueFinalAttemptFailureHandler: {
|
|
90
|
+
isTypeOnly: true;
|
|
91
|
+
};
|
|
87
92
|
QueueHandlerBinding: {
|
|
88
93
|
isTypeOnly: true;
|
|
89
94
|
};
|
|
@@ -167,7 +172,7 @@ export declare const authModuleGenerator: import("@baseplate-dev/sync").Generato
|
|
|
167
172
|
}, any>;
|
|
168
173
|
appRuntimeConfig: import("@baseplate-dev/sync").GeneratorTask<any, {
|
|
169
174
|
appRuntimeConfig: import("@baseplate-dev/sync").ProviderType<Omit<import("@baseplate-dev/utils").FieldMap<{
|
|
170
|
-
services: import("@baseplate-dev/utils").MapContainer<string, import("@baseplate-dev/
|
|
175
|
+
services: import("@baseplate-dev/utils").MapContainer<string, import("@baseplate-dev/fastify-generators").AppRuntimeServiceEntry>;
|
|
171
176
|
construction: import("@baseplate-dev/utils").MapContainer<string, import("@baseplate-dev/fastify-generators").AppRuntimeConstructionEntry>;
|
|
172
177
|
flattenedModuleFields: import("@baseplate-dev/utils").MapContainer<string, string>;
|
|
173
178
|
usesBackgroundServices: import("@baseplate-dev/utils").ScalarContainer<boolean | undefined>;
|
|
@@ -102,7 +102,9 @@ export const authModuleGenerator = createGenerator({
|
|
|
102
102
|
paths: GENERATED_TEMPLATES.paths.provider,
|
|
103
103
|
},
|
|
104
104
|
run({ appRuntimeConfig, paths }) {
|
|
105
|
-
appRuntimeConfig.services.set('userSession',
|
|
105
|
+
appRuntimeConfig.services.set('userSession', {
|
|
106
|
+
type: tsCodeFragment('CookieUserSessionService', tsTypeImportBuilder(['CookieUserSessionService']).from(paths.userSessionService)),
|
|
107
|
+
});
|
|
106
108
|
appRuntimeConfig.construction.set('userSession', {
|
|
107
109
|
fragment: TsCodeUtils.template `new ${TsCodeUtils.importFragment('CookieUserSessionService', paths.userSessionService)}()`,
|
|
108
110
|
});
|
|
@@ -54,7 +54,8 @@ export declare const LOCAL_AUTH_CORE_AUTH_MODULE_GENERATED: {
|
|
|
54
54
|
};
|
|
55
55
|
}>>;
|
|
56
56
|
configServiceImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
57
|
-
|
|
57
|
+
getConfig: {};
|
|
58
|
+
isDevelopment: {};
|
|
58
59
|
}>>;
|
|
59
60
|
errorHandlerServiceImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
60
61
|
BadRequestError: {};
|
|
@@ -88,6 +89,10 @@ export declare const LOCAL_AUTH_CORE_AUTH_MODULE_GENERATED: {
|
|
|
88
89
|
EnqueueOptions: {
|
|
89
90
|
isTypeOnly: true;
|
|
90
91
|
};
|
|
92
|
+
hasFinalAttemptFailureHandler: {};
|
|
93
|
+
QueueFinalAttemptFailureHandler: {
|
|
94
|
+
isTypeOnly: true;
|
|
95
|
+
};
|
|
91
96
|
QueueHandlerBinding: {
|
|
92
97
|
isTypeOnly: true;
|
|
93
98
|
};
|
|
@@ -255,6 +260,10 @@ export declare const LOCAL_AUTH_CORE_AUTH_MODULE_GENERATED: {
|
|
|
255
260
|
EnqueueOptions: {
|
|
256
261
|
isTypeOnly: true;
|
|
257
262
|
};
|
|
263
|
+
hasFinalAttemptFailureHandler: {};
|
|
264
|
+
QueueFinalAttemptFailureHandler: {
|
|
265
|
+
isTypeOnly: true;
|
|
266
|
+
};
|
|
258
267
|
QueueHandlerBinding: {
|
|
259
268
|
isTypeOnly: true;
|
|
260
269
|
};
|
|
@@ -310,6 +319,10 @@ export declare const LOCAL_AUTH_CORE_AUTH_MODULE_GENERATED: {
|
|
|
310
319
|
EnqueueOptions: {
|
|
311
320
|
isTypeOnly: true;
|
|
312
321
|
};
|
|
322
|
+
hasFinalAttemptFailureHandler: {};
|
|
323
|
+
QueueFinalAttemptFailureHandler: {
|
|
324
|
+
isTypeOnly: true;
|
|
325
|
+
};
|
|
313
326
|
QueueHandlerBinding: {
|
|
314
327
|
isTypeOnly: true;
|
|
315
328
|
};
|
|
@@ -401,7 +414,8 @@ export declare const LOCAL_AUTH_CORE_AUTH_MODULE_GENERATED: {
|
|
|
401
414
|
};
|
|
402
415
|
}>>;
|
|
403
416
|
configServiceImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
404
|
-
|
|
417
|
+
getConfig: {};
|
|
418
|
+
isDevelopment: {};
|
|
405
419
|
}>>;
|
|
406
420
|
errorHandlerServiceImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
407
421
|
BadRequestError: {};
|
|
@@ -445,7 +459,8 @@ export declare const LOCAL_AUTH_CORE_AUTH_MODULE_GENERATED: {
|
|
|
445
459
|
cookieSigner: import("@baseplate-dev/core-generators").TsTemplateFile<{}, {}, Record<never, Record<never, never>>>;
|
|
446
460
|
sessionCookie: import("@baseplate-dev/core-generators").TsTemplateFile<{}, {
|
|
447
461
|
configServiceImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
448
|
-
|
|
462
|
+
getConfig: {};
|
|
463
|
+
isDevelopment: {};
|
|
449
464
|
}>>;
|
|
450
465
|
}, Record<never, Record<never, never>>>;
|
|
451
466
|
verifyRequestOrigin: import("@baseplate-dev/core-generators").TsTemplateFile<{}, {}, Record<never, Record<never, never>>>;
|
|
@@ -56,7 +56,8 @@ export declare const LOCAL_AUTH_CORE_AUTH_MODULE_RENDERERS: {
|
|
|
56
56
|
};
|
|
57
57
|
}>>;
|
|
58
58
|
configServiceImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
59
|
-
|
|
59
|
+
getConfig: {};
|
|
60
|
+
isDevelopment: {};
|
|
60
61
|
}>>;
|
|
61
62
|
errorHandlerServiceImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
62
63
|
BadRequestError: {};
|
|
@@ -90,6 +91,10 @@ export declare const LOCAL_AUTH_CORE_AUTH_MODULE_RENDERERS: {
|
|
|
90
91
|
EnqueueOptions: {
|
|
91
92
|
isTypeOnly: true;
|
|
92
93
|
};
|
|
94
|
+
hasFinalAttemptFailureHandler: {};
|
|
95
|
+
QueueFinalAttemptFailureHandler: {
|
|
96
|
+
isTypeOnly: true;
|
|
97
|
+
};
|
|
93
98
|
QueueHandlerBinding: {
|
|
94
99
|
isTypeOnly: true;
|
|
95
100
|
};
|
|
@@ -94,7 +94,8 @@ export declare const utilsGroup: {
|
|
|
94
94
|
cookieSigner: import("@baseplate-dev/core-generators").TsTemplateFile<{}, {}, Record<never, Record<never, never>>>;
|
|
95
95
|
sessionCookie: import("@baseplate-dev/core-generators").TsTemplateFile<{}, {
|
|
96
96
|
configServiceImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
97
|
-
|
|
97
|
+
getConfig: {};
|
|
98
|
+
isDevelopment: {};
|
|
98
99
|
}>>;
|
|
99
100
|
}, Record<never, Record<never, never>>>;
|
|
100
101
|
verifyRequestOrigin: import("@baseplate-dev/core-generators").TsTemplateFile<{}, {}, Record<never, Record<never, never>>>;
|
|
@@ -200,6 +201,10 @@ export declare const LOCAL_AUTH_CORE_AUTH_MODULE_TEMPLATES: {
|
|
|
200
201
|
EnqueueOptions: {
|
|
201
202
|
isTypeOnly: true;
|
|
202
203
|
};
|
|
204
|
+
hasFinalAttemptFailureHandler: {};
|
|
205
|
+
QueueFinalAttemptFailureHandler: {
|
|
206
|
+
isTypeOnly: true;
|
|
207
|
+
};
|
|
203
208
|
QueueHandlerBinding: {
|
|
204
209
|
isTypeOnly: true;
|
|
205
210
|
};
|
|
@@ -255,6 +260,10 @@ export declare const LOCAL_AUTH_CORE_AUTH_MODULE_TEMPLATES: {
|
|
|
255
260
|
EnqueueOptions: {
|
|
256
261
|
isTypeOnly: true;
|
|
257
262
|
};
|
|
263
|
+
hasFinalAttemptFailureHandler: {};
|
|
264
|
+
QueueFinalAttemptFailureHandler: {
|
|
265
|
+
isTypeOnly: true;
|
|
266
|
+
};
|
|
258
267
|
QueueHandlerBinding: {
|
|
259
268
|
isTypeOnly: true;
|
|
260
269
|
};
|
|
@@ -346,7 +355,8 @@ export declare const LOCAL_AUTH_CORE_AUTH_MODULE_TEMPLATES: {
|
|
|
346
355
|
};
|
|
347
356
|
}>>;
|
|
348
357
|
configServiceImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
349
|
-
|
|
358
|
+
getConfig: {};
|
|
359
|
+
isDevelopment: {};
|
|
350
360
|
}>>;
|
|
351
361
|
errorHandlerServiceImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
352
362
|
BadRequestError: {};
|
|
@@ -390,7 +400,8 @@ export declare const LOCAL_AUTH_CORE_AUTH_MODULE_TEMPLATES: {
|
|
|
390
400
|
cookieSigner: import("@baseplate-dev/core-generators").TsTemplateFile<{}, {}, Record<never, Record<never, never>>>;
|
|
391
401
|
sessionCookie: import("@baseplate-dev/core-generators").TsTemplateFile<{}, {
|
|
392
402
|
configServiceImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
393
|
-
|
|
403
|
+
getConfig: {};
|
|
404
|
+
isDevelopment: {};
|
|
394
405
|
}>>;
|
|
395
406
|
}, Record<never, Record<never, never>>>;
|
|
396
407
|
verifyRequestOrigin: import("@baseplate-dev/core-generators").TsTemplateFile<{}, {}, Record<never, Record<never, never>>>;
|
|
@@ -5,17 +5,19 @@ import { USER_SESSION_DURATION_SEC, USER_SESSION_MAX_LIFETIME_SEC, USER_SESSION_
|
|
|
5
5
|
import { verifyRequestOrigin } from '$verifyRequestOrigin';
|
|
6
6
|
import { InvalidSessionError } from '%authContextImports';
|
|
7
7
|
import { DEFAULT_USER_ROLES } from '%authRolesImports';
|
|
8
|
-
import {
|
|
8
|
+
import { getConfig, isDevelopment } from '%configServiceImports';
|
|
9
9
|
import { ForbiddenError } from '%errorHandlerServiceImports';
|
|
10
10
|
import { prisma } from '%prismaImports';
|
|
11
11
|
import { randomBytes } from 'node:crypto';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
function getCookieOptions() {
|
|
13
|
+
return {
|
|
14
|
+
httpOnly: true,
|
|
15
|
+
sameSite: 'lax',
|
|
16
|
+
secure: !isDevelopment(),
|
|
17
|
+
maxAge: USER_SESSION_DURATION_SEC,
|
|
18
|
+
path: '/',
|
|
19
|
+
};
|
|
20
|
+
}
|
|
19
21
|
/**
|
|
20
22
|
* Validates the expiry of a user session and determines if it needs to be renewed.
|
|
21
23
|
*
|
|
@@ -83,8 +85,8 @@ export class CookieUserSessionService {
|
|
|
83
85
|
...user.roles.map((role) => role.role),
|
|
84
86
|
];
|
|
85
87
|
const cookieName = getUserSessionCookieName(context.reqInfo.headers);
|
|
86
|
-
const cookieValue = signObject({ token },
|
|
87
|
-
context.cookieStore.set(cookieName, cookieValue,
|
|
88
|
+
const cookieValue = signObject({ token }, getConfig().AUTH_SECRET);
|
|
89
|
+
context.cookieStore.set(cookieName, cookieValue, getCookieOptions());
|
|
88
90
|
return { userId, expiresAt, roles };
|
|
89
91
|
}
|
|
90
92
|
/**
|
|
@@ -98,7 +100,7 @@ export class CookieUserSessionService {
|
|
|
98
100
|
where: { id: sessionInfo.id },
|
|
99
101
|
});
|
|
100
102
|
const cookieName = getUserSessionCookieName(context.reqInfo.headers);
|
|
101
|
-
context.cookieStore.clear(cookieName,
|
|
103
|
+
context.cookieStore.clear(cookieName, getCookieOptions());
|
|
102
104
|
}
|
|
103
105
|
/**
|
|
104
106
|
* Retrieves the user session information from the request.
|
|
@@ -120,12 +122,12 @@ export class CookieUserSessionService {
|
|
|
120
122
|
if ((req.method !== 'GET' ||
|
|
121
123
|
req.headers.upgrade?.toLowerCase() === 'websocket') &&
|
|
122
124
|
req.method !== 'HEAD' &&
|
|
123
|
-
!verifyRequestOrigin(req, [req.host, ...
|
|
125
|
+
!verifyRequestOrigin(req, [req.host, ...getConfig().ALLOWED_ORIGINS])) {
|
|
124
126
|
throw new ForbiddenError('Invalid Origin header');
|
|
125
127
|
}
|
|
126
128
|
try {
|
|
127
129
|
// Unsign the session cookie
|
|
128
|
-
const sessionCookieResult = unsignObject(sessionCookieValue,
|
|
130
|
+
const sessionCookieResult = unsignObject(sessionCookieValue, getConfig().AUTH_SECRET);
|
|
129
131
|
if (!sessionCookieResult)
|
|
130
132
|
throw new InvalidSessionError();
|
|
131
133
|
const { token } = sessionCookieResult;
|
|
@@ -150,8 +152,8 @@ export class CookieUserSessionService {
|
|
|
150
152
|
expiresAt: sessionExpiryResult.newExpiry,
|
|
151
153
|
},
|
|
152
154
|
});
|
|
153
|
-
const newSignedCookie = signObject({ token },
|
|
154
|
-
reply.setCookie(cookieName, newSignedCookie,
|
|
155
|
+
const newSignedCookie = signObject({ token }, getConfig().AUTH_SECRET);
|
|
156
|
+
reply.setCookie(cookieName, newSignedCookie, getCookieOptions());
|
|
155
157
|
}
|
|
156
158
|
const { user } = userSession;
|
|
157
159
|
const expiresAt = sessionExpiryResult.newExpiry ?? userSession.expiresAt;
|
|
@@ -169,7 +171,7 @@ export class CookieUserSessionService {
|
|
|
169
171
|
catch (err) {
|
|
170
172
|
// clear the cookie if it's invalid
|
|
171
173
|
if (err instanceof InvalidSessionError && reply) {
|
|
172
|
-
reply.clearCookie(cookieName,
|
|
174
|
+
reply.clearCookie(cookieName, getCookieOptions());
|
|
173
175
|
}
|
|
174
176
|
throw err;
|
|
175
177
|
}
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
import { verifyRequestOrigin } from '$verifyRequestOrigin';
|
|
21
21
|
import { InvalidSessionError } from '%authContextImports';
|
|
22
22
|
import { DEFAULT_USER_ROLES } from '%authRolesImports';
|
|
23
|
-
import {
|
|
23
|
+
import { getConfig, isDevelopment } from '%configServiceImports';
|
|
24
24
|
import { ForbiddenError } from '%errorHandlerServiceImports';
|
|
25
25
|
import { prisma } from '%prismaImports';
|
|
26
26
|
import { randomBytes } from 'node:crypto';
|
|
@@ -30,13 +30,15 @@ interface SessionCookieValue {
|
|
|
30
30
|
token: string;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
function getCookieOptions(): CookieSerializeOptions {
|
|
34
|
+
return {
|
|
35
|
+
httpOnly: true,
|
|
36
|
+
sameSite: 'lax',
|
|
37
|
+
secure: !isDevelopment(),
|
|
38
|
+
maxAge: USER_SESSION_DURATION_SEC,
|
|
39
|
+
path: '/',
|
|
40
|
+
};
|
|
41
|
+
}
|
|
40
42
|
|
|
41
43
|
/**
|
|
42
44
|
* Validates the expiry of a user session and determines if it needs to be renewed.
|
|
@@ -129,9 +131,9 @@ export class CookieUserSessionService implements UserSessionService {
|
|
|
129
131
|
];
|
|
130
132
|
|
|
131
133
|
const cookieName = getUserSessionCookieName(context.reqInfo.headers);
|
|
132
|
-
const cookieValue = signObject({ token },
|
|
134
|
+
const cookieValue = signObject({ token }, getConfig().AUTH_SECRET);
|
|
133
135
|
|
|
134
|
-
context.cookieStore.set(cookieName, cookieValue,
|
|
136
|
+
context.cookieStore.set(cookieName, cookieValue, getCookieOptions());
|
|
135
137
|
|
|
136
138
|
return { userId, expiresAt, roles };
|
|
137
139
|
}
|
|
@@ -151,7 +153,7 @@ export class CookieUserSessionService implements UserSessionService {
|
|
|
151
153
|
});
|
|
152
154
|
|
|
153
155
|
const cookieName = getUserSessionCookieName(context.reqInfo.headers);
|
|
154
|
-
context.cookieStore.clear(cookieName,
|
|
156
|
+
context.cookieStore.clear(cookieName, getCookieOptions());
|
|
155
157
|
}
|
|
156
158
|
|
|
157
159
|
/**
|
|
@@ -180,7 +182,7 @@ export class CookieUserSessionService implements UserSessionService {
|
|
|
180
182
|
(req.method !== 'GET' ||
|
|
181
183
|
req.headers.upgrade?.toLowerCase() === 'websocket') &&
|
|
182
184
|
req.method !== 'HEAD' &&
|
|
183
|
-
!verifyRequestOrigin(req, [req.host, ...
|
|
185
|
+
!verifyRequestOrigin(req, [req.host, ...getConfig().ALLOWED_ORIGINS])
|
|
184
186
|
) {
|
|
185
187
|
throw new ForbiddenError('Invalid Origin header');
|
|
186
188
|
}
|
|
@@ -188,7 +190,7 @@ export class CookieUserSessionService implements UserSessionService {
|
|
|
188
190
|
// Unsign the session cookie
|
|
189
191
|
const sessionCookieResult = unsignObject(
|
|
190
192
|
sessionCookieValue,
|
|
191
|
-
|
|
193
|
+
getConfig().AUTH_SECRET,
|
|
192
194
|
) as SessionCookieValue | undefined;
|
|
193
195
|
if (!sessionCookieResult) throw new InvalidSessionError();
|
|
194
196
|
|
|
@@ -218,8 +220,8 @@ export class CookieUserSessionService implements UserSessionService {
|
|
|
218
220
|
expiresAt: sessionExpiryResult.newExpiry,
|
|
219
221
|
},
|
|
220
222
|
});
|
|
221
|
-
const newSignedCookie = signObject({ token },
|
|
222
|
-
reply.setCookie(cookieName, newSignedCookie,
|
|
223
|
+
const newSignedCookie = signObject({ token }, getConfig().AUTH_SECRET);
|
|
224
|
+
reply.setCookie(cookieName, newSignedCookie, getCookieOptions());
|
|
223
225
|
}
|
|
224
226
|
|
|
225
227
|
const { user } = userSession;
|
|
@@ -238,7 +240,7 @@ export class CookieUserSessionService implements UserSessionService {
|
|
|
238
240
|
} catch (err) {
|
|
239
241
|
// clear the cookie if it's invalid
|
|
240
242
|
if (err instanceof InvalidSessionError && reply) {
|
|
241
|
-
reply.clearCookie(cookieName,
|
|
243
|
+
reply.clearCookie(cookieName, getCookieOptions());
|
|
242
244
|
}
|
|
243
245
|
throw err;
|
|
244
246
|
}
|
package/dist/local-auth/core/generators/auth-module/templates/module/utils/session-cookie.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
|
-
import {
|
|
2
|
+
import { getConfig, isDevelopment } from '%configServiceImports';
|
|
3
3
|
const COOKIE_NAME = 'user-session';
|
|
4
4
|
/**
|
|
5
5
|
* Retrieves the name of the session cookie based on the provided request.
|
|
@@ -10,9 +10,10 @@ const COOKIE_NAME = 'user-session';
|
|
|
10
10
|
* @returns The name of the Iron session cookie.
|
|
11
11
|
*/
|
|
12
12
|
export function getUserSessionCookieName(headers) {
|
|
13
|
-
if (
|
|
13
|
+
if (!isDevelopment()) {
|
|
14
14
|
return `__Host-${COOKIE_NAME}`;
|
|
15
15
|
}
|
|
16
|
+
const { SERVER_PORT } = getConfig();
|
|
16
17
|
// in development, localhost does not support the __Host prefix and should be scoped to port
|
|
17
18
|
// use origin/referer header to determine hostname because dev reverse proxies use origin/referer to signal the original host
|
|
18
19
|
const { origin, referer } = headers;
|
|
@@ -20,18 +21,17 @@ export function getUserSessionCookieName(headers) {
|
|
|
20
21
|
let port;
|
|
21
22
|
try {
|
|
22
23
|
if (!originalHost) {
|
|
23
|
-
port =
|
|
24
|
+
port = SERVER_PORT;
|
|
24
25
|
}
|
|
25
26
|
else {
|
|
26
27
|
const url = new URL(originalHost);
|
|
27
28
|
const parsedPort = Number.parseInt(url.port, 10);
|
|
28
29
|
// Validate port is in valid range (1-65535)
|
|
29
|
-
port =
|
|
30
|
-
parsedPort > 0 && parsedPort < 65_536 ? parsedPort : config.SERVER_PORT;
|
|
30
|
+
port = parsedPort > 0 && parsedPort < 65_536 ? parsedPort : SERVER_PORT;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
catch {
|
|
34
|
-
port =
|
|
34
|
+
port = SERVER_PORT;
|
|
35
35
|
}
|
|
36
36
|
return `${COOKIE_NAME}-${port}`;
|
|
37
37
|
}
|
package/dist/local-auth/core/generators/auth-module/templates/module/utils/session-cookie.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import type { FastifyRequest } from 'fastify';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { getConfig, isDevelopment } from '%configServiceImports';
|
|
6
6
|
|
|
7
7
|
const COOKIE_NAME = 'user-session';
|
|
8
8
|
|
|
@@ -17,9 +17,10 @@ const COOKIE_NAME = 'user-session';
|
|
|
17
17
|
export function getUserSessionCookieName(
|
|
18
18
|
headers: FastifyRequest['headers'],
|
|
19
19
|
): string {
|
|
20
|
-
if (
|
|
20
|
+
if (!isDevelopment()) {
|
|
21
21
|
return `__Host-${COOKIE_NAME}`;
|
|
22
22
|
}
|
|
23
|
+
const { SERVER_PORT } = getConfig();
|
|
23
24
|
// in development, localhost does not support the __Host prefix and should be scoped to port
|
|
24
25
|
// use origin/referer header to determine hostname because dev reverse proxies use origin/referer to signal the original host
|
|
25
26
|
const { origin, referer } = headers;
|
|
@@ -27,16 +28,15 @@ export function getUserSessionCookieName(
|
|
|
27
28
|
let port;
|
|
28
29
|
try {
|
|
29
30
|
if (!originalHost) {
|
|
30
|
-
port =
|
|
31
|
+
port = SERVER_PORT;
|
|
31
32
|
} else {
|
|
32
33
|
const url = new URL(originalHost);
|
|
33
34
|
const parsedPort = Number.parseInt(url.port, 10);
|
|
34
35
|
// Validate port is in valid range (1-65535)
|
|
35
|
-
port =
|
|
36
|
-
parsedPort > 0 && parsedPort < 65_536 ? parsedPort : config.SERVER_PORT;
|
|
36
|
+
port = parsedPort > 0 && parsedPort < 65_536 ? parsedPort : SERVER_PORT;
|
|
37
37
|
}
|
|
38
38
|
} catch {
|
|
39
|
-
port =
|
|
39
|
+
port = SERVER_PORT;
|
|
40
40
|
}
|
|
41
41
|
return `${COOKIE_NAME}-${port}`;
|
|
42
42
|
}
|
|
@@ -49,10 +49,6 @@ export declare const authRoutesGenerator: import("@baseplate-dev/sync").Generato
|
|
|
49
49
|
AutocompleteValue: {};
|
|
50
50
|
Badge: {};
|
|
51
51
|
badgeVariants: {};
|
|
52
|
-
BadgeWithIcon: {};
|
|
53
|
-
BadgeWithIconProps: {
|
|
54
|
-
isTypeOnly: true;
|
|
55
|
-
};
|
|
56
52
|
Breadcrumb: {};
|
|
57
53
|
BreadcrumbEllipsis: {};
|
|
58
54
|
BreadcrumbItem: {};
|
|
@@ -72,7 +68,6 @@ export declare const authRoutesGenerator: import("@baseplate-dev/sync").Generato
|
|
|
72
68
|
Checkbox: {};
|
|
73
69
|
CheckboxField: {};
|
|
74
70
|
CheckboxFieldController: {};
|
|
75
|
-
CheckedInput: {};
|
|
76
71
|
CircularProgress: {};
|
|
77
72
|
cn: {};
|
|
78
73
|
Collapsible: {};
|
|
@@ -163,10 +158,8 @@ export declare const authRoutesGenerator: import("@baseplate-dev/sync").Generato
|
|
|
163
158
|
ItemTitle: {};
|
|
164
159
|
itemVariants: {};
|
|
165
160
|
Label: {};
|
|
166
|
-
LinkButton: {};
|
|
167
161
|
Loader: {};
|
|
168
162
|
mergeRefs: {};
|
|
169
|
-
Modal: {};
|
|
170
163
|
MultiComboboxField: {};
|
|
171
164
|
MultiComboboxFieldController: {};
|
|
172
165
|
MultiComboboxFieldProps: {
|
|
@@ -184,19 +177,21 @@ export declare const authRoutesGenerator: import("@baseplate-dev/sync").Generato
|
|
|
184
177
|
NavigationMenuList: {};
|
|
185
178
|
NavigationMenuTrigger: {};
|
|
186
179
|
navigationMenuTriggerStyle: {};
|
|
187
|
-
NavigationMenuViewport: {};
|
|
188
180
|
NotFoundCard: {};
|
|
181
|
+
NumberField: {};
|
|
182
|
+
NumberFieldController: {};
|
|
189
183
|
Popover: {};
|
|
190
|
-
PopoverAnchor: {};
|
|
191
184
|
PopoverContent: {};
|
|
192
185
|
PopoverTrigger: {};
|
|
193
|
-
|
|
194
|
-
|
|
186
|
+
RadioField: {};
|
|
187
|
+
RadioFieldController: {};
|
|
188
|
+
RadioOptionProps: {
|
|
189
|
+
isTypeOnly: true;
|
|
190
|
+
};
|
|
195
191
|
ScrollArea: {};
|
|
196
192
|
Select: {};
|
|
197
193
|
SelectField: {};
|
|
198
194
|
SelectFieldController: {};
|
|
199
|
-
SelectInput: {};
|
|
200
195
|
SelectOptionProps: {
|
|
201
196
|
isTypeOnly: true;
|
|
202
197
|
};
|
|
@@ -249,8 +244,6 @@ export declare const authRoutesGenerator: import("@baseplate-dev/sync").Generato
|
|
|
249
244
|
Textarea: {};
|
|
250
245
|
TextareaField: {};
|
|
251
246
|
TextareaFieldController: {};
|
|
252
|
-
TextAreaInput: {};
|
|
253
|
-
TextInput: {};
|
|
254
247
|
Toaster: {};
|
|
255
248
|
Tooltip: {};
|
|
256
249
|
TooltipContent: {};
|