v2.0.0-beta
🚀 Multi-tenancy support added
Overview
In this release, we have added support for multi-tenancy in Rafiki. This allows single Rafiki instance to service multiple account servicing entities (ASEs).
There is no "opt out" of multi-tenancy, Rafiki is multi-tenant by default.
Migration guide
The entity responsible for managing a Rafiki instance that serves multiple ASEs is called an operator. When upgrading from v1-beta version of Rafiki to v2-beta, an operator tenant is seeded automatically (given the environment variables below) and all of the existing resources are backfilled to reference the operator tenant.
An operator is then able to create individual tenants, and create, manage resources & liquidity for them. This is done through the backend Admin API. The tenant details/settings (and the updates to those details) are propagated to the auth service with a new "tenant" auth API.
At a high level, the main changes require:
- Generating a V4 UUID to set as the operator id
- Start signing Admin API requests to both
backendandauthAPIs, if not done so already. This is necessary to determine which tenant is making a request to the APIs. - Expose the tenant API in
authto listen to any tenant information changes propagated frombackend.
Necessary auth changes
- Set
OPERATOR_TENANT_IDto a V4 UUID. ADMIN_API_SECRETto a strong, random secret.- Expose the tenant service API port (by default it is
3011). This is to listen to any changes to the tenant information frombackend.
Necessary backend changes
- Set
OPERATOR_TENANT_IDto a V4 UUID (the same as theauth). - Set
ADMIN_API_SECRETto a strong, random secret. (for ease of use when signing requests, set it to same as theauth).
Please note, if you were already signing the Admin API requests tobackend,API_SECRETwas renamed toADMIN_API_SECRET, andAPI_SIGNATURE_VERSIONwas renamed toAPI_SIGNATURE_VERSION. - Set
AUTH_SERVICE_API_URLto the full URL of new exposed tenant auth service.
Necessary frontend changes
- When first interacting with
frontend, the tenant (or operator) credentials must be entered akin to a login screen.
Necessary changes to your integration server
- Update
createWalletAddressmutation input. Now, instead of a fullurlpath, the mutation takes inaddress, which could be a full URL or just a path. If a path is entered, it will act as a suffix to the definedOPEN_PAYMENTS_URLif the request is on behalf of an operator, or a suffix to the defined wallet address URL tenant setting, if the request is from a non-operator tenant. - Update
walletAddressresolver to fetchaddressinstead ofurl. - Start signing requests to the
backendandauthAdmin APIs. An example of signing requests with the Apollo GraphQL client can be found in ourmock-asehere.
Example code:
const httpLink = new HttpLink({
uri: process.env.ADMIN_API_URL,
enhancedClientAwareness: { transport: false } // necessary to avoid adding additional properties into request object
});
const createAuthLink = (args: { tenantId: string, apiSecret: string, signatureVersion: number }) => {
return setContext((request, { headers }) => {
const timestamp = Date.now()
const { query, variables, operationName } = request
const formattedRequest = {
variables,
operationName,
query: print(query)
}
const payload = `${timestamp}.${canonicalize(formattedRequest)}`
const digest = createHmac('sha256', args.apiSecret)
.update(payload)
.digest('hex')
return {
headers: {
...headers,
signature: `t=${timestamp}, v${args.signatureVersion}=${digest}`,
['tenant-id']: args.tenantId
}
};
})
}✨ New Features
f8c4684- Multi-Tenancy v1 (PR #3413 by @njlie)cf3f946- setup i18n for rafiki docs (PR #3521 by @huijing)cb847fb- migrate from astro-graphql-plugin to spectaql (PR #3536 by @huijing)083660b- mock-ase: swapped receiver/sender bruno env; ASE env vars (PR #3565 by @njlie)007891e- frontend: tenant settings fields for tenant create (PR #3572 by @njlie)490f627- frontend: use tenant wallet address prefix in admin UI (PR #3570 by @njlie)6c6f50a- backend: tenant id filter tests for gql pagination (PR #3567 by @njlie)960bf1c- backend: add tenant id to some liquidity resolvers (PR #3579 by @njlie)c32fdde- backend: optionaldebitAmountincreateOutgoingPaymentFromIncomingPaymentmutation (PR #3631 by @mkurapov)0c08e41- auth: start storingapiSecretinauthand add tenant signature middleware (PR #3696 by @mkurapov)0afe257- auth: add tenant boundaries to auth GraphQL resolvers (PR #3697 by @mkurapov)2cc4ca1- backend: enforce uniqueness on tenant wallet address prefixes (PR #3695 by @njlie)
🐛 Bug Fixes
8539446- update default autopeer link to testnet (PR #3583 by @dragosp1011)c4f4520- masl: seed script in MASE (PR #3588 by @mkurapov)8e3cf96- localenv: fix env, localenv, bruno errors (PR #3603 by @njlie)b5c71d5- update README with correct link (commit by @bkanishka004)b6a535d- backend: dependency issues (PR #3703 by @cozminu)
🔧 Chores
32b51a6- deps: fix critical vulnerability (PR #3582 by @cozminu)97178b5- backend, auth: use open-payments-specifications as submodule (PR #3615 by @sanducb)f1375f3- backend: remove peer id from outgoing payment model (PR #3617 by @sanducb)7b996b5- auth: re-generate auth graphql (PR #3702 by @mkurapov)f8709db- auth, backend: removed unused multi-tenancy features, update env variables (PR #3699 by @mkurapov)