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: validate store/add access #15

Merged
merged 13 commits into from
Nov 21, 2022
Merged

Conversation

alanshaw
Copy link
Member

@alanshaw alanshaw commented Nov 15, 2022

This PR adds a request to w3access when a store/add invocation is handled.

The request to w3access ensures that the target space has been verified by a user via email.

@seed-deploy seed-deploy bot temporarily deployed to pr15 November 15, 2022 15:44 Inactive
@seed-deploy
Copy link

seed-deploy bot commented Nov 15, 2022

View stack outputs

Copy link
Contributor

@vasco-santos vasco-santos left a comment

Choose a reason for hiding this comment

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

Yes! I Like it

@alanshaw alanshaw force-pushed the feat/validate-store-add-access branch from 5603f06 to 51f5047 Compare November 16, 2022 12:47
@seed-deploy seed-deploy bot temporarily deployed to pr15 November 16, 2022 12:47 Inactive
@olizilla
Copy link
Contributor

@alanshaw plz to add PR description or link to issue or both!

Copy link
Contributor

@olizilla olizilla left a comment

Choose a reason for hiding this comment

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

👍

carIsLinkedToAccount,
carExists
] = await Promise.all([
context.storeTable.exists(account, link.toString()),
context.access.verifyInvocation(invocation),
Copy link
Contributor

Choose a reason for hiding this comment

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

do context.access.verifyInvocation before we do any other work? db and bucket reads have a smol $ cost.

Copy link
Member Author

Choose a reason for hiding this comment

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

IDK, I'm optimistically hoping that requests are going to have access to do this.

@@ -35,7 +39,9 @@ async function ucanInvocationRouter (request) {
}
}

const server = await createUcantoServer({
const id = await getServiceDid()
Copy link
Contributor

Choose a reason for hiding this comment

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

plz long name like

Suggested change
const id = await getServiceDid()
const uploadApiDid = await getServiceDid()

Copy link
Contributor

@vasco-santos vasco-santos left a comment

Choose a reason for hiding this comment

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

Can you extend this to store/*? and maybe upload/* if this lands after storacha/w3up#184

@seed-deploy seed-deploy bot temporarily deployed to pr15 November 21, 2022 13:36 Inactive
…age/upload-api into feat/validate-store-add-access
@seed-deploy seed-deploy bot temporarily deployed to pr15 November 21, 2022 14:37 Inactive
@seed-deploy seed-deploy bot temporarily deployed to pr15 November 21, 2022 15:07 Inactive
@seed-deploy seed-deploy bot temporarily deployed to pr15 November 21, 2022 15:28 Inactive
@seed-deploy
Copy link

seed-deploy bot commented Nov 21, 2022

Stack outputs updated

@seed-deploy seed-deploy bot temporarily deployed to pr15 November 21, 2022 15:52 Inactive
@seed-deploy seed-deploy bot temporarily deployed to pr15 November 21, 2022 16:03 Inactive
@seed-deploy seed-deploy bot temporarily deployed to pr15 November 21, 2022 16:09 Inactive
@seed-deploy seed-deploy bot temporarily deployed to pr15 November 21, 2022 16:15 Inactive
@seed-deploy seed-deploy bot temporarily deployed to pr15 November 21, 2022 16:17 Inactive
@seed-deploy seed-deploy bot temporarily deployed to pr15 November 21, 2022 16:28 Inactive
Copy link
Contributor

@vasco-santos vasco-santos left a comment

Choose a reason for hiding this comment

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

LGTM! 🎉 Thanks

@@ -77,3 +96,81 @@ export function getSigningOptions(ctx) {
bucket: ctx.bucketName,
}
}

/** @returns {Promise<MockAccess>} */
export async function createAccessServer () {
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be nice to consider creating a mock module for this as I expect it to be needed in more services. Not for now, just raising thoughts for visibility :)

@olizilla
Copy link
Contributor

I had to make similar changes to createUcantoServer in #35 so let's get this one merged and I can deal with the conflicts over there.

@alanshaw alanshaw merged commit 32320b5 into main Nov 21, 2022
@alanshaw alanshaw deleted the feat/validate-store-add-access branch November 21, 2022 20:58
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