Skip to content

Commit

Permalink
Merge branch '2893/multi-tenancy-v1' into feature/tenant-settings-ini…
Browse files Browse the repository at this point in the history
…tial
  • Loading branch information
golobitch committed Feb 24, 2025
2 parents b8c6e7f + 9d32bb6 commit 12d1318
Show file tree
Hide file tree
Showing 134 changed files with 3,565 additions and 785 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ script:post-response {
authUrl.hostname.includes('happy-life-bank')
){
const port = authUrl.hostname.includes('cloud-nine-wallet')? authUrl.port: Number(authUrl.port) + 1000
bru.setEnvVar("receiverOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port );
bru.setEnvVar("receiverOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port + authUrl.path);
} else {
bru.setEnvVar("receiverOpenPaymentsAuthHost", body?.authServer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ script:post-response {
}

const body = res.getBody()

bru.setEnvVar("senderAssetCode", body?.assetCode)
bru.setEnvVar("senderAssetScale", body?.assetScale)

Expand All @@ -38,7 +38,7 @@ script:post-response {
authUrl.hostname.includes('happy-life-bank')
){
const port = authUrl.hostname.includes('cloud-nine-wallet')? authUrl.port: Number(authUrl.port) + 1000
bru.setEnvVar("senderOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port );
bru.setEnvVar("senderOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port + authUrl.path);
} else {
bru.setEnvVar("senderOpenPaymentsAuthHost", body?.authServer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

post {
url: {{receiverOpenPaymentsAuthHost}}/
url: {{receiverOpenPaymentsAuthHost}}
body: json
auth: none
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

post {
url: {{senderOpenPaymentsAuthHost}}/
url: {{senderOpenPaymentsAuthHost}}
body: json
auth: none
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ script:pre-request {

script:post-response {
const body = res.getBody();

if (body?.id) {
bru.setEnvVar("incomingPaymentId", body.id.split("/").pop());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ script:pre-request {

script:post-response {
const url = require('url')

if (res.getStatus() !== 200) {
return
}

const body = res.getBody()
bru.setEnvVar("receiverAssetCode", body?.assetCode)
bru.setEnvVar("receiverAssetScale", body?.assetScale)
Expand All @@ -37,7 +37,7 @@ script:post-response {
authUrl.hostname.includes('happy-life-bank')
){
const port = authUrl.hostname.includes('cloud-nine-wallet')? authUrl.port: Number(authUrl.port) + 1000
bru.setEnvVar("receiverOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port );
bru.setEnvVar("receiverOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port + authUrl.path);
} else {
bru.setEnvVar("receiverOpenPaymentsAuthHost", body?.authServer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ script:post-response {
authUrl.hostname.includes('happy-life-bank')
){
const port = authUrl.hostname.includes('cloud-nine-wallet')? authUrl.port: Number(authUrl.port) + 1000
bru.setEnvVar("senderOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port );
bru.setEnvVar("senderOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port + authUrl.path);
} else {
bru.setEnvVar("senderOpenPaymentsAuthHost", body?.authServer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

post {
url: {{receiverOpenPaymentsAuthHost}}/
url: {{receiverOpenPaymentsAuthHost}}
body: json
auth: none
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

post {
url: {{senderOpenPaymentsAuthHost}}/
url: {{senderOpenPaymentsAuthHost}}
body: json
auth: none
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

post {
url: {{senderOpenPaymentsAuthHost}}/
url: {{senderOpenPaymentsAuthHost}}
body: json
auth: none
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ script:pre-request {

script:post-response {
const body = res.getBody();

if (body?.id) {
bru.setEnvVar("incomingPaymentId", body.id.split("/").pop());
bru.setEnvVar("quoteDebitAmount", JSON.stringify({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ script:post-response {
}

const body = res.getBody()

bru.setEnvVar("receiverAssetCode", body?.assetCode)
bru.setEnvVar("receiverAssetScale", body?.assetScale)

Expand All @@ -38,7 +38,7 @@ script:post-response {
authUrl.hostname.includes('happy-life-bank')
){
const port = authUrl.hostname.includes('cloud-nine-wallet')? authUrl.port: Number(authUrl.port) + 1000
bru.setEnvVar("receiverOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port );
bru.setEnvVar("receiverOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port + authUrl.path);
} else {
bru.setEnvVar("receiverOpenPaymentsAuthHost", body?.authServer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ script:post-response {
authUrl.hostname.includes('happy-life-bank')
){
const port = authUrl.hostname.includes('cloud-nine-wallet')? authUrl.port: Number(authUrl.port) + 1000
bru.setEnvVar("senderOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port );
bru.setEnvVar("senderOpenPaymentsAuthHost", authUrl.protocol + '//localhost:' + port + authUrl.path);
} else {
bru.setEnvVar("senderOpenPaymentsAuthHost", body?.authServer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

post {
url: {{receiverOpenPaymentsAuthHost}}/
url: {{receiverOpenPaymentsAuthHost}}
body: json
auth: none
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

post {
url: {{senderOpenPaymentsAuthHost}}/
url: {{senderOpenPaymentsAuthHost}}
body: json
auth: none
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ script:pre-request {

script:post-response {
const body = res.getBody();

if (body?.id) {
bru.setEnvVar("incomingPaymentId", body.id.split("/").pop());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ get {
auth: none
}

query {
params:query {
first: 10
wallet-address: {{receiverWalletAddress}}
~cursor: ea3bf38f-2719-4473-a0f7-4ba967d1d81b
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta {
}

post {
url: {{receiverOpenPaymentsAuthHost}}/
url: {{receiverOpenPaymentsAuthHost}}
body: json
auth: none
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ body:graphql:vars {
},
"incomingAmount": null,
"walletAddressId": "{{walletAddressId}}"
}
},
"tenantId": "{{tenantId}}"
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
meta {
name: Get Incoming Payment By Tenant
type: graphql
seq: 54
}

post {
url: {{RafikiGraphqlHost}}/{{tenantId}}/graphql
body: graphql
auth: none
}

body:graphql {
query GetIncomingPayment($id: String!) {
incomingPayment(id: $id) {
id
walletAddressId
client
state
expiresAt
incomingAmount {
value
assetCode
assetScale
}
receivedAmount {
value
assetCode
assetScale
}
metadata
createdAt
}
}
}

body:graphql:vars {
{
"id": "{{incomingPaymentId}}",
"tenantId": "{{tenantId}}"
}
}

script:pre-request {
const scripts = require('./scripts');

scripts.addApiSignatureHeader();
}
1 change: 1 addition & 0 deletions bruno/collections/Rafiki/environments/Local Playground.bru
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ vars {
assetCode: USD
assetScale: 2
senderTenantId: 438fa74a-fa7d-4317-9ced-dde32ece1787
RafikiGraphqlHostTenantId: 438fa74a-fa7d-4317-9ced-dde32ece1787
}
8 changes: 8 additions & 0 deletions localenv/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,14 @@ Authentication is disabled by default for ease of development, but it can be ena
pnpm localenv:compose:adminauth up
```

The Admin UI requires a valid API secret and tenant id to make requests to the Admin APIs, which must be submitted via a form on the frontend. For our convenience, we log a link on Mock Account Servicing Entity (MASE) start that can be used to access the Admin UI and set the credentials automatically. The credentials used pull from the MASE’s `SIGNATURE_SECRET` and `OPERATOR_TENANT_ID` environment variables.

```
cloud-nine-mock-ase-1 | Local Dev Setup:
cloud-nine-mock-ase-1 | Use this URL to access the frontend with operator tenant credentials:
cloud-nine-mock-ase-1 | http://localhost:3010/?tenantId=438fa74a-fa7d-4317-9ced-dde32ece1787&apiSecret=iyIgCprjb9uL8wFckR%2BpLEkJWMB7FJhgkvqhTQR%2F964%3D
```

For additional details on using the Rafiki Admin application within the Local Playground, including enabling authentication and managing users, see the [Local Playground Rafiki Admin](https://rafiki.dev/integration/playground/overview/#rafiki-admin) documentation.

# Reference
Expand Down
15 changes: 15 additions & 0 deletions localenv/mock-account-servicing-entity/generated/graphql.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions packages/auth/migrations/20241206232423_add_tenant_to_grant.js
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('grants', function (table) {
table.uuid('tenantId').references('tenants.id').index()
})
.then(() => {
return knex.raw(
`UPDATE "grants" SET "tenantId" = (SELECT id from "tenants" LIMIT 1)`
)
})
.then(() => {
return knex.schema.alterTable('grants', (table) => {
table.uuid('tenantId').notNullable().alter()
})
})
}

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.down = function (knex) {
return knex.schema.alterTable('grants', function (table) {
table.dropColumn('tenantId')
})
}
Loading

0 comments on commit 12d1318

Please sign in to comment.