-
Notifications
You must be signed in to change notification settings - Fork 90
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(backend): tenanted assets #3206
Merged
Merged
Changes from 21 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
3827964
feat(backend): migration to backfill tenantId on assets
mkurapov 0ad9b69
feat(backend): add tenantId to asset, use it in service
mkurapov f47c6a0
feat(backend): use tenantId in asset resolvers
mkurapov 2edea03
test(backend): update tests to use asset tenantId where necessary
mkurapov 54434cb
test(backend): truncate tenant table manually in tenant tests
mkurapov 54ef8b7
test(backend): update failing accounting tests
mkurapov 4255595
test(backend): update tenant service test
mkurapov 5dce25b
test: fix accounting tests linting
mkurapov 5a31294
test(backend): update accounting tests
mkurapov 8151328
feat(backend): use tenantId when fetching asset
mkurapov 5c507fd
test(backend): make tests work with separate middleware
mkurapov 557e78a
test(backend): keep operator tenant when truncating tables
mkurapov 62be42b
test(backend): skip tenant pagination tests for now
mkurapov 2ae9bd0
test(backend): seed operator tenant in truncateTable
mkurapov 1b57e15
test(backend): seed operator tenant after tenants service is done
mkurapov c89d84e
test(backend): use separate schema for tenant tests
mkurapov 5c38bf0
test(backend): pass operator tenant id in pagination tests
mkurapov 79422ed
feat(backend): make tenantId required in asset pagination
mkurapov f3eadec
test(backend): update tenant service tests
mkurapov 34a05c2
chore(backend): update config file
mkurapov d3fa2b2
test: update truncateTables to take in dbSchema
mkurapov bf85eb6
feat(backend): make tenantId optional in asset pagination
mkurapov 279a3d2
Merge branch '2893/multi-tenancy-v1' into 3033/mk/tenanted-assets
mkurapov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
packages/backend/migrations/20241216160130_backfill_tenant_on_assets.js
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,30 @@ | ||
/** | ||
* @param { import("knex").Knex } knex | ||
* @returns { Promise<void> } | ||
*/ | ||
exports.up = function (knex) { | ||
return knex.schema | ||
.alterTable('assets', (table) => { | ||
table.uuid('tenantId').references('tenants.id').index() | ||
}) | ||
.then(() => { | ||
return knex.raw( | ||
`UPDATE "assets" SET "tenantId" = (SELECT id from "tenants" LIMIT 1)` | ||
) | ||
}) | ||
.then(() => { | ||
return knex.schema.alterTable('assets', (table) => { | ||
table.uuid('tenantId').notNullable().alter() | ||
}) | ||
}) | ||
} | ||
|
||
/** | ||
* @param { import("knex").Knex } knex | ||
* @returns { Promise<void> } | ||
*/ | ||
exports.down = function (knex) { | ||
return knex.schema.alterTable('assets', (table) => { | ||
table.dropColumn('tenantId') | ||
}) | ||
} |
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
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
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Basically, had an issue where the replay attack prevention via redis (ie
canApiSignature
function) was resulting a 401 Unauthorized error for many resolver tests (for cases where we call the same resolver back to back)