Skip to content

Allow guest write scope for document, file and execution #3727

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

Merged
merged 2 commits into from
Aug 30, 2022

Conversation

abnegate
Copy link
Member

What does this PR do?

Allow guests write scope for document, files, executions. Missed from spec for permissions V2.

Test Plan

Expanded tests to cover guest create/update/delete

Related PRs and Issues

#3700

Have you read the Contributing Guidelines on issues?

Yes

@abnegate abnegate marked this pull request as ready for review August 29, 2022 23:58
@@ -1802,6 +1802,8 @@ function createAttribute(string $databaseId, string $collectionId, Document $att
->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}')
->label('usage.metric', 'documents.{scope}.requests.create')
->label('usage.params', ['databaseId:{request.databaseId}', 'collectionId:{request.collectionId}'])
->label('abuse-limit', 120)
Copy link
Member

Choose a reason for hiding this comment

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

Why is this different than other ones?

Copy link
Member Author

Choose a reason for hiding this comment

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

@Meldiron Raised a good point that some workflows require creating multiple documents at once and we don't want to be too limiting to client apps, especially when the change is already reducing the amount of requests they can make.

Copy link
Contributor

Choose a reason for hiding this comment

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

@abnegate, @Meldiron, since the abuse key is the URL, this would allow creating 120 documents in 1 collection in 1 minute, right? Is that reasonable?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, after reviewing the abuse check a bit more, it looks like params are part of the abuse check so wouldn't a bad actor be able to change the param value to bypass the abuse check?

Copy link
Member Author

Choose a reason for hiding this comment

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

@stnguyen90 What is reasonable is open for discussion - what are your thoughts?

We can configure the key to be whatever we want: URL, IP, any of the params, or a combination of all.

The block you referenced lets us explicitly set request params as a part of the key - if we don't use them, it won't have any effect. For example, the abuse key for creating a magic URL contains the userId, but none of the other params:

    ->label('abuse-key', 'url:{url},userId:{param-userId}')

Copy link
Contributor

Choose a reason for hiding this comment

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

@abnegate,

What is reasonable is open for discussion - what are your thoughts?

1 doc in a particular collection per second should be plenty, right?

The block you referenced lets us explicitly set request params as a part of the key

I see now! Thanks for the clarification!

Copy link
Member Author

Choose a reason for hiding this comment

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

@stnguyen90 Please check the refactor here and lets follow up there: #3741

1 doc in a particular collection per second should be plenty, right?

From further investigation today, URL keys are not populated with ID's, however, the route method was not taken into account which led to limits applying across PATCH/PUT/DELETE routes with the same URL. Following the refactor, keys will look like this:

Screen Shot 2022-08-31 at 4 18 08 PM

cc @eldadfux

@christyjacob4 christyjacob4 merged commit 3da3e21 into 0.16.x Aug 30, 2022
@stnguyen90 stnguyen90 deleted the feat-allow-guest-writes branch February 14, 2023 01:17
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.

4 participants