Skip to content

Allow restricting share recipients to an allowlist - #3

Closed
pragmabits wants to merge 1 commit into
mainfrom
feat/share-allowlist
Closed

pragmabits wants to merge 1 commit into
mainfrom
feat/share-allowlist

Conversation

@pragmabits

Copy link
Copy Markdown
Owner

Motivation

share_spreadsheet invites any address the caller supplies. It is the one path through which this server hands data to someone outside it, and the Drive permissions of the credential do not constrain it: a service account limited to a single folder can still share a file from that folder with a stranger.

Removing the tool via ENABLED_TOOLS covers the extreme case, but not the common one — wanting to share, only with known destinations.

Change

SHARE_ALLOWED_EMAILS optionally narrows who can be invited:

  • user@host permits one address
  • @host permits a whole domain
  • entries are comma separated, trimmed, case-insensitive

Recipients outside the list are reported under failures without an invitation being sent, so the existing {successes, failures} contract is unchanged.

Opt-in, with the default preserved

Leaving the variable unset keeps sharing unrestricted. Installations that do not want the feature see no difference and need no configuration.

Note this is the opposite of a fail-closed default: an empty list means "no restriction", not "block everyone". Blocking everything is already achievable by dropping the tool from ENABLED_TOOLS.

Notes

  • Domains are compared exactly rather than by suffix, otherwise @example.com would also admit notexample.com. There is a dedicated test for it.
  • The check runs before any API call.
  • 12 unit tests; suite green on Python 3.10, 3.12 and 3.13.

share_spreadsheet will invite any address the caller supplies, which is the one
path through which this server hands data to someone outside it. SHARE_ALLOWED_EMAILS
now optionally narrows that: 'user@host' permits one address and '@host' a whole
domain. Recipients outside the list are reported under failures without an
invitation being sent, so the existing successes/failures contract is unchanged.

Leaving the variable unset keeps sharing unrestricted, so installations that do
not want the feature see no difference. Domains are compared exactly rather than
by suffix, otherwise '@example.com' would also admit 'notexample.com'.
@pragmabits pragmabits closed this Sep 2, 2026
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.

1 participant