Skip to content

restrict /policy PATCH to non-themes#22564

Merged
eviljeff merged 1 commit into
mozilla:masterfrom
eviljeff:14937-prevent-themes-from-policy-api-patch
Aug 12, 2024
Merged

restrict /policy PATCH to non-themes#22564
eviljeff merged 1 commit into
mozilla:masterfrom
eviljeff:14937-prevent-themes-from-policy-api-patch

Conversation

@eviljeff

@eviljeff eviljeff commented Aug 9, 2024

Copy link
Copy Markdown
Member

Fixes: mozilla/addons#14937

Description

Themes can't have EULA or privacy policies, so restrict the endpoint to non-themes, like devhub does.

Context

PATCH for /policy was added recently.

Testing

Checklist

  • Add #ISSUENUM at the top of your PR to an existing open issue in the mozilla/addons repository.
  • Successfully verified the change locally.
  • The change is covered by automated tests, or otherwise indicated why doing so is unnecessary/impossible.
  • Add before and after screenshots (Only for changes that impact the UI).
  • Add or update relevant docs reflecting the changes made.

@eviljeff
eviljeff force-pushed the 14937-prevent-themes-from-policy-api-patch branch from 93c0da8 to 2f90dcd Compare August 9, 2024 18:46
@eviljeff
eviljeff requested review from a team and KevinMind and removed request for a team August 9, 2024 18:46
@eviljeff
eviljeff marked this pull request as ready for review August 9, 2024 18:46
@KevinMind

Copy link
Copy Markdown
Contributor

@eviljeff how do I create a new theme locally?

image

@eviljeff

Copy link
Copy Markdown
Member Author

@eviljeff how do I create a new theme locally?

Either download one from prod and submit it as a new add-on, or use the theme wizard to create one with whatever random image you have lying around.

@KevinMind

Copy link
Copy Markdown
Contributor

Also FWIW I will try testing this using the swagger docs. http://olympia.test/api/v5/swagger/#/addons/addons_addon_eula_policy_partial_update

Note: Interesting swagger is not groking the serializer TranslationField correctly, expecting a string. Should be fixed at some point.

For now used Curl to update an addon's policy, once I find out how to upload a theme I'll test the opposite case.

curl -X PATCH http://olympia.test/api/v5/addons/addon/97/eula_policy/
-H "Authorization: Session "
-H "Content-Type: application/json"
-d '{
"privacy_policy": {
"en-us": "private"
}
}'

@KevinMind KevinMind left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code looks good. One question, " like devhub does." this indicates that devhub is also limiting access to the endpoint? Thought the validator you added doesn't seem to be referenced by devhub code. Does this mean we have two mechanisms for access control or can you expand on what you mean by the quoted statement.

Confirmed themese not able to patch, extension was able to patch.

@KevinMind

Copy link
Copy Markdown
Contributor

Filed mozilla/addons#14958

@eviljeff

Copy link
Copy Markdown
Member Author

Code looks good. One question, " like devhub does." this indicates that devhub is also limiting access to the endpoint? Thought the validator you added doesn't seem to be referenced by devhub code. Does this mean we have two mechanisms for access control or can you expand on what you mean by the quoted statement.

Devhub has a form to set/edit privacy policy and EULA (under ownership), and we don't show those fields for themes.

@eviljeff
eviljeff merged commit 83691af into mozilla:master Aug 12, 2024
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.

[Bug]: Exclude themes in PATCH requests for eula and privacy policy fields

2 participants