-
Notifications
You must be signed in to change notification settings - Fork 99
feat(auth, backend): seed operator tenant #3156
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
Merged
mkurapov
merged 10 commits into
2893/multi-tenancy-v1
from
3149/mk/seed-operator-tenant
Dec 11, 2024
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ec65976
feat(auth): migration to seed operator tenant
mkurapov 06bc64b
feat(backend): migration to seed operator tenant
mkurapov 98ba4b9
chore(localenv): add env vars for operator tenant
mkurapov 247f980
test(backend): set operator env variables in jest config
mkurapov e8f9095
test(auth): set operator env variables in jest config
mkurapov 457913e
test(auth, backend): load env vars into jest environment script
mkurapov 1da190f
feat(auth,backend): update migrations with error messages
mkurapov a97dca7
Merge branch '2893/multi-tenancy-v1' into 3149/mk/seed-operator-tenant
mkurapov 17cbcaf
test(integration): adding operator tenant vars
mkurapov c983320
chore(backend, localenv): replace OPERATOR_TENANT_SECRET with existin…
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
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
47 changes: 47 additions & 0 deletions
47
packages/auth/migrations/20241205153036_seed_operator_tenant.js
This file contains hidden or 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,47 @@ | ||
/** | ||
* @param { import("knex").Knex } knex | ||
* @returns { Promise<void> } | ||
*/ | ||
|
||
const OPERATOR_TENANT_ID = process.env['OPERATOR_TENANT_ID'] | ||
const IDENTITY_SERVER_URL = process.env['IDENTITY_SERVER_URL'] | ||
const IDENTITY_SERVER_SECRET = process.env['IDENTITY_SERVER_SECRET'] | ||
|
||
exports.up = function (knex) { | ||
if (!OPERATOR_TENANT_ID) { | ||
throw new Error( | ||
'Could not seed operator tenant. Please configure OPERATOR_TENANT_ID environment variables' | ||
) | ||
} | ||
|
||
const seed = { | ||
id: OPERATOR_TENANT_ID | ||
} | ||
|
||
if (IDENTITY_SERVER_URL) { | ||
seed['idpConsentUrl'] = IDENTITY_SERVER_URL | ||
} | ||
|
||
if (IDENTITY_SERVER_SECRET) { | ||
seed['idpSecret'] = IDENTITY_SERVER_SECRET | ||
} | ||
|
||
return knex.raw(` | ||
INSERT INTO "tenants" (${Object.keys(seed) | ||
.map((key) => `"${key}"`) | ||
.join(', ')}) | ||
VALUES (${Object.values(seed) | ||
.map((key) => `'${key}'`) | ||
.join(', ')}) | ||
`) | ||
} | ||
|
||
/** | ||
* @param { import("knex").Knex } knex | ||
* @returns { Promise<void> } | ||
*/ | ||
exports.down = function (knex) { | ||
return knex.raw(` | ||
TRUNCATE "tenants" | ||
`) | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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,16 @@ | ||
process.env.LOG_LEVEL = 'silent' | ||
process.env.INSTANCE_NAME = 'Rafiki' | ||
process.env.KEY_ID = 'myKey' | ||
process.env.OPEN_PAYMENTS_URL = 'http://127.0.0.1:3000' | ||
process.env.ILP_CONNECTOR_URL = 'http://127.0.0.1:3002' | ||
process.env.ILP_ADDRESS = 'test.rafiki' | ||
process.env.AUTH_SERVER_GRANT_URL = 'http://127.0.0.1:3006' | ||
process.env.AUTH_SERVER_INTROSPECTION_URL = 'http://127.0.0.1:3007/' | ||
process.env.WEBHOOK_URL = 'http://127.0.0.1:4001/webhook' | ||
process.env.STREAM_SECRET = '2/PxuRFV9PAp0yJlnAifJ+1OxujjjI16lN+DBnLNRLA=' | ||
process.env.USE_TIGERBEETLE = false | ||
process.env.ENABLE_TELEMETRY = false | ||
process.env.AUTH_ADMIN_API_URL = 'http://127.0.0.1:3003/graphql' | ||
process.env.AUTH_ADMIN_API_SECRET = 'test-secret' | ||
process.env.OPERATOR_TENANT_ID = 'cf5fd7d3-1eb1-4041-8e43-ba45747e9e5d' | ||
process.env.API_SECRET = 'KQEXlZO65jUJXakXnLxGO7dk387mt71G9tZ42rULSNU=' |
This file contains hidden or 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
30 changes: 30 additions & 0 deletions
30
packages/backend/migrations/20241205153035_seed_operator_tenant.js
This file contains hidden or 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> } | ||
*/ | ||
|
||
const OPERATOR_TENANT_ID = process.env['OPERATOR_TENANT_ID'] | ||
const OPERATOR_API_SECRET = process.env['API_SECRET'] | ||
|
||
exports.up = function (knex) { | ||
if (!OPERATOR_TENANT_ID || !OPERATOR_API_SECRET) { | ||
throw new Error( | ||
'Could not seed operator tenant. Please configure OPERATOR_TENANT_ID and API_SECRET environment variables' | ||
) | ||
} | ||
|
||
return knex.raw(` | ||
INSERT INTO "tenants" ("id", "apiSecret") | ||
VALUES ('${OPERATOR_TENANT_ID}', '${OPERATOR_API_SECRET}') | ||
`) | ||
} | ||
|
||
/** | ||
* @param { import("knex").Knex } knex | ||
* @returns { Promise<void> } | ||
*/ | ||
exports.down = function (knex) { | ||
return knex.raw(` | ||
TRUNCATE "tenants" | ||
`) | ||
} |
This file contains hidden or 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 |
---|---|---|
|
@@ -162,7 +162,7 @@ export const Config = { | |
signatureSecret: process.env.SIGNATURE_SECRET, // optional | ||
signatureVersion: envInt('SIGNATURE_VERSION', 1), | ||
|
||
adminApiSecret: process.env.API_SECRET, // optional | ||
adminApiSecret: envString('API_SECRET'), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. now required |
||
adminApiSignatureVersion: envInt('API_SIGNATURE_VERSION', 1), | ||
adminApiSignatureTtl: envInt('ADMIN_API_SIGNATURE_TTL_SECONDS', 30), | ||
|
||
|
@@ -195,7 +195,8 @@ export const Config = { | |
'MAX_OUTGOING_PAYMENT_RETRY_ATTEMPTS', | ||
5 | ||
), | ||
localCacheDuration: envInt('LOCAL_CACHE_DURATION_MS', 15_000) | ||
localCacheDuration: envInt('LOCAL_CACHE_DURATION_MS', 15_000), | ||
operatorTenantId: envString('OPERATOR_TENANT_ID') | ||
} | ||
|
||
function parseRedisTlsConfig( | ||
|
This file contains hidden or 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 hidden or 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.
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.
required (will throw if not provided)