-
Notifications
You must be signed in to change notification settings - Fork 7.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
feat(API): Implement users account quota guards #6434
feat(API): Implement users account quota guards #6434
Conversation
Signed-off-by: Oleg Ivaniv <me@olegivaniv.com>
Signed-off-by: Oleg Ivaniv <me@olegivaniv.com>
Great PR! Please pay attention to the following items before merging: Files matching
Files matching
Make sure to check off this list before asking for review. |
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.
General comments:
- We are aiming to have a 1-user flavor of UM, rather than to check whether UM is enabled or disabled. Also remember that in v1 there will be no explicit checks for UM as it will always be enabled. Hence we should focus the checks on the users quota.
- Let's aim to add functionality to services or repositories instead of
UserManagementHelper
. TheUserManagement
dir was created when UM was only a feature, but by now UM has become an integral part of the BE - so over time that dir and its helpers should be removed.isInstanceOwner
in particular could beisOwner
is theUserRepository
. - Can we centralize the check by adding it to
resolveJwtContent
instead? Or was there a reason that this didn't work or shouldn't be done? - We are throwing 400 but I wonder if 401 would be more appropriate, since members are unauthorized in 1-user UM.
- For endpoints protected by this new check, I wonder if we could create a Nest-style decorator auth guard. We should have most of the setup for this already.
packages/cli/src/License.ts
Outdated
getUsersLimit(): number { | ||
const limit = this.getFeatureValue(LICENSE_QUOTAS.USERS_LIMIT); | ||
|
||
return (limit ?? -1) as number; | ||
} |
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.
An overload on getFeatureValue
would be nice, to have proper typing.
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.
Thanks @ivov! I've addressed all your points but 5. Moving the check to central place(resolveJwtContent
) simplified the logic so IMO there's no need for the decorator. Can you have another look, please?
- Getting `usersQuota` from `Settings` repo - Revert `isUserManagementEnabled` helper - Fix FE listing of users Signed-off-by: Oleg Ivaniv <me@olegivaniv.com>
Signed-off-by: Oleg Ivaniv <me@olegivaniv.com>
Signed-off-by: Oleg Ivaniv <me@olegivaniv.com>
Signed-off-by: Oleg Ivaniv <me@olegivaniv.com>
…s-having-1-as-users-quota
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #6434 +/- ##
==========================================
- Coverage 28.92% 28.87% -0.06%
==========================================
Files 3069 3070 +1
Lines 188355 188417 +62
Branches 20892 20899 +7
==========================================
- Hits 54488 54399 -89
- Misses 132987 133135 +148
- Partials 880 883 +3
☔ View full report in Codecov by Sentry. |
Signed-off-by: Oleg Ivaniv <me@olegivaniv.com>
Signed-off-by: Oleg Ivaniv <me@olegivaniv.com>
Signed-off-by: Oleg Ivaniv <me@olegivaniv.com>
@ivov Addressed your comments. Can you re-review, please? |
1 flaky tests on run #1424 ↗︎
Details:
cypress/e2e/24-ndv-paired-item.cy.ts • 1 flaky test
This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. |
…s-having-1-as-users-quota Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> # Conflicts: # packages/cli/src/Ldap/helpers.ts # packages/cli/src/Server.ts # packages/cli/src/middlewares/auth.ts # packages/cli/src/push/index.ts # packages/cli/src/sso/saml/samlHelpers.ts # packages/editor-ui/src/router.ts # packages/editor-ui/src/stores/settings.store.ts # packages/editor-ui/src/views/SettingsUsersView.vue # packages/workflow/src/Interfaces.ts
Signed-off-by: Oleg Ivaniv <me@olegivaniv.com>
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.
Still need to test it locally.
refactor: License typings suggestions
Co-authored-by: Iván Ovejero <ivov.src@gmail.com>
Co-authored-by: Iván Ovejero <ivov.src@gmail.com>
Signed-off-by: Oleg Ivaniv <me@olegivaniv.com>
Signed-off-by: Oleg Ivaniv <me@olegivaniv.com>
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.
Thanks for addressing everything! I'll test it out later today :)
Thanks for the thorough review <3 Let me know if I can help with anything |
✅ All Cypress E2E specs passed |
Tested these cases, let me know if I'm missing any, else let's merge! When having
Regular case:
|
* master: ci!: Drop support for Node.js 16. Add initial support for Node.js 20 (#6649) feat(API): Implement users account quota guards (#6434) feat(OpenAI Node): Update max token limit to support newer model limits (#6644) ci: Run checklist job as a separate workflow (no-changelog) (#6645) fix(HTTP Request Node): Cleanup circular references in response (#6590) fix(Postgres Node): Upsert does not fetch columns when schema other then public (#6643) fix(core): Update docker compose setup for V1 images (#6642) refactor: Delete unnecessary interface re-exports from core, and delete unused code in nodes-base (no-changelog) (#6631) fix(core): Reduce memory consumption on `BinaryDataManager.init` (#6633) fix(editor): Implement simple view for templates experiment (no-changelog) (#6637) # Conflicts: # packages/editor-ui/src/stores/settings.store.ts
* ADO-814-trial-banner: ✔️ Updated callout component snapshots 👌 Moving DOM logic from the store 👌 Addressing more points from code review 👌 Refactoring trial banner component and ui store 👌 Updating permanent banner dismiss endpoint and back-end logic ⚡ Updating the migrations syntax ci!: Drop support for Node.js 16. Add initial support for Node.js 20 (#6649) feat(API): Implement users account quota guards (#6434) feat(OpenAI Node): Update max token limit to support newer model limits (#6644) ci: Run checklist job as a separate workflow (no-changelog) (#6645) fix(HTTP Request Node): Cleanup circular references in response (#6590) fix(Postgres Node): Upsert does not fetch columns when schema other then public (#6643) fix(core): Update docker compose setup for V1 images (#6642) refactor: Delete unnecessary interface re-exports from core, and delete unused code in nodes-base (no-changelog) (#6631) fix(core): Reduce memory consumption on `BinaryDataManager.init` (#6633) ⚡ Updating upgrade plan button click 👌 Addressing design review feedback ⚡ Using query parameters in migrations fix(editor): Implement simple view for templates experiment (no-changelog) (#6637) ⚡ Updating migration files
* feat(cli): Implement users account quota guards Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> * Remove comment Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> * Address PR comments - Getting `usersQuota` from `Settings` repo - Revert `isUserManagementEnabled` helper - Fix FE listing of users Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> * Refactor isWithinUserQuota getter and fix tests Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> * Revert testDb.ts changes Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> * Cleanup & improve types Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> * Fix duplicated method * Fix failing test * Remove `isUserManagementEnabled` completely Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> * Check for globalRole.name to determine if user is owner Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> * Fix unit tests Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> * Set isInstanceOwnerSetUp in specs * Fix SettingsUserView UM Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> * refactor: License typings suggestions for users quota guards (#6636) refactor: License typings suggestions * Update packages/cli/src/Ldap/helpers.ts Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * Update packages/cli/test/integration/shared/utils.ts Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * Address PR comments Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> * Use 403 for all user quota related errors Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> --------- Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> Co-authored-by: Iván Ovejero <ivov.src@gmail.com>
Got released with |
Github issue / Community forum post (link here to close automatically):