Skip to content
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

feat(editor): Add routing middleware, permission checks, RBAC store, RBAC component #7702

Merged
merged 27 commits into from
Nov 23, 2023

Conversation

alexgrozav
Copy link
Contributor

Github issue / Community forum post (link here to close automatically):

@alexgrozav alexgrozav added the n8n team Authored by the n8n team label Nov 14, 2023
@alexgrozav alexgrozav self-assigned this Nov 14, 2023

let valid: boolean;
if (mode === 'allOf') {
valid = options.features.every((feature) => settingsStore.isEnterpriseFeatureEnabled(feature));
Copy link
Contributor

@cstuncsik cstuncsik Nov 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a nitpick (coming from my functional programming self :))
it could be pointfree (same below)

Suggested change
valid = options.features.every((feature) => settingsStore.isEnterpriseFeatureEnabled(feature));
valid = options.features.every(settingsStore.isEnterpriseFeatureEnabled);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

resourceId: string;
},
) {
if (!scopesByResourceId.value[context.resourceType][context.resourceId]) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe you could save these long object accesses to a variable to avoid the repetition

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

export function inferResourceTypeFromRoute(to: RouteLocationNormalized): Resource | undefined {
const routeParts = to.path.split('/');

switch (true) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could reduce some repetition with just using an object and a forOf loop

const hash = {
    workflow: 'workflows',
    sourceControl: 'source-control',
}

for (const resource of hash) {
    if(routeParts.includes(hash[resource])) {
        return resource
    }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome idea! Thanks!

cstuncsik
cstuncsik previously approved these changes Nov 14, 2023
Copy link
Contributor

@cstuncsik cstuncsik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! I like the middlewares
Left some coding style nitpicks but apart from that it looks good

Copy link
Contributor

⚠️ Some Cypress E2E specs are failing, please fix them before merging

Copy link

cypress bot commented Nov 14, 2023

2 flaky tests on run #3000 ↗︎

0 282 5 0 Flakiness 2

Details:

🌳 🖥️ browsers:node18.12.0-chrome107 🤖 alexgrozav 🗃️ e2e/*
Project: n8n Commit: 1eba64028f
Status: Passed Duration: 05:47 💡
Started: Nov 23, 2023 11:12 AM Ended: Nov 23, 2023 11:18 AM
Flakiness  12-canvas.cy.ts • 1 flaky test

View Output Video

Test Artifacts
Canvas Node Manipulation and Navigation > should add merge node and test connections Screenshots Video
Flakiness  26-resource-locator.cy.ts • 1 flaky test

View Output Video

Test Artifacts
Resource Locator > should retrieve list options when other params throw errors Screenshots Video

Review all test suite changes for PR #7702 ↗︎

@alexgrozav alexgrozav changed the title feat(editor): Add routing middleware, RBAC store, RBAC component feat(editor): Add routing middleware, permission checks, RBAC store, RBAC component Nov 15, 2023
Comment on lines 122 to 127
const defaultScopes: Scope[] = [];
if (isInstanceOwner(user)) {
defaultScopes.push('tag:delete');
}

useRBACStore().setGlobalScopes(user.globalScopes || defaultScopes);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cstuncsik This code needs to be updated once Back End returns globalScopes.

cstuncsik
cstuncsik previously approved these changes Nov 15, 2023
Copy link
Contributor

⚠️ Some Cypress E2E specs are failing, please fix them before merging

cstuncsik
cstuncsik previously approved these changes Nov 21, 2023
Copy link
Contributor

⚠️ Some Cypress E2E specs are failing, please fix them before merging

cstuncsik
cstuncsik previously approved these changes Nov 21, 2023
Copy link
Contributor

✅ All Cypress E2E specs passed

cstuncsik
cstuncsik previously approved these changes Nov 22, 2023
Copy link
Contributor

✅ All Cypress E2E specs passed

Copy link
Contributor

✅ All Cypress E2E specs passed

@alexgrozav alexgrozav merged commit 67a8891 into master Nov 23, 2023
19 checks passed
@alexgrozav alexgrozav deleted the pay-1005-front-end-permissions-overhaul branch November 23, 2023 11:22
@github-actions github-actions bot mentioned this pull request Nov 29, 2023
ivov added a commit that referenced this pull request Nov 29, 2023
#
[1.19.0](https://github.com/n8n-io/n8n/compare/n8n@1.18.0...n8n@1.19.0)
(2023-11-29)


### Bug Fixes

* **core:** Ensure member and admin cannot be promoted to owner
([#7830](#7830))
([9b87a59](9b87a59)),
closes
[/linear.app/n8n/issue/PAY-985/add-user-role-modification-endpoint#comment-62355f6](https://github.com//linear.app/n8n/issue/PAY-985/add-user-role-modification-endpoint/issues/comment-62355f6)
* **core:** Prevent error messages due to statistics about data loading
([#7824](#7824))
([847f6ac](847f6ac))
* **core:** Tighten checks for multi-main setup usage
([#7788](#7788))
([fdb2c18](fdb2c18))
* **core:** Use AbortController to notify nodes to abort execution
([#6141](#6141))
([d2c18c5](d2c18c5))
* **editor:** Add telemetry to workflow history
([#7811](#7811))
([d497041](d497041))
* **editor:** Allow owners and admins to share workflows and credentials
they don't own ([#7833](#7833))
([3ab3ec9](3ab3ec9))
* **editor:** Disable context menu actions in read-only mode
([#7789](#7789))
([902beff](902beff))
* **editor:** Fix cloud plan data loading on instance
([#7841](#7841))
([8b99384](8b99384))
* **editor:** Fix credential icon for old node type version
([#7843](#7843))
([4074107](4074107))
* **editor:** Fix icon for unknown node type
([#7842](#7842))
([28ac5a7](28ac5a7))
* **editor:** Fix mouse position in workflow previews
([#7853](#7853))
([c063398](c063398))
* **editor:** Show nice error when environment is not set up
([#7778](#7778))
([5835e05](5835e05))
* **editor:** Suppress dev server websocket messages in workflow view
([#7808](#7808))
([685ffd7](685ffd7))
* **Google Sheets Node:** Read operation execute for each item
([#7800](#7800))
([d548872](d548872))
* **HTTP Request Node:** Enable expressions for binary input data fields
([#7782](#7782))
([6208af0](6208af0))
* **Microsoft SQL Node:** Prevent double escaping table name
([#7801](#7801))
([73ec753](73ec753))


### Features

* Add AI tool building capabilities
([#7336](#7336))
([87def60](87def60))
* Add initial scope checks via decorators
([#7737](#7737))
([a37f1cb](a37f1cb))
* Ado 1296 spike credential setup in templates
([#7786](#7786))
([aae45b0](aae45b0))
* **core:** Add Support for custom CORS origins for webhooks
([#7455](#7455))
([99a9ea4](99a9ea4))
* **core:** Allow user role modification
([#7797](#7797))
([7a86d36](7a86d36))
* **core:** Set up endpoint for all existing roles with license flag
([#7834](#7834))
([2356fb0](2356fb0))
* **editor:** Add node name and version to NDV node settings
([#7731](#7731))
([da85198](da85198))
* **editor:** Add routing middleware, permission checks, RBAC store,
RBAC component ([#7702](#7702))
([67a8891](67a8891))
* **editor:** Replace middleware for Role checks with Scope checks
([#7847](#7847))
([72852a6](72852a6))
* **editor:** Show avatars for users currently working on the same
workflow ([#7763](#7763))
([77bc8ec](77bc8ec))
* **Notion Node:** Option to simplify output in getChildBlocks operation
([#7791](#7791))
([d667bca](d667bca))
* **Slack Node:** Add support for getting the profile of a user
([#7829](#7829))
([90bb6ba](90bb6ba))

Co-authored-by: ivov <ivov@users.noreply.github.com>
@janober
Copy link
Member

janober commented Dec 1, 2023

Got released with n8n@1.19.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
n8n team Authored by the n8n team Released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants