2024-12-22 19:36:24 +00:00
|
|
|
# spam accounts management for forgejo
|
2024-11-23 12:20:40 +00:00
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
- remove `model.json` if you want to start with no pre-existing model of what is
|
|
|
|
spam or not. Or keep it to use the current classifier. The file gets updated
|
|
|
|
when using the tool: the classifier learns from spam/legit decisions and
|
|
|
|
should get progressively better at identifying spam.
|
|
|
|
- run: `cargo run`
|
2024-12-21 20:22:16 +00:00
|
|
|
- classify users as spam/not spam. By default the classification is stored
|
|
|
|
locally in `db.json`, no concrete action is taken. (see the
|
|
|
|
`ACTUALLY_BAN_USERS` environment variable below.)
|
2024-11-23 12:28:24 +00:00
|
|
|
|
2024-12-20 20:14:43 +00:00
|
|
|
## Configuration
|
|
|
|
|
|
|
|
Forgery reads the following environment variables:
|
2025-01-03 11:01:47 +00:00
|
|
|
- `FORGE_URL` (**mandatory**): url of the forgejo instance (e.g.
|
|
|
|
https://git.deuxfleurs.fr)
|
|
|
|
- `FORGE_API_TOKEN` (**mandatory**): Forgejo API token *granting admin access*.
|
|
|
|
You can generate an API token using the Forgejo web interface in `Settings ->
|
2024-12-21 20:22:16 +00:00
|
|
|
Applications -> Generate New Token`.
|
2025-01-03 11:01:47 +00:00
|
|
|
- `ACTUALLY_BAN_USERS` (default: `false`): define it to `true` to actually lock
|
|
|
|
user accounts, send notification emails and eventually delete user accounts.
|
|
|
|
Otherwise, no actual action is taken: spammers are only listed in the
|
|
|
|
database. The variable should be set in production, but probably not for
|
|
|
|
testing.
|
|
|
|
- `STORAGE_BACKEND` (default: `local`): either `local` or `s3`. Chose `local` to
|
|
|
|
store the application state to local files, or `s3` to store them in
|
|
|
|
S3-compatible storage (see below for corresponding configuration variables).
|
|
|
|
- `BIND_ADDR` (default: `127.0.0.1:8080`): address on which the webserver listens
|
2024-12-20 20:14:43 +00:00
|
|
|
|
2024-12-22 23:50:01 +00:00
|
|
|
Environment variables read when `ACTUALLY_BAN_USERS=true`:
|
2024-12-20 20:14:43 +00:00
|
|
|
- `SMTP_ADDRESS`: address of the SMTP relay used to send email notifications
|
|
|
|
- `SMTP_USERNAME`: SMTP username
|
|
|
|
- `SMTP_PASSWORD`: SMTP password
|
2025-01-03 11:01:47 +00:00
|
|
|
- `ADMIN_CONTACT_EMAIL`: email that can be used to contact admins of your
|
|
|
|
instance (included in the notification email sent when locking accounts)
|
|
|
|
- `ORG_NAME`: organization name (used in the notification email sent when
|
|
|
|
locking accounts)
|
2024-12-20 20:14:43 +00:00
|
|
|
|
2024-12-22 23:50:01 +00:00
|
|
|
Environment variables read when `STORAGE_BACKEND=local`:
|
2025-01-03 11:01:47 +00:00
|
|
|
- `STORAGE_LOCAL_DIR` (default: `.`): path to a local directory where to store
|
|
|
|
the application data (as two files `db.json` and `model.json`).
|
2024-12-22 23:50:01 +00:00
|
|
|
|
|
|
|
Environment variables read when `STORAGE_BACKEND=s3`:
|
|
|
|
- `STORAGE_S3_BUCKET`: name of the bucket where to store the application data
|
|
|
|
(as two entries `db.json` and `model.json`).
|
|
|
|
- `AWS_DEFAULT_REGION`: S3 endpoint region
|
|
|
|
- `AWS_ENDPOINT_URL`: S3 endpoint URL
|
|
|
|
- `AWS_ACCESS_KEY_ID`: S3 key id
|
|
|
|
- `AWS_SECRET_ACCESS_KEY`: S3 key secret
|
|
|
|
|
2024-11-23 12:28:24 +00:00
|
|
|
## Todos
|
|
|
|
|
2024-12-20 19:48:13 +00:00
|
|
|
- discuss the current design choices for when locking the account/sending a
|
|
|
|
notification email fails.
|
|
|
|
(Current behavior is to periodically retry, avoid deleting if the account
|
|
|
|
could not be locked, but delete the account after the grace period even if
|
|
|
|
the email could not be sent…)
|
2024-12-22 23:50:01 +00:00
|
|
|
- auth: add support for connecting to the forge using oauth?
|
2025-01-03 10:52:54 +00:00
|
|
|
- improve error handling? currently the app will panic if writing to the storage
|
|
|
|
backend fails. Can we do better?
|