@keystonejs/access-control
Advanced tools
Comparing version 5.2.0 to 6.0.0
# @keystonejs/access-control | ||
## 6.0.0 | ||
### Major Changes | ||
- [`839666e25`](https://github.com/keystonejs/keystone/commit/839666e25d8bffefd034e6344e11d72dd43b925b) [#2872](https://github.com/keystonejs/keystone/pull/2872) Thanks [@wcalebgray](https://github.com/wcalebgray)! - Added async capability for all Access Control resolvers. This changes the below methods to async functions, returning Promises: | ||
``` | ||
access-control | ||
- validateCustomAccessControl | ||
- validateListAccessControl | ||
- validateFieldAccessControl | ||
- validateAuthAccessControl | ||
keystone/List | ||
- checkFieldAccess | ||
- checkListAccess | ||
keystone/providers/custom | ||
- computeAccess | ||
keystone/providers/listAuth | ||
- checkAccess | ||
``` | ||
Changed `keystone/Keystone`'s `getGraphQlContext` return object (context) to include async resolvers for the following methods: | ||
``` | ||
- context.getCustomAccessControlForUser | ||
- context.getListAccessControlForUser | ||
- context.getFieldAccessControlForUser | ||
- context.getAuthAccessControlForUser | ||
``` | ||
## 5.2.0 | ||
@@ -31,3 +65,3 @@ | ||
- [`7b4ed362`](https://github.com/keystonejs/keystone-5/commit/7b4ed3623f5774d7783c39962bfa1ce97938e310) [#1821](https://github.com/keystonejs/keystone-5/pull/1821) Thanks [@jesstelford](https://github.com/jesstelford)! - Release @keystonejs/\* packages (つ^ ◡ ^)つ | ||
- [`7b4ed362`](https://github.com/keystonejs/keystone/commit/7b4ed3623f5774d7783c39962bfa1ce97938e310) [#1821](https://github.com/keystonejs/keystone/pull/1821) Thanks [@jesstelford](https://github.com/jesstelford)! - Release @keystonejs/\* packages (つ^ ◡ ^)つ | ||
@@ -40,3 +74,3 @@ - This is the first release of `@keystonejs/*` packages (previously `@keystone-alpha/*`). | ||
- Updated dependencies [[`7b4ed362`](https://github.com/keystonejs/keystone-5/commit/7b4ed3623f5774d7783c39962bfa1ce97938e310)]: | ||
- Updated dependencies [[`7b4ed362`](https://github.com/keystonejs/keystone/commit/7b4ed3623f5774d7783c39962bfa1ce97938e310)]: | ||
- @keystonejs/utils@5.0.0 | ||
@@ -50,3 +84,3 @@ | ||
- [1405eb07](https://github.com/keystonejs/keystone-5/commit/1405eb07): Add `listKey`, `fieldKey` (fields only), `operation`, `gqlName`, `itemId` and `itemIds` as arguments to imperative access control functions. | ||
- [1405eb07](https://github.com/keystonejs/keystone/commit/1405eb07): Add `listKey`, `fieldKey` (fields only), `operation`, `gqlName`, `itemId` and `itemIds` as arguments to imperative access control functions. | ||
@@ -57,3 +91,3 @@ ## 3.0.0 | ||
- [9ade2b2d](https://github.com/keystonejs/keystone-5/commit/9ade2b2d): Add support for `access: { auth: ... }` which controls whether authentication queries and mutations are accessible on a List | ||
- [9ade2b2d](https://github.com/keystonejs/keystone/commit/9ade2b2d): Add support for `access: { auth: ... }` which controls whether authentication queries and mutations are accessible on a List | ||
@@ -64,8 +98,8 @@ If you have a `List` which is being used as the target of an Authentication Strategy, you should set `access: { auth: true }` on that list. | ||
- [b61289b4](https://github.com/keystonejs/keystone-5/commit/b61289b4): Add `parseCustomAccess()` for parsing the access control directives on custom types/queries/mutations. | ||
- [0bba9f07](https://github.com/keystonejs/keystone-5/commit/0bba9f07): Add `validateCustomAccessControl()` for use by custom queries/mutations access control checking. | ||
- [b61289b4](https://github.com/keystonejs/keystone/commit/b61289b4): Add `parseCustomAccess()` for parsing the access control directives on custom types/queries/mutations. | ||
- [0bba9f07](https://github.com/keystonejs/keystone/commit/0bba9f07): Add `validateCustomAccessControl()` for use by custom queries/mutations access control checking. | ||
### Patch Changes | ||
- [9ece715c](https://github.com/keystonejs/keystone-5/commit/9ece715c): Refactor access-control internals to better support future changes | ||
- [9ece715c](https://github.com/keystonejs/keystone/commit/9ece715c): Refactor access-control internals to better support future changes | ||
@@ -76,3 +110,3 @@ ## 2.0.0 | ||
- [bc0b9813](https://github.com/keystonejs/keystone-5/commit/bc0b9813): `parseListAccess` and `parseFieldAccess` now take `schemaNames` as an argument, and return a nested access object, with the `schemaNames` as keys. | ||
- [bc0b9813](https://github.com/keystonejs/keystone/commit/bc0b9813): `parseListAccess` and `parseFieldAccess` now take `schemaNames` as an argument, and return a nested access object, with the `schemaNames` as keys. | ||
@@ -114,3 +148,3 @@ For example, | ||
- [e5d4ee76](https://github.com/keystonejs/keystone-5/commit/e5d4ee76): Expose 'originalInput' to access control functions for lists & fields | ||
- [e5d4ee76](https://github.com/keystonejs/keystone/commit/e5d4ee76): Expose 'originalInput' to access control functions for lists & fields | ||
@@ -121,3 +155,3 @@ ## 1.0.5 | ||
- [19fe6c1b](https://github.com/keystonejs/keystone-5/commit/19fe6c1b): | ||
- [19fe6c1b](https://github.com/keystonejs/keystone/commit/19fe6c1b): | ||
@@ -128,3 +162,3 @@ Move frontmatter in docs into comments | ||
- Updated dependencies [b7a2ea9c](https://github.com/keystonejs/keystone-5/commit/b7a2ea9c): | ||
- Updated dependencies [b7a2ea9c](https://github.com/keystonejs/keystone/commit/b7a2ea9c): | ||
- @keystone-alpha/utils@3.0.0 | ||
@@ -134,3 +168,3 @@ | ||
- [patch][10d96db2](https://github.com/keystonejs/keystone-5/commit/10d96db2): | ||
- [patch][10d96db2](https://github.com/keystonejs/keystone/commit/10d96db2): | ||
@@ -141,3 +175,3 @@ - Restructure internal code | ||
- Updated dependencies [98c02a46](https://github.com/keystonejs/keystone-5/commit/98c02a46): | ||
- Updated dependencies [98c02a46](https://github.com/keystonejs/keystone/commit/98c02a46): | ||
- @keystone-alpha/utils@2.0.0 | ||
@@ -147,7 +181,7 @@ | ||
- [patch][1f0bc236](https://github.com/keystonejs/keystone-5/commit/1f0bc236): | ||
- [patch][1f0bc236](https://github.com/keystonejs/keystone/commit/1f0bc236): | ||
- Update the package.json author field to "The Keystone Development Team" | ||
- [patch][9534f98f](https://github.com/keystonejs/keystone-5/commit/9534f98f): | ||
- [patch][9534f98f](https://github.com/keystonejs/keystone/commit/9534f98f): | ||
@@ -154,0 +188,0 @@ - Add README.md to package |
@@ -84,3 +84,3 @@ const { getType, pick, defaultObj, intersection } = require('@keystonejs/utils'); | ||
const type = getType(access); | ||
if (!['Boolean', 'Function', 'Object'].includes(type)) { | ||
if (!['Boolean', 'AsyncFunction', 'Function', 'Object'].includes(type)) { | ||
throw new Error( | ||
@@ -115,7 +115,7 @@ `Expected a Boolean, Object, or Function for custom access, but got ${type}` | ||
if (accessType === 'create') { | ||
if (!['Boolean', 'Function'].includes(type)) { | ||
if (!['Boolean', 'AsyncFunction', 'Function'].includes(type)) { | ||
return `Expected a Boolean, or Function for ${listKey}.access.${accessType}, but got ${type}. (NOTE: 'create' cannot have a Declarative access control config)`; | ||
} | ||
} else { | ||
if (!['Object', 'Boolean', 'Function'].includes(type)) { | ||
if (!['Object', 'Boolean', 'AsyncFunction', 'Function'].includes(type)) { | ||
return `Expected a Boolean, Object, or Function for ${listKey}.access.${accessType}, but got ${type}`; | ||
@@ -148,3 +148,3 @@ } | ||
(type, accessType) => { | ||
if (!['Boolean', 'Function'].includes(type)) { | ||
if (!['Boolean', 'AsyncFunction', 'Function'].includes(type)) { | ||
return `Expected a Boolean or Function for ${listKey}.fields.${fieldKey}.access.${accessType}, but got ${type}. (NOTE: Fields cannot have declarative access control config)`; | ||
@@ -157,3 +157,3 @@ } | ||
validateCustomAccessControl({ access, authentication = {} }) { | ||
async validateCustomAccessControl({ access, authentication = {} }) { | ||
// Either a boolean or an object describing a where clause | ||
@@ -164,3 +164,3 @@ let result; | ||
} else { | ||
result = access({ authentication: authentication.item ? authentication : {} }); | ||
result = await access({ authentication: authentication.item ? authentication : {} }); | ||
} | ||
@@ -177,3 +177,3 @@ const type = getType(result); | ||
validateListAccessControl({ | ||
async validateListAccessControl({ | ||
access, | ||
@@ -193,3 +193,3 @@ listKey, | ||
} else { | ||
result = access[operation]({ | ||
result = await access[operation]({ | ||
authentication: authentication.item ? authentication : {}, | ||
@@ -223,3 +223,3 @@ listKey, | ||
validateFieldAccessControl({ | ||
async validateFieldAccessControl({ | ||
access, | ||
@@ -240,3 +240,3 @@ listKey, | ||
} else { | ||
result = access[operation]({ | ||
result = await access[operation]({ | ||
authentication: authentication.item ? authentication : {}, | ||
@@ -265,3 +265,3 @@ listKey, | ||
validateAuthAccessControl({ access, listKey, authentication = {}, gqlName }) { | ||
async validateAuthAccessControl({ access, listKey, authentication = {}, gqlName }) { | ||
const operation = 'auth'; | ||
@@ -273,3 +273,3 @@ // Either a boolean or an object describing a where clause | ||
} else { | ||
result = access[operation]({ | ||
result = await access[operation]({ | ||
authentication: authentication.item ? authentication : {}, | ||
@@ -276,0 +276,0 @@ listKey, |
{ | ||
"name": "@keystonejs/access-control", | ||
"description": "KeystoneJS Access Control parsing and validating utilities.", | ||
"version": "5.2.0", | ||
"version": "6.0.0", | ||
"author": "The KeystoneJS Development Team", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
@@ -7,2 +7,4 @@ <!--[meta] | ||
[![View changelog](https://img.shields.io/badge/changelogs.xyz-Explore%20Changelog-brightgreen)](https://changelogs.xyz/@keystonejs/access-control) | ||
This package is an internal helper package used by Keystone to parse and validate access control expressions. | ||
@@ -9,0 +11,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17929
14