-
Notifications
You must be signed in to change notification settings - Fork 10.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(editor): Handle permission edge cases (empty scopes) #7723
Conversation
userScopes: ScopeLevels, | ||
options?: HasScopeOptions, | ||
): boolean; | ||
export function hasScope( | ||
scope: Scope | Scope[], | ||
userScopes: Pick<ScopeLevels, 'global'>, | ||
options?: HasScopeOptions, | ||
): boolean; | ||
export function hasScope( | ||
scope: Scope | Scope[], | ||
userScopes: Omit<ScopeLevels, 'resource'>, | ||
options?: HasScopeOptions, | ||
): boolean; | ||
export function hasScope( | ||
scope: Scope | Scope[], | ||
userScopes: Pick<ScopeLevels, 'global'> & Partial<ScopeLevels>, | ||
userScopes: Partial<ScopeLevels>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was done so that to use the resource scope you'd need to provide the global and project scopes as well. If you want to use the project scope you need to provide the global scope as well. This way there's no way to accidentally only check just the resource level scope or something similar. I tried to do it in a more succinct type but typescript wasn't liking it 🤷.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, sorry, I totally overlooked that and great that you thought of this.
After all I didn't change much on the point but let me know if you're fine with it
const userScopeSet = new Set([ | ||
...userScopes.global, | ||
...(userScopes.project ?? []), | ||
...(userScopes.resource ?? []), | ||
]); | ||
const scopeLevelOrder: ScopeLevelOrder = ['global', 'project', 'resource']; | ||
const userScopeSet = new Set(scopeLevelOrder.flatMap((level) => userScopes[level] ?? [])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The order here doesn't matter since it's a set.
4 flaky tests on run #2922 ↗︎
Details:
6-code-node.cy.ts • 2 flaky tests
28-resource-mapper.cy.ts • 2 flaky tests
Review all test suite changes for PR #7723 ↗︎ |
✅ All Cypress E2E specs passed |
* master: (27 commits) fix: Include cypress TypeScript types in /cypress folder (no-changelog) (#7746) refactor(core): Stop reporting to Sentry `NodeApiError` outside 500 range (no-changelog) (#7753) fix(core): Guard against node not found on cancelling test webhook (#7750) fix(JotForm Trigger Node): Fix iteration on form loader (#7751) refactor(core): Stop reporting to Sentry unknown cred on mapping (no-changelog) (#7752) feat(core): Coordinate manual workflow activation and deactivation in multi-main scenario (#7643) ci: Fix "Release: Create Pull Request" workflow fix(editor): Fix Admin panel icon in the sidebar for cloud deployments (no-changelog) (#7738) fix(editor): Remove `n8nHooksNext` flag (no-changelog) (#7733) fix(editor): Show v1 banner dismiss button if owner (#7722) fix(GitHub Node): Fix issue preventing file edits on branches (#7734) fix(core): Fix all dependency versions for backend packages (no-changelog) (#7745) refactor(core): Convert dynamic node-parameter routes to a decorated controller (no-changelog) (#7284) refactor: Stop reporting to Sentry Facebook multi-webhook error (no-changelog) (#7743) refactor(core): Stop reporting to Sentry unrecognized node errors (no-changelog) (#7728) fix(core): Account for non-ASCII chars in filename on binary data download (#7742) ci: Fix DB tests and Workflow tests (no-changelog) (#7741) refactor: Extract Invitation routes to InvitationController (no-changelog) (#7726) fix(editor): Handle permission edge cases (empty scopes) (#7723) ci: Skip the regularly failing tests in 2-credentials.cy.ts (no-changelog) (#7736) ...
# [1.18.0](https://github.com/n8n-io/n8n/compare/n8n@1.17.0...n8n@1.18.0) (2023-11-22) ### Bug Fixes * **core:** Account for non-ASCII chars in filename on binary data download ([#7742](#7742)) ([b4ebb1a](b4ebb1a)) * **core:** Correct permissions for getstatus ([#7724](#7724)) ([f96c1d2](f96c1d2)) * **core:** Ensure failed executions are saved in queue mode ([#7744](#7744)) ([b7c5c74](b7c5c74)) * **core:** Guard against node not found on cancelling test webhook ([#7750](#7750)) ([6be453b](6be453b)) * **editor:** Handle permission edge cases (empty scopes) ([#7723](#7723)) ([e2ffd39](e2ffd39)) * **editor:** Make sure LineController is registered with chart.js ([#7730](#7730)) ([ebee1a5](ebee1a5)) * **editor:** Move workerview entry into settings menu ([#7761](#7761)) ([366cd67](366cd67)) * **editor:** Only show push to git menu item to owners ([#7766](#7766)) ([0d3d33d](0d3d33d)) * **editor:** Show v1 banner dismiss button if owner ([#7722](#7722)) ([44d3b3e](44d3b3e)) * **editor:** Use project diagram icon for worker view ([#7764](#7764)) ([ff0b651](ff0b651)) * **editor:** Validate user info before submiting ([#7608](#7608)) ([2064f7f](2064f7f)) * **GitHub Node:** Fix issue preventing file edits on branches ([#7734](#7734)) ([ce002a6](ce002a6)) * **Google Sheets Node:** Check for `null` before destructuring ([#7729](#7729)) ([5d4a52d](5d4a52d)) * **Item Lists Node:** Don't check same type in remove duplicates operation ([#7678](#7678)) ([4f30764](4f30764)) * **JotForm Trigger Node:** Fix iteration on form loader ([#7751](#7751)) ([82f3202](82f3202)) ### Features * Add Creator hub link to Templates page ([#7721](#7721)) ([4dbae0e](4dbae0e)) * **core:** Coordinate manual workflow activation and deactivation in multi-main scenario ([#7643](#7643)) ([4c40825](4c40825)) * **editor:** Add node context menu ([#7620](#7620)) ([8d12c1a](8d12c1a)) * **editor:** Node IO filter ([#7503](#7503)) ([1881765](1881765)) Co-authored-by: ivov <ivov@users.noreply.github.com>
Got released with |
No description provided.