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

✨ User management backend #2636

Merged
merged 782 commits into from
Mar 14, 2022
Merged

✨ User management backend #2636

merged 782 commits into from
Mar 14, 2022

Conversation

BHesseldieck
Copy link
Contributor

Creating the backend functionality to enable the usage of an n8n instance by multiple people simultaneously.

@BHesseldieck BHesseldieck added feature Large self-contained feature n8n team Authored by the n8n team labels Jan 5, 2022
@BHesseldieck BHesseldieck changed the title User management backend ✨ User management backend Jan 5, 2022
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we don't want to add file wide rule disablings anymore but rather remove them. We should either remove them and refactor or think if the rule is needed or should be changed.

Copy link
Contributor

Choose a reason for hiding this comment

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

For reference, @typescript-eslint/no-non-null-assertion is almost always because of mistyped DB collections. I know how to fix the typing but agreed with Omar to defer until we finish UM.

Copy link
Contributor

Choose a reason for hiding this comment

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

More generally, I have been removing lint exceptions in the testing branches. Perhaps we should wait until those are merged before refactoring and/or adding project-wide exceptions.

Copy link
Contributor Author

@BHesseldieck BHesseldieck left a comment

Choose a reason for hiding this comment

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

flagged all places where we are adding file wide rule disablements. We def. need to refactor this

@@ -1,3 +1,4 @@
/* eslint-disable import/no-cycle */
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ref previous comments about file wide rule disablings

https://github.com/n8n-io/n8n/pull/2636/files#r798351153

Comment on lines 1 to 2
/* eslint-disable import/no-cycle */
/* eslint-disable @typescript-eslint/no-non-null-assertion */
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ref previous comments about file wide rule disablings

https://github.com/n8n-io/n8n/pull/2636/files#r798351153

@@ -1,3 +1,4 @@
/* eslint-disable import/no-cycle */
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ref previous comments about file wide rule disablings

https://github.com/n8n-io/n8n/pull/2636/files#r798351153

@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ref previous comments about file wide rule disablings

https://github.com/n8n-io/n8n/pull/2636/files#r798351153

Comment on lines 1 to 2
/* eslint-disable import/no-cycle */
/* eslint-disable @typescript-eslint/no-unused-vars */
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ref previous comments about file wide rule disablings

https://github.com/n8n-io/n8n/pull/2636/files#r798351153

Comment on lines +1 to +2
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable import/no-cycle */
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ref previous comments about file wide rule disablings

https://github.com/n8n-io/n8n/pull/2636/files#r798351153

@@ -0,0 +1,57 @@
/* eslint-disable import/no-cycle */
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ref previous comments about file wide rule disablings

https://github.com/n8n-io/n8n/pull/2636/files#r798351153

@@ -0,0 +1,57 @@
/* eslint-disable import/no-cycle */
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ref previous comments about file wide rule disablings

https://github.com/n8n-io/n8n/pull/2636/files#r798351153

@@ -0,0 +1,106 @@
/* eslint-disable import/no-cycle */
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ref previous comments about file wide rule disablings

https://github.com/n8n-io/n8n/pull/2636/files#r798351153

@@ -0,0 +1,141 @@
/* eslint-disable import/no-cycle */
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ref previous comments about file wide rule disablings

https://github.com/n8n-io/n8n/pull/2636/files#r798351153

BHesseldieck and others added 25 commits February 10, 2022 14:33
* 📦 Add crypto-js to /cli

* 📦 Update package-lock.json

* ✨ Create type for SMTP config

* ⚡ Encrypt SMTP pass

* ⚡ Update format for `userManagement.emails.mode`

* ⚡ Update format for `binaryDataManager.mode`

* ⚡ Update format for `logs.level`

* 🔥 Remove logging

* 👕 Fix lint
* remove mocks

* update authorization func

* lock down default role

* 🐛 fix requiring authentication for OPTIONS requests

* 🐛 fix cors and cookie issues in dev

* update setup route

Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com>
* ⚡ Refactor users namespace

* ⚡ Adjust fillout endpoint

* ⚡ Refactor initTestServer arg

* ✏️ Specify agent type

* ✏️ Specify role type

* ⚡ Tighten `/users/:id` check

* ✨ Add initial tests

* 🚚 Reposition init server map

* ⚡ Set constants in `validatePassword()`

* ⚡ Tighten `/users/:id` check

* ⚡ Improve checks in `/users/:id`

* ✨ Add tests for `/users/:id`

* 📦 Update package-lock.json

* ⚡ Simplify expectation

* ⚡ Reuse util for authless agent

* 🚚 Make role names consistent

* 📘 Tighten namespaces map type

* 🔥 Remove unneeded default arg

* ✨ Add tests for `POST /users`

* 📘 Create test SMTP account type

* ✏️ Improve wording

* 🎨 Formatting

* 🔥 Remove temp fix

* ⚡ Replace helper with config call

* ⚡ Fix failing tests

* 🔥 Remove outdated test

* 🔥 Remove unused helper

* ⚡ Increase readability of domain fetcher

* ⚡ Refactor payload validation

* 🔥 Remove repetition

* ⏪ Restore logging

* ⚡ Initialize logger in tests

* 🔥 Remove redundancy from check

* 🚚 Move `globalOwnerRole` fetching to global scope

* 🔥 Remove unused imports

* 🚚 Move random utils to own module

* 🚚 Move test types to own module

* ✏️ Add dividers to utils

* ✏️ Reorder `initTestServer` param docstring

* ✏️ Add TODO comment

* ⚡ Dry up member creation

* ⚡ Tighten search criteria

* 🧪 Add expectation to `GET /users`

* ⚡ Create role fetcher utils

* ⚡ Create one more role fetch util

* 🔥 Remove unneeded DB query

* 🧪 Add expectation to `POST /users`

* 🧪 Add expectation to `DELETE /users/:id`

* 🧪 Add another expectation to `DELETE /users/:id`

* 🧪 Add expectations to `DELETE /users/:id`

* 🧪 Adjust expectations in `POST /users/:id`

* 🧪 Add expectations to `DELETE /users/:id`

* 👕 Fix build

* ⚡ Update method

* 📘 Fix `userToDelete` type

* ⚡ Refactor `createAgent()`

* ⚡ Make role fetching global

* ⚡ Optimize roles fetching

* ⚡ Centralize member creation

* ⚡ Refactor truncation helper

* 🧪 Add teardown to `DELETE /users/:id`

* 🧪 Add DB expectations to users tests

* 🔥 Remove pass validation due to hash

* ✏️ Improve pass validation error message

* ⚡ Improve owner pass validation

* ⚡ Create logger initialization helper

* ⚡ Optimize helpers

* ⚡ Restructure `getAllRoles` helper
* ⚡ Refactor users namespace

* ⚡ Adjust fillout endpoint

* ⚡ Refactor initTestServer arg

* ✏️ Specify agent type

* ✏️ Specify role type

* ⚡ Tighten `/users/:id` check

* ✨ Add initial tests

* 🚚 Reposition init server map

* ⚡ Set constants in `validatePassword()`

* ⚡ Tighten `/users/:id` check

* ⚡ Improve checks in `/users/:id`

* ✨ Add tests for `/users/:id`

* 📦 Update package-lock.json

* ⚡ Simplify expectation

* ⚡ Reuse util for authless agent

* 🚚 Make role names consistent

* 📘 Tighten namespaces map type

* 🔥 Remove unneeded default arg

* ✨ Add tests for `POST /users`

* 📘 Create test SMTP account type

* ✏️ Improve wording

* 🎨 Formatting

* 🔥 Remove temp fix

* ⚡ Replace helper with config call

* ⚡ Fix failing tests

* 🔥 Remove outdated test

* ✨ Add tests for password reset flow

* ✏️ Fix test wording

* ⚡ Set password reset namespace

* 🔥 Remove unused helper

* ⚡ Increase readability of domain fetcher

* ⚡ Refactor payload validation

* 🔥 Remove repetition

* ⏪ Restore logging

* ⚡ Initialize logger in tests

* 🔥 Remove redundancy from check

* 🚚 Move `globalOwnerRole` fetching to global scope

* 🔥 Remove unused imports

* 🚚 Move random utils to own module

* 🚚 Move test types to own module

* ✏️ Add dividers to utils

* ✏️ Reorder `initTestServer` param docstring

* ✏️ Add TODO comment

* ⚡ Dry up member creation

* ⚡ Tighten search criteria

* 🧪 Add expectation to `GET /users`

* ⚡ Create role fetcher utils

* ⚡ Create one more role fetch util

* 🔥 Remove unneeded DB query

* 🧪 Add expectation to `POST /users`

* 🧪 Add expectation to `DELETE /users/:id`

* 🧪 Add another expectation to `DELETE /users/:id`

* 🧪 Add expectations to `DELETE /users/:id`

* 🧪 Adjust expectations in `POST /users/:id`

* 🧪 Add expectations to `DELETE /users/:id`

* 📘 Add namespace name to type

* 🚚 Adjust imports

* ⚡ Optimize `globalOwnerRole` fetching

* 🧪 Add expectations

* 👕 Fix build

* 👕 Fix build

* ⚡ Update method

* ⚡ Update method

* 🧪 Fix `POST /change-password` test

* 📘 Fix `userToDelete` type

* ⚡ Refactor `createAgent()`

* ⚡ Make role fetching global

* ⚡ Optimize roles fetching

* ⚡ Centralize member creation

* ⚡ Refactor truncation helper

* 🧪 Add teardown to `DELETE /users/:id`

* 🧪 Add DB expectations to users tests

* ⚡ Refactor as in users namespace

* 🧪 Add expectation to `POST /change-password`

* 🔥 Remove pass validation due to hash

* ✏️ Improve pass validation error message

* ⚡ Improve owner pass validation

* ⚡ Create logger initialization helper

* ⚡ Optimize helpers

* ⚡ Restructure `getAllRoles` helper

* ⚡ Update `truncate` calls
mutdmour and others added 24 commits March 11, 2022 15:49
* Disable basic auth after owner has been set up

* Remove unnecessary comparison
* Added public url variable for emails

* Fixed base url for reset password - the current implementation overrides possibly existing path

* Change variable name to editorUrl

* Using correct name editorUrl for emails

* Changed variable description

* Improved base url naming and appending path so it remains consistent

* Removed trailing slash from editor base url
* fix up i18n pattern

* update translation keys

* update urls

* support i18n in nds

* fix how external keys are handled

* add source
Use webhook url as fallback when editor url is not defined
add confirmation modal to setup
@krynble krynble marked this pull request as ready for review March 14, 2022 12:43
@janober janober merged commit 7264239 into master Mar 14, 2022
@janober janober deleted the user-management-backend branch March 14, 2022 13:46
@janober janober added the Upcoming Release Will be part of the upcoming release label Mar 14, 2022
@janober
Copy link
Member

janober commented Mar 14, 2022

Got released with n8n@0.168.0

@janober janober removed the Upcoming Release Will be part of the upcoming release label Mar 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Large self-contained feature n8n team Authored by the n8n team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants