forked from storacha/w3up
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: content serve authorization (storacha#1590) + set default gatew…
…ay (#99) To enable a gateway to serve content from a specific space, we must ensure that the space owner delegates the `space/content/serve/*` capability to the Gateway. This delegation allows the Gateway to serve content and log egress events appropriately. I created a new function `authorizeContentServe` for this implementation and included it in the `createSpace` flow. This is a breaking change because now the user is forced to provide the DIDs of the Content Serve services, and the connection, or skip the authorization flow. Additionally, with the `authorizeContentServe` function, we can implement a feature in the Console App that enables users to explicitly authorize the Freeway Gateway to serve content from existing/legacy spaces. - **New Functionality:** - Added a new function, `authorizeContentServe`, in the `w3up-client` module to facilitate the delegation process. Integrated it with the `createdSpace` flow. - It also sets the Storacha Gateway as the default content server service in case the user doesn't provide any in the `createSpace` call, and doesn't use the `skipGatewayAuthorization=true` flag. - **Testing:** Introduced test cases to verify the authorization of specified gateways. - **Fixes:** Resolved issues with previously broken test cases (Egress Record). ### Related Issues - storacha/project-tracking#158 - storacha/project-tracking#160 - storacha/project-tracking#207 - storacha#1604 - Resolves storacha/project-tracking#196
- Loading branch information
Showing
28 changed files
with
3,235 additions
and
1,463 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,7 +102,7 @@ export const testAccount = { | |
export const testSpace = { | ||
'storacha space create': test(async (assert, context) => { | ||
const command = storacha | ||
.args(['space', 'create']) | ||
.args(['space', 'create', '--no-gateway-authorization']) | ||
.env(context.env.alice) | ||
.fork() | ||
|
||
|
@@ -115,7 +115,7 @@ export const testSpace = { | |
|
||
'storacha space create home': test(async (assert, context) => { | ||
const create = storacha | ||
.args(['space', 'create', 'home']) | ||
.args(['space', 'create', 'home', '--no-gateway-authorization']) | ||
.env(context.env.alice) | ||
.fork() | ||
|
||
|
@@ -136,7 +136,13 @@ export const testSpace = { | |
|
||
'storacha space create home --no-caution': test(async (assert, context) => { | ||
const create = storacha | ||
.args(['space', 'create', 'home', '--no-caution']) | ||
.args([ | ||
'space', | ||
'create', | ||
'home', | ||
'--no-caution', | ||
'--no-gateway-authorization', | ||
]) | ||
.env(context.env.alice) | ||
.fork() | ||
|
||
|
@@ -160,7 +166,13 @@ export const testSpace = { | |
'storacha space create my-space --no-recovery': test( | ||
async (assert, context) => { | ||
const create = storacha | ||
.args(['space', 'create', 'home', '--no-recovery']) | ||
.args([ | ||
'space', | ||
'create', | ||
'home', | ||
'--no-recovery', | ||
'--no-gateway-authorization', | ||
]) | ||
.env(context.env.alice) | ||
.fork() | ||
|
||
|
@@ -179,7 +191,13 @@ export const testSpace = { | |
await selectPlan(context) | ||
|
||
const create = storacha | ||
.args(['space', 'create', 'home', '--no-recovery']) | ||
.args([ | ||
'space', | ||
'create', | ||
'home', | ||
'--no-recovery', | ||
'--no-gateway-authorization', | ||
]) | ||
.env(context.env.alice) | ||
.fork() | ||
|
||
|
@@ -197,7 +215,13 @@ export const testSpace = { | |
await login(context, { email: '[email protected]' }) | ||
|
||
const create = storacha | ||
.args(['space', 'create', 'my-space', '--no-recovery']) | ||
.args([ | ||
'space', | ||
'create', | ||
'my-space', | ||
'--no-recovery', | ||
'--no-gateway-authorization', | ||
]) | ||
.env(context.env.alice) | ||
.fork() | ||
|
||
|
@@ -228,6 +252,7 @@ export const testSpace = { | |
'--customer', | ||
'[email protected]', | ||
'--no-account', | ||
'--no-gateway-authorization', | ||
]) | ||
.join() | ||
.catch() | ||
|
@@ -240,8 +265,6 @@ export const testSpace = { | |
'storacha space create home --no-recovery --customer [email protected] --no-account': | ||
test(async (assert, context) => { | ||
await login(context, { email: '[email protected]' }) | ||
await login(context, { email: '[email protected]' }) | ||
|
||
await selectPlan(context) | ||
|
||
const create = await storacha | ||
|
@@ -250,6 +273,7 @@ export const testSpace = { | |
'create', | ||
'home', | ||
'--no-recovery', | ||
'--no-gateway-authorization', | ||
'--customer', | ||
'[email protected]', | ||
'--no-account', | ||
|
@@ -279,6 +303,7 @@ export const testSpace = { | |
'create', | ||
'home', | ||
'--no-recovery', | ||
'--no-gateway-authorization', | ||
'--customer', | ||
email, | ||
'--account', | ||
|
@@ -312,13 +337,56 @@ export const testSpace = { | |
|
||
const { output, error } = await storacha | ||
.env(context.env.alice) | ||
.args(['space', 'create', 'home', '--no-recovery']) | ||
.args([ | ||
'space', | ||
'create', | ||
'home', | ||
'--no-recovery', | ||
'--no-gateway-authorization', | ||
]) | ||
.join() | ||
|
||
assert.match(output, /billing account is set/i) | ||
assert.match(error, /wait.*plan.*select/i) | ||
}), | ||
|
||
'storacha space create home --no-recovery --customer [email protected] --account [email protected] --authorize-gateway-services': | ||
test(async (assert, context) => { | ||
const email = '[email protected]' | ||
await login(context, { email }) | ||
await selectPlan(context, { email }) | ||
|
||
const serverId = context.connection.id | ||
const serverURL = context.serverURL | ||
|
||
const { output } = await storacha | ||
.args([ | ||
'space', | ||
'create', | ||
'home', | ||
'--no-recovery', | ||
'--customer', | ||
email, | ||
'--account', | ||
email, | ||
'--authorize-gateway-services', | ||
`[{"id":"${serverId}","serviceEndpoint":"${serverURL}"}]`, | ||
]) | ||
.env(context.env.alice) | ||
.join() | ||
|
||
assert.match(output, /account is authorized/i) | ||
|
||
const result = await context.delegationsStorage.find({ | ||
audience: DIDMailto.fromEmail(email), | ||
}) | ||
|
||
assert.ok( | ||
result.ok?.find((d) => d.capabilities[0].can === '*'), | ||
'account has been delegated access to the space' | ||
) | ||
}), | ||
|
||
'storacha space add': test(async (assert, context) => { | ||
const { env } = context | ||
|
||
|
@@ -642,6 +710,7 @@ export const testStorachaUp = { | |
'home', | ||
'--no-recovery', | ||
'--no-account', | ||
'--no-gateway-authorization', | ||
'--customer', | ||
email, | ||
]) | ||
|
@@ -674,6 +743,7 @@ export const testStorachaUp = { | |
'home', | ||
'--no-recovery', | ||
'--no-account', | ||
'--no-gateway-authorization', | ||
'--customer', | ||
email, | ||
]) | ||
|
@@ -706,6 +776,7 @@ export const testStorachaUp = { | |
'home', | ||
'--no-recovery', | ||
'--no-account', | ||
'--no-gateway-authorization', | ||
'--customer', | ||
email, | ||
]) | ||
|
@@ -737,6 +808,7 @@ export const testStorachaUp = { | |
'home', | ||
'--no-recovery', | ||
'--no-account', | ||
'--no-gateway-authorization', | ||
'--customer', | ||
email, | ||
]) | ||
|
@@ -1371,6 +1443,7 @@ export const createSpace = async ( | |
name, | ||
'--no-recovery', | ||
'--no-account', | ||
'--no-gateway-authorization', | ||
...(customer ? ['--customer', customer] : ['--no-customer']), | ||
]) | ||
.env(env) | ||
|
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.