Restrict shared attachments by file name
Description
Background
A customer shares work items from Jira Software spaces. Comments can be limited on a share (by group or role, and by date), but attachments are all or nothing: the only switch is the Attachment - View permission. Jira Software has no internal or public attachments (only JSM has them), and single attachment shares cannot be created through the web API, so the customer cannot automate them.
The customer asked for a way to show only some attachments on a share, based on the file name. Example: with the files Photos.zip, public_ProjectPlan.txt and temp.txt on the work item, only public_ProjectPlan.txt is visible on the share.
What to do
Add an "Attachment restrictions" section to the Security tab of a share, below "Comment restrictions":
-
a switch "Restrict attachments by file name",
-
a mode: "Show only files containing" or "Hide files containing",
-
a text field with the phrase. The match is a plain "contains" check, not case sensitive. Spaces around the phrase are ignored. An empty phrase restricts nothing.
The option is set per share and is also available in both web APIs (/webapi/share and v1) as attachmentNameRestriction with mode (OFF, SHOW_ONLY, HIDE) and phrase (up to 255 characters), so shares created by Jira automation can use it. It does not apply to shares of the Attachment type.
Where the restriction must apply
A hidden attachment must not be reachable and its name must not be shown anywhere on the share:
-
the attachments panel of a shared work item,
-
images, file cards and links to attachments in the description, comments and rich text fields (also in filter shares, board cards and inline editors),
-
the History tab (entries of hidden files, and their names inside other changes),
-
the AI view,
-
e-mails and notifications sent to share watchers and mentioned users (attachment, comment and field change notifications, and the notification inbox),
-
both file download addresses of a share. A link of the share to a file, copied before the restriction was turned on, stops working at once. The short-lived address of the Atlassian media service that such a link redirects a preview to cannot be withdrawn by the app.
Decisions
-
Files pasted into the description or a comment are restricted too. Images pasted in the editor have generated names, so in the "show only" mode they are hidden. Otherwise the restriction would be easy to bypass.
-
A hidden file leaves no visible trace on the share: no "blocked attachment" card, because the card would show the file name. The page keeps an invisible element in its place, so that editing the field on the share does not remove the file from Jira. In the History tab and in notifications the name is replaced by
***. -
Files uploaded by an external user through the share follow the same rule. If the name does not pass the restriction, the file is hidden also for the person who uploaded it.
-
One phrase per share in the first version.
-
Per share only, no default in the space configuration.