Skip to content

Conversation

missytake
Copy link
Contributor

@missytake missytake commented Jul 8, 2025

fix #594


To restrict address creation for anyone who doesn't have the invite link/QR code:

  1. Use the invite_token option to add one or more tokens of your choice to chatmail.ini: invite_token = s3cr3t privil3g3
    • (recommendation: choose 9 or more letters, or it will be easily bruteforced)
  2. Run scripts/cmdeploy run
  3. Distribute a dcaccount invite link/QR code (like the one on your web page) with one of your invite tokens added at the end, for example: dcaccount:https://example.org/new?s3cr3t

To try it out: dcaccount:https://c17.testrun.org/new?asdf
(Right now broken client-side because of chatmail/core#6988)

image

@missytake missytake changed the base branch from main to fix-dovecot-deb July 8, 2025 14:40
Base automatically changed from fix-dovecot-deb to main July 8, 2025 19:41
@missytake missytake changed the title doveauth: add invite_token to override nocreate file WIP: doveauth: add invite_token to override nocreate file Jul 9, 2025
@missytake
Copy link
Contributor Author

missytake commented Jul 9, 2025

Hm -.-

right now, when I run curl -X POST https://c17.testrun.org/new?asdf, it responds with a passphrase that contains asdf.

but when I copy the very same URL into Delta Chat's "create new profile > use other server > scan invitation code", it tries to login with a passphrase which doesn't contain asdf. It seems the ?asdf parameter is stripped when Delta Chat sends a POST request?
When I login manually with a passphrase that contains asdf it works.

@missytake
Copy link
Contributor Author

So server-side everything works, just client-side it doesn't.

@missytake missytake changed the title WIP: doveauth: add invite_token to override nocreate file doveauth: add invite_token to override nocreate file Jul 9, 2025
@missytake
Copy link
Contributor Author

So server-side everything works, just client-side it doesn't.

With 2.x.x it works :) So we can merge this now.

@dillfrescott
Copy link

Awesome, can't wait for the merge! Good job!

Copy link
Contributor

@hpk42 hpk42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Could you add docs to the README to tell how to use this invite token? I am not sure yet i understand how this is overall supposed to be used from admins and users.

  2. I am dubious about nocreate override -- i think nocreate should remain absolute and block all account creation (if your server is overwhelmed with creation requests, you first want to stop it, and then analyze what happens -- might be a leaked invite token).


if len(cleartext_password) < config.password_min_length:
if (
len(cleartext_password.replace(config.invite_token, ""))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can randomly fail depending on the invite_token (might be short)
I think there should be a fixed "{invite_token}:password" format, and then do a more specific check.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd leave out the :, as it could be part of the password; but yes, the invite_token needs to be at the beginning of the password now, that is what newemail.py generates anyway.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if someone makes eg a 4-char invite code there might still be random passwords that match it, i am afraid.

@missytake missytake changed the title doveauth: add invite_token to override nocreate file doveauth: add invite_tokens to restrict access Sep 11, 2025
@missytake
Copy link
Contributor Author

missytake commented Sep 11, 2025

  1. Could you add docs to the README to tell how to use this invite token? I am not sure yet i understand how this is overall supposed to be used from admins and users.

Do we want it to be easy to find? Personally I'd leave it out of the README.md and point anyone who really asks for it to this PR description instead.

The chatmail ecosystem will be much more resilient and anonymous if people can generally sign up on relays of people they don't know. I get why some people need a fence, so I built a fence; but we want to have a public park, not a Kleingartenverein.

@missytake missytake requested a review from hpk42 September 11, 2025 23:41
@missytake missytake changed the title doveauth: add invite_tokens to restrict access doveauth: add invite_tokens to restrict address creation Sep 11, 2025
@hpk42
Copy link
Contributor

hpk42 commented Sep 12, 2025

if invite codes are set, then normal QR codes without an invite token (like the one on the web page) don't work anymore, right?
The web-page needs to not show the QR code then and instead a message that an invite is needed.

Also, the invite code maybe needs have a minimum length of 9 or so because otherwise someone can brute force account creation (invite tokens with 4 characters for example are probably easy to crack in a few days, even without showing up in monitoring, it's just ~1M combinations, can be tried with one password per second, and in ten days you have the invite token).

Given that the recommended UX flow is the QR code / link, it doesn't matter that it becomes harder to type manually by requiring long invite codes. Besides, chatmail.ini so far contains no secrets and can be public in some repo even -- with the invite codes it's more sensitive.

Lastly, i am still grappling with the overall idea and the implications of invite links. Not 100% convinced yet.

@missytake
Copy link
Contributor Author

missytake commented Sep 12, 2025

if invite codes are set, then normal QR codes without an invite token (like the one on the web page) don't work anymore, right? The web-page needs to not show the QR code then and instead a message that an invite is needed.

Done :)

Also, the invite code maybe needs have a minimum length of 9 or so because otherwise someone can brute force account creation (invite tokens with 4 characters for example are probably easy to crack in a few days, even without showing up in monitoring, it's just ~1M combinations, can be tried with one password per second, and in ten days you have the invite token).

True, I added a recommendation on token length to the README and the PR description. Enforcing it would add complexity for showing error messages; let's hope admins can read and choose risks.

Given that the recommended UX flow is the QR code / link, it doesn't matter that it becomes harder to type manually by requiring long invite codes. Besides, chatmail.ini so far contains no secrets and can be public in some repo even -- with the invite codes it's more sensitive.

True, but I don't think it will become a problem. So far I haven't seen a chatmail.ini in a public repository - and if you have public sysadmin docs, you anyway need to think about how to avoid committing secrets. I'd say, if someone asks, we can allow setting invite tokens per environment variable.

Lastly, i am still grappling with the overall idea and the implications of invite links. Not 100% convinced yet.

Same tbh. This PR is fun to implement though :D and I think the compromise of implementing it but hiding the documentation in a GitHub PR is good enough, as some people seem to need this feature. Then again - once it's in the world, it's hard to put back in the box :/

@missytake missytake requested a review from hpk42 September 12, 2025 10:46
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.

[Feature request] Invite-only server
3 participants