@opensaas/keystone-nextjs-auth 18.0.0 → 18.0.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.
package/CHANGELOG.md
CHANGED
@@ -267,6 +267,10 @@ function createAuth({
|
|
267
267
|
} = context;
|
268
268
|
const pathname = url__default["default"].parse(req === null || req === void 0 ? void 0 : req.url).pathname;
|
269
269
|
|
270
|
+
if (pathname === `${customPath}/api/__keystone_api_build`) {
|
271
|
+
return;
|
272
|
+
}
|
273
|
+
|
270
274
|
if (isValidSession) {
|
271
275
|
if (pathname === `${customPath}/api/auth/signin`) {
|
272
276
|
return {
|
@@ -452,11 +456,15 @@ function createAuth({
|
|
452
456
|
},
|
453
457
|
enableSessionItem: true,
|
454
458
|
isAccessAllowed: async context => {
|
455
|
-
var _context$req, _keystoneConfig$ui3;
|
459
|
+
var _context$req, _context$req2, _keystoneConfig$ui3;
|
456
460
|
|
457
|
-
|
461
|
+
if (process.env.NODE_ENV !== 'production' && ((_context$req = context.req) === null || _context$req === void 0 ? void 0 : _context$req.url) !== undefined && new _URL__default["default"](context.req.url, 'http://example.com').pathname === `${customPath}/api/__keystone_api_build`) {
|
462
|
+
return true;
|
463
|
+
} // Allow access to the adminMeta data from the /init path to correctly render that page
|
458
464
|
// even if the user isn't logged in (which should always be the case if they're seeing /init)
|
459
|
-
|
465
|
+
|
466
|
+
|
467
|
+
const headers = (_context$req2 = context.req) === null || _context$req2 === void 0 ? void 0 : _context$req2.headers;
|
460
468
|
const host = headers ? headers['x-forwarded-host'] || headers.host : null;
|
461
469
|
const thisUrl = headers !== null && headers !== void 0 && headers.referer ? new _URL__default["default"](headers.referer) : undefined;
|
462
470
|
const accessingInitPage = (thisUrl === null || thisUrl === void 0 ? void 0 : thisUrl.pathname) === '/init' && (thisUrl === null || thisUrl === void 0 ? void 0 : thisUrl.host) === host && (await context.sudo().query[listKey].count({})) === 0;
|
@@ -267,6 +267,10 @@ function createAuth({
|
|
267
267
|
} = context;
|
268
268
|
const pathname = url__default["default"].parse(req === null || req === void 0 ? void 0 : req.url).pathname;
|
269
269
|
|
270
|
+
if (pathname === `${customPath}/api/__keystone_api_build`) {
|
271
|
+
return;
|
272
|
+
}
|
273
|
+
|
270
274
|
if (isValidSession) {
|
271
275
|
if (pathname === `${customPath}/api/auth/signin`) {
|
272
276
|
return {
|
@@ -452,11 +456,11 @@ function createAuth({
|
|
452
456
|
},
|
453
457
|
enableSessionItem: true,
|
454
458
|
isAccessAllowed: async context => {
|
455
|
-
var _context$
|
456
|
-
|
457
|
-
// Allow access to the adminMeta data from the /init path to correctly render that page
|
459
|
+
var _context$req2, _keystoneConfig$ui3;
|
458
460
|
// even if the user isn't logged in (which should always be the case if they're seeing /init)
|
459
|
-
|
461
|
+
|
462
|
+
|
463
|
+
const headers = (_context$req2 = context.req) === null || _context$req2 === void 0 ? void 0 : _context$req2.headers;
|
460
464
|
const host = headers ? headers['x-forwarded-host'] || headers.host : null;
|
461
465
|
const thisUrl = headers !== null && headers !== void 0 && headers.referer ? new _URL__default["default"](headers.referer) : undefined;
|
462
466
|
const accessingInitPage = (thisUrl === null || thisUrl === void 0 ? void 0 : thisUrl.pathname) === '/init' && (thisUrl === null || thisUrl === void 0 ? void 0 : thisUrl.host) === host && (await context.sudo().query[listKey].count({})) === 0;
|
@@ -233,6 +233,10 @@ function createAuth({
|
|
233
233
|
} = context;
|
234
234
|
const pathname = url.parse(req === null || req === void 0 ? void 0 : req.url).pathname;
|
235
235
|
|
236
|
+
if (pathname === `${customPath}/api/__keystone_api_build`) {
|
237
|
+
return;
|
238
|
+
}
|
239
|
+
|
236
240
|
if (isValidSession) {
|
237
241
|
if (pathname === `${customPath}/api/auth/signin`) {
|
238
242
|
return {
|
@@ -418,11 +422,15 @@ function createAuth({
|
|
418
422
|
},
|
419
423
|
enableSessionItem: true,
|
420
424
|
isAccessAllowed: async context => {
|
421
|
-
var _context$req, _keystoneConfig$ui3;
|
425
|
+
var _context$req, _context$req2, _keystoneConfig$ui3;
|
422
426
|
|
423
|
-
|
427
|
+
if (process.env.NODE_ENV !== 'production' && ((_context$req = context.req) === null || _context$req === void 0 ? void 0 : _context$req.url) !== undefined && new _URL(context.req.url, 'http://example.com').pathname === `${customPath}/api/__keystone_api_build`) {
|
428
|
+
return true;
|
429
|
+
} // Allow access to the adminMeta data from the /init path to correctly render that page
|
424
430
|
// even if the user isn't logged in (which should always be the case if they're seeing /init)
|
425
|
-
|
431
|
+
|
432
|
+
|
433
|
+
const headers = (_context$req2 = context.req) === null || _context$req2 === void 0 ? void 0 : _context$req2.headers;
|
426
434
|
const host = headers ? headers['x-forwarded-host'] || headers.host : null;
|
427
435
|
const thisUrl = headers !== null && headers !== void 0 && headers.referer ? new _URL(headers.referer) : undefined;
|
428
436
|
const accessingInitPage = (thisUrl === null || thisUrl === void 0 ? void 0 : thisUrl.pathname) === '/init' && (thisUrl === null || thisUrl === void 0 ? void 0 : thisUrl.host) === host && (await context.sudo().query[listKey].count({})) === 0;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
@@ -73,7 +73,9 @@ export function createAuth<GeneratedListTypes extends BaseGeneratedListTypes>({
|
|
73
73
|
}) => {
|
74
74
|
const { req, session } = context;
|
75
75
|
const pathname = url.parse(req?.url!).pathname!;
|
76
|
-
|
76
|
+
if (pathname === `${customPath}/api/__keystone_api_build`) {
|
77
|
+
return;
|
78
|
+
}
|
77
79
|
if (isValidSession) {
|
78
80
|
if (pathname === `${customPath}/api/auth/signin`) {
|
79
81
|
return { kind: 'redirect', to: `${customPath}` };
|
@@ -244,6 +246,14 @@ export function createAuth<GeneratedListTypes extends BaseGeneratedListTypes>({
|
|
244
246
|
keystoneConfig?.ui?.pageMiddleware?.(args),
|
245
247
|
enableSessionItem: true,
|
246
248
|
isAccessAllowed: async (context: KeystoneContext) => {
|
249
|
+
if (
|
250
|
+
process.env.NODE_ENV !== 'production' &&
|
251
|
+
context.req?.url !== undefined &&
|
252
|
+
new URL(context.req.url, 'http://example.com').pathname ===
|
253
|
+
`${customPath}/api/__keystone_api_build`
|
254
|
+
) {
|
255
|
+
return true;
|
256
|
+
}
|
247
257
|
// Allow access to the adminMeta data from the /init path to correctly render that page
|
248
258
|
// even if the user isn't logged in (which should always be the case if they're seeing /init)
|
249
259
|
const headers = context.req?.headers;
|