A page that gives out OONI's Slack invite link. It replaces slackin, which
invited people through Slack's undocumented users.admin.invite and a legacy
token, both of which Slack has been shutting down.
Slack's free plan has no API for inviting people, but an admin can make a shared invite link that anyone can join with. Slack keeps it active for 30 days, or until 400 people have used it.
- An admin makes a link in Slack (click the workspace name, then Invite
people to OONI, then Copy invite link) and sets it from the admin channel
with
/invite-link <link>. The channel sees who set it and when it expires. - slack.ooni.org gives the link to whoever visits, with a Join button.
- Slack doesn't say when a link expires, so the service counts 30 days from
when it was set. It reminds the admin channel 5 days and 1 day before,
and when the link has expired, through an incoming webhook. Until a new
link is set, the page says there is none and shows
CONTACT_EMAIL.
/invite-link with nothing after it tells whoever sends it, from any
channel, the current link and when it expires (only they see the answer).
A link sent from any channel but the admin channel gets only "Denied.", so
the answer doesn't say where the link can be set. Slash command requests
are checked against the app's signing secret, and refused if signed more
than 5 minutes from now, so a captured one can't be replayed.
The link is kept in an SSM parameter, as JSON with when it was set, by
whom (a Slack user ID) and which reminders were sent, so a restarted
service finds it and doesn't remind again. A bare link put in the parameter
by hand also works, counted from when the parameter was last modified (as
is JSON without set_at).
Visitors give the service nothing, and nothing about them is logged. Anyone who has the link can join, and pass it on, until it expires.
From the environment:
| Variable | |
|---|---|
INVITE_LINK_PARAMETER |
Required. SSM parameter that holds the link. Needs AWS_REGION, and credentials that may read and write the parameter (on ECS, the task role) |
SLACK_SIGNING_SECRET |
The Slack app's signing secret (Basic Information → App Credentials). With SLACK_ADMIN_CHANNEL, turns on /invite-link |
SLACK_SIGNING_SECRET_FILE |
Or a file holding it |
SLACK_ADMIN_CHANNEL |
ID of the channel the link may be set from (C0123...; channel details → About). Make it a private channel: anyone can join the workspace |
SLACK_ADMIN_USERS |
IDs of the only users who may set the link, comma-separated (U0123...; profile → ⋮ → Copy member ID). Empty: anyone in the admin channel |
SLACK_WEBHOOK_URL |
Incoming webhook the reminders are posted to, in the admin channel (https://hooks.slack.com/services/...). Without it, reminders only go to the log |
SLACK_WEBHOOK_URL_FILE |
Or a file holding it |
WORKSPACE_NAME |
Shown on the page and in reminders (default OONI) |
CONTACT_EMAIL |
Shown for people who have trouble joining |
SLACK_SIGNIN_URL |
The workspace's URL (https://<workspace>.slack.com/), linked for members to sign in. Invite links of other workspaces are then refused, from the command and from the parameter |
LISTEN_ADDR |
Address to listen on (default :3000; the image sets :80) |
Without the Slack settings, set the link in the parameter by hand; the 30 days count from when it was written. The service reads the parameter every hour, and at start, so restart it (or wait) for the page to give out the new link:
aws ssm put-parameter --name <parameter> --type String --overwrite \
--value 'https://join.slack.com/t/<workspace>/shared_invite/...'
The Slack app (the one whose incoming webhook posts to the admin channel)
needs a slash command: Slash Commands → Create New Command, named
/invite-link, with the Request URL https://slack.ooni.org/slack/commands.
Reinstall the app to the
workspace afterwards. Adding the command only adds the commands scope:
the app reads no messages.
make docker-build builds the image, running the Go tests as part of the
build. make docker-smoketest starts it and checks it answers.
It runs as an ECS service set up in ooni/devops with the ooniapi_service
and ooniapi_service_deployer modules. The deployer's CodeBuild project runs
buildspec.yml on every push to main: it builds, smoketests and pushes
ooni/slack-invite:<date>-<sha>, and ECS deploys it.
The image is Debian stable (trixie-slim) with ca-certificates from apt,
for HTTPS to Slack. Rebuilding picks up their updates.
The page looks like slackin's did. assets/org-logo.png is the workspace's
icon and assets/slack.svg Slack's logo; the service serves them itself, so
the page loads nothing from other sites.
/badge.svg is a "slack | join" badge in place of slackin's, which READMEs
embed. Unlike slackin's, it has no member count.
BSD 3-Clause (LICENSE). The page's look and the badge are derived from slackin-extended and slackin, under the MIT license, and the Slack logo belongs to Slack: see NOTICE.