Skip to content
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!: content serve authorization #1590

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Conversation

fforbeck
Copy link
Member

@fforbeck fforbeck commented Nov 26, 2024

Context

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.

Main Changes

  • New Functionality: Added a new function, authorizeContentServe, in the w3up-client module to facilitate the delegation process. Integrated it with the createdSpace flow.
  • Testing: Introduced test cases to verify the authorization of specified gateways.
  • Fixes: Resolved issues with previously broken test cases (Egress Record).

Issue: #158

@fforbeck fforbeck self-assigned this Nov 26, 2024
@fforbeck fforbeck force-pushed the feat/gateway-authorization branch 2 times, most recently from b98e723 to 5d8ba9b Compare November 27, 2024 14:08
@fforbeck fforbeck marked this pull request as ready for review November 27, 2024 14:08
packages/w3up-client/src/client.js Outdated Show resolved Hide resolved
packages/w3up-client/src/client.js Outdated Show resolved Hide resolved
packages/w3up-client/src/client.js Outdated Show resolved Hide resolved
packages/w3up-client/src/client.js Outdated Show resolved Hide resolved
packages/w3up-client/src/client.js Outdated Show resolved Hide resolved
packages/w3up-client/src/client.js Outdated Show resolved Hide resolved
packages/w3up-client/test/capability/space.test.js Outdated Show resolved Hide resolved
packages/w3up-client/test/client.test.js Outdated Show resolved Hide resolved
Peeja
Peeja previously requested changes Nov 29, 2024
Copy link
Member

@Peeja Peeja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! Just the TypeScript / JSDoc thing.

Not My Type Mexican

packages/w3up-client/test/mocks/service.js Outdated Show resolved Hide resolved
packages/w3up-client/test/capability/space.test.js Outdated Show resolved Hide resolved
@fforbeck fforbeck changed the title feat: authorize gateway feat!: content serve authorization Nov 29, 2024
packages/w3up-client/src/client.js Outdated Show resolved Hide resolved
packages/w3up-client/src/client.js Outdated Show resolved Hide resolved
packages/w3up-client/src/client.js Outdated Show resolved Hide resolved
packages/w3up-client/src/client.js Outdated Show resolved Hide resolved
packages/w3up-client/src/client.js Outdated Show resolved Hide resolved
@fforbeck fforbeck force-pushed the feat/gateway-authorization branch 2 times, most recently from e0fb6fb to d533b7a Compare December 2, 2024 14:06
@@ -13,13 +13,15 @@ export const provide = (ctx) =>

/**
* Checks if the given Principal is an Account.
*
Copy link
Member Author

@fforbeck fforbeck Dec 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed lint issue

* @param {API.Principal} principal
* @returns {principal is API.Principal<API.DID<'mailto'>>}
*/
const isAccount = (principal) => principal.did().startsWith('did:mailto:')

/**
* Returns true when the delegation has a `ucan:*` capability.
*
Copy link
Member Author

@fforbeck fforbeck Dec 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed lint issue

* @param {Agent<S>} agent
* @param {Types.Invocation} invocation
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed lint issue

@fforbeck fforbeck dismissed Peeja’s stale review December 2, 2024 18:35

Implemented suggested changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants