API scope for customized texts

AI-generated summary

mattdm is requesting an API scope for customized texts to support syncing with translation. The desired API key should have the ability to read and write customized texts, but with restrictions. Specifically, the scope should:

  • Allow reads of all customized texts
  • Allow writes to non-primary language strings only if the primary language string is not default
  • Allow reset of non-primary language strings to their defaults
  • Disallow writes to primary language strings

A possible first pass would be to restrict access to /admin/customize/site_texts. However, further configurable restrictions on site_text[locale] writes and site_text[value]s are necessary to prevent potential misuse, such as defacement or spam, in case the API key is compromised.

The use case is syncing with translation – see

I’d like to provision an API key which can read and write customized texts, but without the power to do anything else.

Although reading all of the overridden strings is probably harmless, it would also be nice to add further restrictions on writes based on a primary language — in my case, English. That would:

  1. disallow writes to strings in that language
  2. allow writes to strings in other languages only if the primary language string is not default
  3. allow reset of strings in non-primary languages to their defaults

(The third rule would allow reset even if the primary language string is customized; this would allow translations to be removed if they need to be for some reason.)

Simply a scope restricting access to only /admin/customize/site_texts would be a nice first pass. However, further (configurable) restrictions on site_text[locale] writes, and even on certain site_text[value]s seems eventually important, because if such a key leaks or is stolen it could be used to deface a site (or insert really sneaky spam links, etc.).