@opensaas/keystone-nextjs-auth 17.0.0 → 19.1.0
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 +24 -0
- package/dist/declarations/src/gql/getBaseAuthSchema.d.ts +3 -3
- package/dist/declarations/src/index.d.ts +1 -1
- package/dist/declarations/src/lib/validateNextAuth.d.ts +1 -1
- package/dist/declarations/src/pages/NextAuthPage.d.ts +1 -1
- package/dist/declarations/src/schema.d.ts +1 -1
- package/dist/declarations/src/types.d.ts +2 -2
- package/dist/opensaas-keystone-nextjs-auth.cjs.dev.js +19 -11
- package/dist/opensaas-keystone-nextjs-auth.cjs.prod.js +16 -12
- package/dist/opensaas-keystone-nextjs-auth.esm.js +16 -8
- package/package.json +6 -7
- package/src/gql/getBaseAuthSchema.ts +3 -3
- package/src/gql/getInitFirstItemSchema.ts +1 -1
- package/src/index.ts +12 -2
- package/src/lib/validateNextAuth.ts +1 -1
- package/src/pages/NextAuthPage.tsx +1 -1
- package/src/schema.ts +2 -2
- package/src/templates/next-config.ts +4 -4
- package/src/types.ts +2 -5
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,29 @@
|
|
1
1
|
# @opensaas-keystone/nextjs-auth
|
2
2
|
|
3
|
+
## 19.1.0
|
4
|
+
|
5
|
+
### Minor Changes
|
6
|
+
|
7
|
+
- fa61bd9: Allow custom port to be defined by env `PORT` as well as a custom path
|
8
|
+
|
9
|
+
## 19.0.0
|
10
|
+
|
11
|
+
### Major Changes
|
12
|
+
|
13
|
+
- 5ac88ef: Upgrade to `keystone-6/core` for more information see https://keystonejs.com/releases/2021-12-01
|
14
|
+
|
15
|
+
## 18.0.1
|
16
|
+
|
17
|
+
### Patch Changes
|
18
|
+
|
19
|
+
- 9b6052a: Fix access issue to allow `/api/__keystone_api_build`
|
20
|
+
|
21
|
+
## 18.0.0
|
22
|
+
|
23
|
+
### Major Changes
|
24
|
+
|
25
|
+
- cff5031: Upgrade to `"@keystone-next/keystone": "^29.0.0"` see https://keystonejs.com/releases/2021-11-24 for more information
|
26
|
+
|
3
27
|
## 17.0.0
|
4
28
|
|
5
29
|
### Major Changes
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import type {
|
2
|
-
import { graphql } from '@keystone-
|
1
|
+
import type { BaseItem } from '@keystone-6/core/types';
|
2
|
+
import { graphql } from '@keystone-6/core';
|
3
3
|
import { AuthGqlNames } from '../types';
|
4
4
|
export declare function getBaseAuthSchema({ listKey, gqlNames, base, }: {
|
5
5
|
listKey: string;
|
@@ -8,7 +8,7 @@ export declare function getBaseAuthSchema({ listKey, gqlNames, base, }: {
|
|
8
8
|
}): {
|
9
9
|
extension: {
|
10
10
|
query: {
|
11
|
-
authenticatedItem: import("@graphql-ts/schema").Field<unknown, {}, import("@graphql-ts/schema").UnionType<
|
11
|
+
authenticatedItem: import("@graphql-ts/schema").Field<unknown, {}, import("@graphql-ts/schema").UnionType<BaseItem, graphql.Context>, string, graphql.Context>;
|
12
12
|
};
|
13
13
|
};
|
14
14
|
};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { BaseGeneratedListTypes, KeystoneConfig } from '@keystone-
|
1
|
+
import { BaseGeneratedListTypes, KeystoneConfig } from '@keystone-6/core/types';
|
2
2
|
import { AuthConfig, KeystoneAuthConfig } from './types';
|
3
3
|
export declare const nextAuthProviders: import("next-auth/providers").BuiltInProviders;
|
4
4
|
/**
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { KeystoneListsAPI } from '@keystone-
|
1
|
+
import type { KeystoneListsAPI } from '@keystone-6/core/types';
|
2
2
|
import { NextAuthErrorCode } from '../types';
|
3
3
|
export declare function validateNextAuth(list: any, identityField: string, identity: string | number, protectIdentities: boolean, itemAPI: KeystoneListsAPI<any>[string]): Promise<{
|
4
4
|
success: false;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { Provider } from 'next-auth/providers';
|
2
|
-
import type { KeystoneListsAPI } from '@keystone-
|
2
|
+
import type { KeystoneListsAPI } from '@keystone-6/core/types';
|
3
3
|
declare type NextAuthPageProps = {
|
4
4
|
identityField: string;
|
5
5
|
mutationName: string;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { ExtendGraphqlSchema } from '@keystone-
|
1
|
+
import { ExtendGraphqlSchema } from '@keystone-6/core/types';
|
2
2
|
import { AuthGqlNames } from './types';
|
3
3
|
export declare const getSchemaExtension: ({ identityField, listKey, gqlNames, }: {
|
4
4
|
identityField: string;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { BaseListTypeInfo, KeystoneConfig } from '@keystone-6/core/types';
|
2
2
|
import { Provider } from 'next-auth/providers';
|
3
3
|
export declare type AuthGqlNames = {
|
4
4
|
CreateInitialInput: string;
|
@@ -18,7 +18,7 @@ declare type KeytoneAuthProviders = {
|
|
18
18
|
providers: NextAuthProviders;
|
19
19
|
};
|
20
20
|
export declare type KeystoneAuthConfig = KeystoneConfig & KeytoneAuthProviders;
|
21
|
-
export declare type AuthConfig<GeneratedListTypes extends
|
21
|
+
export declare type AuthConfig<GeneratedListTypes extends BaseListTypeInfo> = {
|
22
22
|
/** The key of the list to authenticate users with */
|
23
23
|
listKey: GeneratedListTypes['key'];
|
24
24
|
/** The path of the field the identity is stored in; must be text-ish */
|
@@ -15,7 +15,7 @@ var cookie = require('cookie');
|
|
15
15
|
var ejs = require('ejs');
|
16
16
|
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
17
17
|
var graphql = require('graphql');
|
18
|
-
var
|
18
|
+
var core = require('@keystone-6/core');
|
19
19
|
|
20
20
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
21
21
|
|
@@ -64,14 +64,14 @@ module.exports = withPreconstruct({
|
|
64
64
|
...config.resolve.alias,
|
65
65
|
react: Path.dirname(require.resolve('react/package.json')),
|
66
66
|
'react-dom': Path.dirname(require.resolve('react-dom/package.json')),
|
67
|
-
'@keystone-
|
68
|
-
require.resolve('@keystone-
|
67
|
+
'@keystone-6/core': Path.dirname(
|
68
|
+
require.resolve('@keystone-6/core/package.json')
|
69
69
|
),
|
70
70
|
};
|
71
71
|
if (isServer) {
|
72
72
|
config.externals = [
|
73
73
|
...config.externals,
|
74
|
-
/@keystone-
|
74
|
+
/@keystone-6\\/core(?!\\/___internal-do-not-use-will-break-in-patch\\/admin-ui\\/id-field-view|\\/fields\\/types\\/[^\\/]+\\/views)/,
|
75
75
|
/.prisma\\/client/
|
76
76
|
];
|
77
77
|
// we need to set these to true so that when __dirname/__filename is used
|
@@ -90,7 +90,7 @@ module.exports = withPreconstruct({
|
|
90
90
|
return [
|
91
91
|
{
|
92
92
|
source: '/api/__keystone_api_build',
|
93
|
-
destination: 'http://localhost
|
93
|
+
destination: 'http://localhost:<%= process.env.PORT || 3000 %><%= keystonePath || '' %>/api/__keystone_api_build',
|
94
94
|
basePath: false
|
95
95
|
}
|
96
96
|
];
|
@@ -116,8 +116,8 @@ function getBaseAuthSchema({
|
|
116
116
|
}) {
|
117
117
|
const extension = {
|
118
118
|
query: {
|
119
|
-
authenticatedItem:
|
120
|
-
type:
|
119
|
+
authenticatedItem: core.graphql.field({
|
120
|
+
type: core.graphql.union({
|
121
121
|
name: 'AuthenticatedItem',
|
122
122
|
types: [base.object(listKey)],
|
123
123
|
resolveType: (root, context) => {
|
@@ -154,7 +154,7 @@ const getSchemaExtension = ({
|
|
154
154
|
identityField,
|
155
155
|
listKey,
|
156
156
|
gqlNames
|
157
|
-
}) =>
|
157
|
+
}) => core.graphql.extend(base => {
|
158
158
|
var _context;
|
159
159
|
|
160
160
|
const uniqueWhereInputType = graphql.assertInputObjectType(base.schema.getType(`${listKey}WhereUniqueInput`));
|
@@ -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;
|
@@ -15,7 +15,7 @@ var cookie = require('cookie');
|
|
15
15
|
var ejs = require('ejs');
|
16
16
|
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
17
17
|
var graphql = require('graphql');
|
18
|
-
var
|
18
|
+
var core = require('@keystone-6/core');
|
19
19
|
|
20
20
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
21
21
|
|
@@ -64,14 +64,14 @@ module.exports = withPreconstruct({
|
|
64
64
|
...config.resolve.alias,
|
65
65
|
react: Path.dirname(require.resolve('react/package.json')),
|
66
66
|
'react-dom': Path.dirname(require.resolve('react-dom/package.json')),
|
67
|
-
'@keystone-
|
68
|
-
require.resolve('@keystone-
|
67
|
+
'@keystone-6/core': Path.dirname(
|
68
|
+
require.resolve('@keystone-6/core/package.json')
|
69
69
|
),
|
70
70
|
};
|
71
71
|
if (isServer) {
|
72
72
|
config.externals = [
|
73
73
|
...config.externals,
|
74
|
-
/@keystone-
|
74
|
+
/@keystone-6\\/core(?!\\/___internal-do-not-use-will-break-in-patch\\/admin-ui\\/id-field-view|\\/fields\\/types\\/[^\\/]+\\/views)/,
|
75
75
|
/.prisma\\/client/
|
76
76
|
];
|
77
77
|
// we need to set these to true so that when __dirname/__filename is used
|
@@ -90,7 +90,7 @@ module.exports = withPreconstruct({
|
|
90
90
|
return [
|
91
91
|
{
|
92
92
|
source: '/api/__keystone_api_build',
|
93
|
-
destination: 'http://localhost
|
93
|
+
destination: 'http://localhost:<%= process.env.PORT || 3000 %><%= keystonePath || '' %>/api/__keystone_api_build',
|
94
94
|
basePath: false
|
95
95
|
}
|
96
96
|
];
|
@@ -116,8 +116,8 @@ function getBaseAuthSchema({
|
|
116
116
|
}) {
|
117
117
|
const extension = {
|
118
118
|
query: {
|
119
|
-
authenticatedItem:
|
120
|
-
type:
|
119
|
+
authenticatedItem: core.graphql.field({
|
120
|
+
type: core.graphql.union({
|
121
121
|
name: 'AuthenticatedItem',
|
122
122
|
types: [base.object(listKey)],
|
123
123
|
resolveType: (root, context) => {
|
@@ -154,7 +154,7 @@ const getSchemaExtension = ({
|
|
154
154
|
identityField,
|
155
155
|
listKey,
|
156
156
|
gqlNames
|
157
|
-
}) =>
|
157
|
+
}) => core.graphql.extend(base => {
|
158
158
|
var _context;
|
159
159
|
|
160
160
|
const uniqueWhereInputType = graphql.assertInputObjectType(base.schema.getType(`${listKey}WhereUniqueInput`));
|
@@ -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;
|
@@ -11,7 +11,7 @@ import * as cookie from 'cookie';
|
|
11
11
|
import ejs from 'ejs';
|
12
12
|
import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
|
13
13
|
import { assertInputObjectType, GraphQLString, GraphQLID } from 'graphql';
|
14
|
-
import { graphql } from '@keystone-
|
14
|
+
import { graphql } from '@keystone-6/core';
|
15
15
|
|
16
16
|
const template$1 = `
|
17
17
|
const Path = require('path');
|
@@ -30,14 +30,14 @@ module.exports = withPreconstruct({
|
|
30
30
|
...config.resolve.alias,
|
31
31
|
react: Path.dirname(require.resolve('react/package.json')),
|
32
32
|
'react-dom': Path.dirname(require.resolve('react-dom/package.json')),
|
33
|
-
'@keystone-
|
34
|
-
require.resolve('@keystone-
|
33
|
+
'@keystone-6/core': Path.dirname(
|
34
|
+
require.resolve('@keystone-6/core/package.json')
|
35
35
|
),
|
36
36
|
};
|
37
37
|
if (isServer) {
|
38
38
|
config.externals = [
|
39
39
|
...config.externals,
|
40
|
-
/@keystone-
|
40
|
+
/@keystone-6\\/core(?!\\/___internal-do-not-use-will-break-in-patch\\/admin-ui\\/id-field-view|\\/fields\\/types\\/[^\\/]+\\/views)/,
|
41
41
|
/.prisma\\/client/
|
42
42
|
];
|
43
43
|
// we need to set these to true so that when __dirname/__filename is used
|
@@ -56,7 +56,7 @@ module.exports = withPreconstruct({
|
|
56
56
|
return [
|
57
57
|
{
|
58
58
|
source: '/api/__keystone_api_build',
|
59
|
-
destination: 'http://localhost
|
59
|
+
destination: 'http://localhost:<%= process.env.PORT || 3000 %><%= keystonePath || '' %>/api/__keystone_api_build',
|
60
60
|
basePath: false
|
61
61
|
}
|
62
62
|
];
|
@@ -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
@@ -1,28 +1,27 @@
|
|
1
1
|
{
|
2
2
|
"name": "@opensaas/keystone-nextjs-auth",
|
3
|
-
"version": "
|
3
|
+
"version": "19.1.0",
|
4
4
|
"repository": "https://github.com/opensaasau/keystone-nextjs-auth",
|
5
5
|
"license": "MIT",
|
6
6
|
"main": "dist/opensaas-keystone-nextjs-auth.cjs.js",
|
7
7
|
"module": "dist/opensaas-keystone-nextjs-auth.esm.js",
|
8
8
|
"dependencies": {
|
9
|
-
"@babel/runtime": "^7.
|
10
|
-
"@babel/runtime-corejs3": "^7.
|
11
|
-
"@keystone-next/admin-ui-utils": "^6.0.0",
|
9
|
+
"@babel/runtime": "^7.16.3",
|
10
|
+
"@babel/runtime-corejs3": "^7.16.3",
|
12
11
|
"@types/ejs": "^3.1.0",
|
13
12
|
"cookie": "^0.4.1",
|
14
13
|
"cross-fetch": "^3.1.4",
|
15
14
|
"ejs": "^3.1.6",
|
16
15
|
"fast-deep-equal": "^3.1.3",
|
17
|
-
"graphql": "^15.
|
16
|
+
"graphql": "^15.7.2",
|
18
17
|
"next-auth": "^3.29.0"
|
19
18
|
},
|
20
19
|
"devDependencies": {
|
21
|
-
"@keystone-
|
20
|
+
"@keystone-6/core": "^1.0.0",
|
22
21
|
"react": "^17.0.2"
|
23
22
|
},
|
24
23
|
"peerDependencies": {
|
25
|
-
"@keystone-
|
24
|
+
"@keystone-6/core": "^1.0.0",
|
26
25
|
"react": "^17.0.2"
|
27
26
|
},
|
28
27
|
"engines": {
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import type {
|
2
|
-
import { graphql } from '@keystone-
|
1
|
+
import type { BaseItem } from '@keystone-6/core/types';
|
2
|
+
import { graphql } from '@keystone-6/core';
|
3
3
|
|
4
4
|
import { AuthGqlNames } from '../types';
|
5
5
|
|
@@ -17,7 +17,7 @@ export function getBaseAuthSchema({
|
|
17
17
|
authenticatedItem: graphql.field({
|
18
18
|
type: graphql.union({
|
19
19
|
name: 'AuthenticatedItem',
|
20
|
-
types: [base.object(listKey) as graphql.ObjectType<
|
20
|
+
types: [base.object(listKey) as graphql.ObjectType<BaseItem>],
|
21
21
|
resolveType: (root, context) => context.session?.listKey,
|
22
22
|
}),
|
23
23
|
resolve(root, args, { session, db }) {
|
package/src/index.ts
CHANGED
@@ -6,7 +6,7 @@ import {
|
|
6
6
|
KeystoneContext,
|
7
7
|
AdminUIConfig,
|
8
8
|
SessionStrategy,
|
9
|
-
} from '@keystone-
|
9
|
+
} from '@keystone-6/core/types';
|
10
10
|
import { getSession } from 'next-auth/client';
|
11
11
|
import Providers from 'next-auth/providers';
|
12
12
|
import * as cookie from 'cookie';
|
@@ -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;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import NextAuth from 'next-auth';
|
2
2
|
import { Provider } from 'next-auth/providers';
|
3
|
-
import type { KeystoneListsAPI } from '@keystone-
|
3
|
+
import type { KeystoneListsAPI } from '@keystone-6/core/types';
|
4
4
|
import { validateNextAuth } from '../lib/validateNextAuth';
|
5
5
|
|
6
6
|
// Need to bring in correct props
|
package/src/schema.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
import { ExtendGraphqlSchema } from '@keystone-
|
1
|
+
import { ExtendGraphqlSchema } from '@keystone-6/core/types';
|
2
2
|
|
3
3
|
import { assertInputObjectType, GraphQLString, GraphQLID } from 'graphql';
|
4
|
-
import { graphql } from '@keystone-
|
4
|
+
import { graphql } from '@keystone-6/core';
|
5
5
|
import { AuthGqlNames } from './types';
|
6
6
|
import { getBaseAuthSchema } from './gql/getBaseAuthSchema';
|
7
7
|
|
@@ -17,14 +17,14 @@ module.exports = withPreconstruct({
|
|
17
17
|
...config.resolve.alias,
|
18
18
|
react: Path.dirname(require.resolve('react/package.json')),
|
19
19
|
'react-dom': Path.dirname(require.resolve('react-dom/package.json')),
|
20
|
-
'@keystone-
|
21
|
-
require.resolve('@keystone-
|
20
|
+
'@keystone-6/core': Path.dirname(
|
21
|
+
require.resolve('@keystone-6/core/package.json')
|
22
22
|
),
|
23
23
|
};
|
24
24
|
if (isServer) {
|
25
25
|
config.externals = [
|
26
26
|
...config.externals,
|
27
|
-
/@keystone-
|
27
|
+
/@keystone-6\\/core(?!\\/___internal-do-not-use-will-break-in-patch\\/admin-ui\\/id-field-view|\\/fields\\/types\\/[^\\/]+\\/views)/,
|
28
28
|
/.prisma\\/client/
|
29
29
|
];
|
30
30
|
// we need to set these to true so that when __dirname/__filename is used
|
@@ -43,7 +43,7 @@ module.exports = withPreconstruct({
|
|
43
43
|
return [
|
44
44
|
{
|
45
45
|
source: '/api/__keystone_api_build',
|
46
|
-
destination: 'http://localhost
|
46
|
+
destination: 'http://localhost:<%= process.env.PORT || 3000 %><%= keystonePath || '' %>/api/__keystone_api_build',
|
47
47
|
basePath: false
|
48
48
|
}
|
49
49
|
];
|
package/src/types.ts
CHANGED
@@ -1,7 +1,4 @@
|
|
1
|
-
import {
|
2
|
-
BaseGeneratedListTypes,
|
3
|
-
KeystoneConfig,
|
4
|
-
} from '@keystone-next/keystone/types';
|
1
|
+
import { BaseListTypeInfo, KeystoneConfig } from '@keystone-6/core/types';
|
5
2
|
import { Provider } from 'next-auth/providers';
|
6
3
|
|
7
4
|
export type AuthGqlNames = {
|
@@ -23,7 +20,7 @@ type KeytoneAuthProviders = {
|
|
23
20
|
|
24
21
|
export type KeystoneAuthConfig = KeystoneConfig & KeytoneAuthProviders;
|
25
22
|
|
26
|
-
export type AuthConfig<GeneratedListTypes extends
|
23
|
+
export type AuthConfig<GeneratedListTypes extends BaseListTypeInfo> = {
|
27
24
|
/** The key of the list to authenticate users with */
|
28
25
|
listKey: GeneratedListTypes['key'];
|
29
26
|
/** The path of the field the identity is stored in; must be text-ish */
|