-
Notifications
You must be signed in to change notification settings - Fork 16
Option for users to only register with an invite link. #30
Comments
Proposal for invitation specification:
There is NO secret data that is stored on the server for making a Invitation.
Making a Token.
Using a Token.
Upon Successful registration the server allocates:
If the Registration somehow fails or has a time-out, the Server unlocks the Invitation Slot Rust Blake3: https://docs.rs/blake3/latest/blake3/ A Invitation-code is encoded with: Bech32m.
The Bech32m Encoding is both Encoded and Decoded on the Fronted. |
I have written a proposal for the protocol for the Invitations. This protocol avoids the server storing any secrets for the creation of invitations. |
it is a good idea. I will help to implement it like this |
@BelieveInBunny I have updated the proposal to assure that a hashed token cannot be reused in multiple invitations. (using a server supplied salt). |
@WarmBeer, @BelieveInBunny, @george-avn My first protocol proposal works in a similar way as hashed passwords, the server doesn't store any passwords directly, but only a hashed image of the password (appropriately salted of-course). If the hashed-password database was public, nobody would be able to instantly log-in because to authenticate one must provide the pre-image to the hashed password i.e. (password || salt). The limitation of this approach is that for every user-secret there needs to have an associated hashed image that is registered on the server. Meaning that the user must inform the server about any new tokens. The naïve approach is to instead to store a secret on the server. To generate a new token, a secret and token iterator are hashed encrypted, i.e (hash(secret || nonce). The user then gives the token-bearer the hashed secret and the nonce. When the token-bearer supplies this to the server, the sever can hash the nonce with the stored secret and check the validity of the encrypted hashed token. This approach allows the user to generate new tokens independently without coordination with the server. i.e. offline. The problem is that we have moved back to the original insecurity of the server holding secrets, anyone with access to the servers secret store can impersonate any token they want. The correct approach to allow for independent token generation is to use cryptographic signatures. The users registers their public key with the server. To generate a token the user signs the token with their private key, producing a secure signature. The token-bearer bring this signed token to the server, who verifies the signature against the pre-registered public key. This approach has none of the downfalls of the other approaches, tokens can be generated independently of the sever, and there is no secret data that is stored inside the server's databases. The problem is that is slightly harder to implement, and the tokens are a little larger. (maybe 80bytes instead of 30bytes). I am considering to write another protocol that uses the cryptographic signature approach, as it is much more future-proof; and the allowance for independent token generation is very useful. (Another 'Invitation Server' could be set-up, and generate tokens based upon it's own policy; it would not need to communicate with any other server). |
@BelieveInBunny Great! I will write the signed invitation specification, until then work on the other tasks. 👍 |
Noted with thanks |
Signed Invitation CodesThis is an alternative specification for making Invitation Codes. This specification has a specific advantage on-top-of the Normal Invitation Codes: Non-Interactive Code Generation. Non-Interactive Code GenerationNo-interactive code generation allows for a user to create new invitation codes without any additional communication with the server. This would allow for example an invitation server or bot to give out codes without needing to continually connect to the Torrust Backend API. Signed Invitations Overview
Technology UsedUsing standard schnorr signatures for secp256k1. Used by Bitcoin in the recent Taproot Upgrade. BIP340 - Schnorr Signatures for secp256k1 (The Signing Algorithm) SpecificationIntroductionUsers of Torrust should easily be able to invite their friends to also use Torrust. One option, when public facing registrations have closed, is that uses are granted a certain amount of 'invitation slots' that their friends may use. Users who invite other users should be linked, so that the Torrust Administrators can easily resolve issues when invitations have unfortunately brought unfriendly people into the community. Power-Users may want to setup systems that allow them to automatically generate new invitations. It is convenient for these systems to run independently without need of a connection to the Torrust-Backend API. The Torrust-Backend should not store any secrets from the users. Just like the use of appropriately implemented hashed passwords, likewise invitations should not rely on secrets held by the backend. Backend DatabaseInvitationsTABLE
Invitation SlotsTABLE
User Public KeysTABLE
UserTABLE
Invitation Format
Encoded Formats.
The invitation is encoded and decoded by the frontend. |
@WarmBeer @BelieveInBunny @george-avn Please Review. 👍 |
Hey @da2ce7 , Thank you for the very interesting and detailed proposal. I am however a little bit ignorant of the use case of such a complicated user invitation system. Could you explain to me the benefit of generating these invitation tokens independently from a Torrust Index backend so I understand why this is needed? |
Hey @WarmBeer, Sure, There are in-fact two competing proposals: Invitation Codes (Interactive Code Generation): torrust/torrust-index#30 (comment) Signed Invitation Codes (Non-interactive Code Generation): torrust/torrust-index#30 (comment) The main advantage of the non-interactive code generation in the case that this software becomes very popular.
Overall I think that it is a cool thing to have, so "coolness factor" may be a thing. When you have public keys connected to an account, we could extend the same system to work as account-recovery or two-factor, or even implement other privacy features. :) Cam. |
Hey @da2ce7 , I made an activity diagram of what happens when the backend receives a user registration request. We talked about how to store pending user registrations in the database and how to clean them up. The ideas we discussed were: 1. Create a separate DB table "pending_users" and store new users in that table until they are verified (on which they will move to the "user" table). The table will also have a scheduler to automatically expire rows that didn't verify in time. Pros:
Cons:
2. Keep using the "emailed_verified" flag in the "users" table. The backend will then have to run a cronjob to remove users that took too long to verify their email. Pros:
Cons:
While working on the activity diagram, I thought of another solution: 3. Store unverified accounts in memory (with something like Redis) and only submit them to the "user" database on verification. Pros:
Cons:
Let me know what you think :) |
Option for new users to only be able to register with a generated invite link.
The text was updated successfully, but these errors were encountered: