-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bypass
ui.isAccessAllowed
for sudo contexts (#6955)
* Bypass `ui.isAccessAllowed` for the admin meta query for sudo contexts * Remove debugger * Unused import * Fix test on postgres Co-authored-by: Daniel Cousens <413395+dcousens@users.noreply.github.com>
- @keystone-ui/tooltip@6.0.2
- @keystone-ui/tooltip@6.0.1
- @keystone-ui/tooltip@6.0.0
- @keystone-ui/tooltip@5.0.0
- @keystone-ui/toast@6.0.2
- @keystone-ui/toast@6.0.1
- @keystone-ui/toast@6.0.0
- @keystone-ui/toast@5.0.0
- @keystone-ui/segmented-control@7.0.3
- @keystone-ui/segmented-control@7.0.2
- @keystone-ui/segmented-control@7.0.1
- @keystone-ui/segmented-control@7.0.0
- @keystone-ui/segmented-control@6.1.0
- @keystone-ui/segmented-control@6.0.0
- @keystone-ui/segmented-control@0.0.0-rc-20230220024700
- @keystone-ui/segmented-control@0.0.0-rc-20230214225011
- @keystone-ui/popover@6.0.2
- @keystone-ui/popover@6.0.1
- @keystone-ui/popover@6.0.0
- @keystone-ui/popover@5.0.1
- @keystone-ui/popover@5.0.0
- @keystone-ui/pill@7.0.2
- @keystone-ui/pill@7.0.1
- @keystone-ui/pill@7.0.0
- @keystone-ui/pill@6.0.0
- @keystone-ui/options@6.0.2
- @keystone-ui/options@6.0.1
- @keystone-ui/options@6.0.0
- @keystone-ui/options@5.0.0
- @keystone-ui/notice@6.0.2
- @keystone-ui/notice@6.0.1
- @keystone-ui/notice@6.0.0
- @keystone-ui/notice@5.0.0
- @keystone-ui/modals@6.0.3
- @keystone-ui/modals@6.0.2
- @keystone-ui/modals@6.0.1
- @keystone-ui/modals@6.0.0
- @keystone-ui/modals@5.0.0
- @keystone-ui/loading@6.0.2
- @keystone-ui/loading@6.0.1
- @keystone-ui/loading@6.0.0
- @keystone-ui/loading@5.0.0
- @keystone-ui/icons@6.0.2
- @keystone-ui/icons@6.0.1
- @keystone-ui/icons@6.0.0
- @keystone-ui/icons@5.0.0
- @keystone-ui/fields@7.2.0
- @keystone-ui/fields@7.1.2
- @keystone-ui/fields@7.1.1
- @keystone-ui/fields@7.1.0
- @keystone-ui/fields@7.0.0
- @keystone-ui/fields@6.1.0
- @keystone-ui/fields@6.0.1
- @keystone-ui/fields@6.0.0
- @keystone-ui/fields@0.0.0-rc-20230412064346
- @keystone-ui/fields@0.0.0-rc-20230412063326
- @keystone-ui/fields@0.0.0-rc-20230330050032
- @keystone-ui/fields@0.0.0-rc-20230329060432
- @keystone-ui/fields@0.0.0-rc-20230328041955
- @keystone-ui/core@5.0.2
- @keystone-ui/core@5.0.1
- @keystone-ui/core@5.0.0
- @keystone-ui/core@4.0.0
- @keystone-ui/button@7.0.2
- @keystone-ui/button@7.0.1
- @keystone-ui/button@7.0.0
- @keystone-ui/button@6.0.0
- @keystone-next/session-store-redis@9.0.0
- @keystone-next/keystone@29.0.0
- @keystone-next/fields-document@14.0.0
- @keystone-next/document-renderer@5.0.0
- @keystone-next/cloudinary@12.0.0
- @keystone-next/auth@37.0.0
- @keystone-6/session-store-redis@4.0.1
- @keystone-6/session-store-redis@4.0.0
- @keystone-6/session-store-redis@3.0.0
- @keystone-6/session-store-redis@2.0.0
- @keystone-6/session-store-redis@1.0.0
- @keystone-6/fields-document@9.1.1
- @keystone-6/fields-document@9.0.0
- @keystone-6/fields-document@8.0.2
- @keystone-6/fields-document@8.0.1
- @keystone-6/fields-document@8.0.0
- @keystone-6/fields-document@7.0.0
- @keystone-6/fields-document@6.0.0
- @keystone-6/fields-document@5.0.2
- @keystone-6/fields-document@5.0.1
- @keystone-6/fields-document@5.0.0
- @keystone-6/fields-document@4.1.2
- @keystone-6/fields-document@4.1.1
- @keystone-6/fields-document@4.1.0
- @keystone-6/fields-document@4.0.1
- @keystone-6/fields-document@4.0.0
- @keystone-6/fields-document@3.0.0
- @keystone-6/fields-document@2.0.1
- @keystone-6/fields-document@2.0.0
- @keystone-6/fields-document@1.0.1
- @keystone-6/fields-document@1.0.0
- @keystone-6/fields-document@0.0.0-rc-20250225040142
- @keystone-6/fields-document@0.0.0-rc-20250224061709
- @keystone-6/fields-document@0.0.0-rc-20250224060915
- @keystone-6/fields-document@0.0.0-rc-20250224052246
- @keystone-6/fields-document@0.0.0-rc-20250217014122
- @keystone-6/fields-document@0.0.0-rc-20250212061115
- @keystone-6/fields-document@0.0.0-rc-20250210004303
- @keystone-6/fields-document@0.0.0-rc-20230412064346
- @keystone-6/fields-document@0.0.0-rc-20230412063326
- @keystone-6/fields-document@0.0.0-rc-20230330050032
- @keystone-6/fields-document@0.0.0-rc-20230329060432
- @keystone-6/fields-document@0.0.0-rc-20230220024700
- @keystone-6/fields-document@0.0.0-rc-20230214225011
- @keystone-6/fields-document@0.0.0-rc-20221013033655
- @keystone-6/document-renderer@1.1.2
- @keystone-6/document-renderer@1.1.1
- @keystone-6/document-renderer@1.1.0
- @keystone-6/document-renderer@1.0.0
- @keystone-6/core@6.4.0
- @keystone-6/core@6.3.1
- @keystone-6/core@6.3.0
- @keystone-6/core@6.1.0
- @keystone-6/core@6.0.0
- @keystone-6/core@5.8.0
- @keystone-6/core@5.7.2
- @keystone-6/core@5.7.1
- @keystone-6/core@5.7.0
- @keystone-6/core@5.6.0
- @keystone-6/core@5.5.1
- @keystone-6/core@5.5.0
- @keystone-6/core@5.4.0
- @keystone-6/core@5.3.2
- @keystone-6/core@5.3.1
- @keystone-6/core@5.3.0
- @keystone-6/core@5.2.0
- @keystone-6/core@5.1.0
- @keystone-6/core@5.0.0
- @keystone-6/core@4.0.1
- @keystone-6/core@4.0.0
- @keystone-6/core@3.1.3
- @keystone-6/core@3.1.2
- @keystone-6/core@3.1.1
- @keystone-6/core@3.1.0
- @keystone-6/core@3.0.2
- @keystone-6/core@3.0.1
- @keystone-6/core@3.0.0
- @keystone-6/core@2.3.1
- @keystone-6/core@2.3.0
- @keystone-6/core@2.2.0
- @keystone-6/core@2.1.0
- @keystone-6/core@2.0.0
- @keystone-6/core@1.1.1
- @keystone-6/core@1.1.0
- @keystone-6/core@1.0.1
- @keystone-6/core@1.0.0
- @keystone-6/core@0.0.0-rc-20250225040142
- @keystone-6/core@0.0.0-rc-20250224061709
- @keystone-6/core@0.0.0-rc-20250224060915
- @keystone-6/core@0.0.0-rc-20250224052246
- @keystone-6/core@0.0.0-rc-20250217014122
- @keystone-6/core@0.0.0-rc-20250212061115
- @keystone-6/core@0.0.0-rc-20250210004303
- @keystone-6/core@0.0.0-rc-20240429035832
- @keystone-6/core@0.0.0-rc-20240419043059
- @keystone-6/core@0.0.0-rc-20230523070754
- @keystone-6/core@0.0.0-rc-20230512055539
- @keystone-6/core@0.0.0-rc-20230412064346
- @keystone-6/core@0.0.0-rc-20230412063326
- @keystone-6/core@0.0.0-rc-20230330050032
- @keystone-6/core@0.0.0-rc-20230329060432
- @keystone-6/core@0.0.0-rc-20230328041955
- @keystone-6/core@0.0.0-rc-20230220024700
- @keystone-6/core@0.0.0-rc-20230214225011
- @keystone-6/core@0.0.0-rc-20221013033655
- @keystone-6/cloudinary@8.0.0
- @keystone-6/cloudinary@7.0.3
- @keystone-6/cloudinary@7.0.2
- @keystone-6/cloudinary@7.0.1
- @keystone-6/cloudinary@7.0.0
- @keystone-6/cloudinary@6.0.0
- @keystone-6/cloudinary@5.0.1
- @keystone-6/cloudinary@5.0.0
- @keystone-6/cloudinary@4.0.1
- @keystone-6/cloudinary@4.0.0
- @keystone-6/cloudinary@3.0.0
- @keystone-6/cloudinary@2.0.0
- @keystone-6/cloudinary@1.0.0
- @keystone-6/cloudinary@0.0.0-rc-20250225040142
- @keystone-6/cloudinary@0.0.0-rc-20250224061709
- @keystone-6/cloudinary@0.0.0-rc-20250224060915
- @keystone-6/cloudinary@0.0.0-rc-20250224052246
- @keystone-6/cloudinary@0.0.0-rc-20250217014122
- @keystone-6/cloudinary@0.0.0-rc-20250212061115
- @keystone-6/cloudinary@0.0.0-rc-20250210004303
- @keystone-6/cloudinary@0.0.0-rc-20230220024700
- @keystone-6/cloudinary@0.0.0-rc-20230214225011
- @keystone-6/cloudinary@0.0.0-rc-20221013033655
- @keystone-6/auth@8.1.0
- @keystone-6/auth@8.0.0
- @keystone-6/auth@7.0.3
- @keystone-6/auth@7.0.2
- @keystone-6/auth@7.0.1
- @keystone-6/auth@7.0.0
- @keystone-6/auth@6.0.0
- @keystone-6/auth@5.0.1
- @keystone-6/auth@5.0.0
- @keystone-6/auth@4.0.1
- @keystone-6/auth@4.0.0
- @keystone-6/auth@3.0.0
- @keystone-6/auth@2.0.0
- @keystone-6/auth@1.0.2
- @keystone-6/auth@1.0.1
- @keystone-6/auth@1.0.0
- @keystone-6/auth@0.0.0-rc-20250225040142
- @keystone-6/auth@0.0.0-rc-20250224061709
- @keystone-6/auth@0.0.0-rc-20250224060915
- @keystone-6/auth@0.0.0-rc-20250224052246
- @keystone-6/auth@0.0.0-rc-20250217014122
- @keystone-6/auth@0.0.0-rc-20250212061115
- @keystone-6/auth@0.0.0-rc-20250210004303
- @keystone-6/auth@0.0.0-rc-20230220024700
- @keystone-6/auth@0.0.0-rc-20230214225011
- @keystone-6/auth@0.0.0-rc-20221013033655
- create-keystone-app@10.0.3
- create-keystone-app@10.0.2
- create-keystone-app@10.0.1
- create-keystone-app@10.0.0
- create-keystone-app@0.0.0-rc-20250225040142
- create-keystone-app@0.0.0-rc-20250224061709
- create-keystone-app@0.0.0-rc-20250224060915
- create-keystone-app@0.0.0-rc-20250224052246
- create-keystone-app@0.0.0-rc-20250217014122
- create-keystone-app@0.0.0-rc-20250212061115
- create-keystone-app@0.0.0-rc-20250210004303
- 2025-02-24
- 2024-11-07
- 2024-08-28
- 2024-08-09
- 2024-04-30
- 2024-04-16
- 2024-04-02
- 2024-02-07
- 2023-12-04
- 2023-09-27
- 2023-09-19
- 2023-08-15
- 2023-08-08
- 2023-08-01
- 2023-06-19
- 2023-06-08
- 2023-05-25
- 2023-04-27
- 2023-03-02
- 2023-02-23
- 2022-12-07
- 2022-12-06
- 2022-11-25
- 2022-11-21
- 2022-11-18
- 2022-11-17
- 2022-11-03
- 2022-10-19
- 2022-10-19-afternoon
- 2022-10-18
- 2022-09-20
- 2022-09-15
- 2022-08-19
- 2022-07-14
- 2022-06-30
- 2022-06-09
- 2022-05-12
- 2022-03-25
- 2022-01-10
- 2021-12-22
- 2021-12-01
- 2021-11-24
Showing
5 changed files
with
120 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@keystone-next/keystone': patch | ||
--- | ||
|
||
Fixed `ui.isAccessAllowed` not being respected in the admin meta query when no session strategy was defined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@keystone-next/keystone': patch | ||
--- | ||
|
||
The admin meta query now bypasses `ui.isAccessAllowed` for sudo contexts. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
import { list } from '@keystone-next/keystone'; | ||
import { text } from '@keystone-next/keystone/fields'; | ||
import { staticAdminMetaQuery } from '@keystone-next/keystone/src/admin-ui/admin-meta-graphql'; | ||
import { setupTestRunner } from '@keystone-next/keystone/testing'; | ||
import { apiTestConfig, dbProvider } from './utils'; | ||
|
||
const runner = setupTestRunner({ | ||
config: apiTestConfig({ | ||
ui: { | ||
isAccessAllowed: () => false, | ||
}, | ||
lists: { User: list({ fields: { name: text() } }) }, | ||
}), | ||
}); | ||
|
||
test( | ||
'non-sudo context does not bypass isAccessAllowed for admin meta', | ||
runner(async ({ context }) => { | ||
const res = await context.exitSudo().graphql.raw({ query: staticAdminMetaQuery }); | ||
expect(res).toMatchInlineSnapshot(` | ||
Object { | ||
"data": null, | ||
"errors": Array [ | ||
[GraphQLError: Access denied], | ||
], | ||
} | ||
`); | ||
}) | ||
); | ||
|
||
test( | ||
'sudo context bypasses isAccessAllowed for admin meta', | ||
runner(async ({ context }) => { | ||
const data = await context.sudo().graphql.run({ query: staticAdminMetaQuery }); | ||
expect(data).toEqual({ | ||
keystone: { | ||
__typename: 'KeystoneMeta', | ||
adminMeta: { | ||
__typename: 'KeystoneAdminMeta', | ||
enableSessionItem: false, | ||
enableSignout: false, | ||
lists: [ | ||
{ | ||
__typename: 'KeystoneAdminUIListMeta', | ||
description: null, | ||
fields: [ | ||
{ | ||
__typename: 'KeystoneAdminUIFieldMeta', | ||
customViewsIndex: null, | ||
fieldMeta: { | ||
kind: 'cuid', | ||
}, | ||
itemView: { | ||
fieldMode: 'hidden', | ||
}, | ||
label: 'Id', | ||
path: 'id', | ||
search: null, | ||
viewsIndex: 0, | ||
}, | ||
{ | ||
__typename: 'KeystoneAdminUIFieldMeta', | ||
customViewsIndex: null, | ||
fieldMeta: { | ||
defaultValue: '', | ||
displayMode: 'input', | ||
isNullable: false, | ||
shouldUseModeInsensitive: dbProvider === 'postgresql', | ||
validation: { | ||
isRequired: false, | ||
length: { | ||
max: null, | ||
min: null, | ||
}, | ||
match: null, | ||
}, | ||
}, | ||
itemView: { | ||
fieldMode: 'edit', | ||
}, | ||
label: 'Name', | ||
path: 'name', | ||
search: dbProvider === 'postgresql' ? 'insensitive' : 'default', | ||
viewsIndex: 1, | ||
}, | ||
], | ||
initialColumns: ['name'], | ||
initialSort: null, | ||
itemQueryName: 'User', | ||
key: 'User', | ||
label: 'Users', | ||
labelField: 'name', | ||
listQueryName: 'Users', | ||
pageSize: 50, | ||
path: 'users', | ||
plural: 'Users', | ||
singular: 'User', | ||
}, | ||
], | ||
}, | ||
}, | ||
}); | ||
}) | ||
); |