-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: homeserver signup tokens #74
Comments
Some thoughts. I like the general direction but I think we can make it better. Let me know what you think. Admin UserWhy not simplify it and just set a admin password in LMDB? Single admin user either with a default password or a password that can be set with the cli that the user can change after the first signin. This is easier to program. Most applications like LND have this. Multi-user is a lot more effort. Signup tokensIt is important to know what type of tokens we want. You describe onetime use here. If we want to go for a user attached tokens, the system and database models would look very different (see Bluesky summary here). As far as I see, we need onetime tokens for the invite only beta and might want Bluesky style invite codes after. I personally don't see Bluesky style invite codes as Sybil prevention so that's another conversation we should have. Likely best to consult with @BitcoinErrorLog here. Signup Mode
What about we create a config called
Token Format
I don't think we need to go that hard. Shorter tokens should be sufficient and are way easier to handle. Think about the conference use case: A person gets a small card with a token printed on it which then needs to type in the signup form on his phone. |
Agree, we can make this simpler. The idea above tried to reuse our existing pubky_ids for admins as well. But in the spirit of KISS we can protect the new endpoints with a password directly coming from the
Yes! Much better.
This gets difficult quickly and we risk over-complicating. I think for now it's safe to stick to "you need a signup token generated by the homeserver admin" . Always by admin, and how you get it is out of question. This is how most homeservers will likely operate anyway (single user, or a user and family/friends). If we, on our own hosted homeserver, want users to be able to invite other users there is many ways to implement such feature by reusing "only tokens by admin". E.g., the homeserver runner could private message in
Yeah, I think this is good! It's also OK if this config is not even exposed on pubky-core/pubky-homeserver/src/config.rs Lines 61 to 70 in bc7c723
pubky-core/pubky-homeserver/src/io/mod.rs Lines 158 to 169 in bc7c723
And we set it to pubky-core/pubky-homeserver/src/config.rs Lines 103 to 113 in bc7c723
pubky-core/pubky-homeserver/src/io/mod.rs Lines 94 to 98 in bc7c723
|
Sounds good. About signup tokens and nexus: In theory, tokens should give you access to the homeserver and nexus. This implies some coordination though because both the homeserver and nexus require the same token. To solve this problem, I propose the following:
Maybe I am just repeating what you guys were already planning but I think this is the most sensible and simplest approach. What do you think? |
This is it. For now Nexus can only track one homeserver. Different spam protection mechanisms are envisioned for future multi-homeserver. But in no case an auth token is needed 👌 |
There is 2 features here: 1) admin endpoints, and 2) signup tokens. Luckily for us: we can use admin endpoints to create new signup tokens. And we can use a special signup token, to create an admin. BOOOOOOM 🤯
Signup Tokens:
/generate_tokens
.Admin/Master Signup Token:
config.toml
and used only during initial setup.Implementation Plan Proposal
I've been looking in detail for every step involved into implementation of this feature. Of course, every plan is to be broken and improved as we go :) Consider this a "mental dry run" of how to go about it:
Admin Infrastructure
admin: bool
field./admin
) for admin endpoints.Add a "master" signup token
Users who do signup with the "master" signup token, will get the
admin: bool
true
.config.toml
and the configuration parser to add an optional fieldmaster_signup_token
. Extend theConfig
struct to include this master token.Signup Tokens Table
signup_tokens
). Design the schema with fields:token: String
created_at: u64
-
expires_at: Option<u64>
(just an idea: not needed just yet, we don't need codes to expire for now!)used: Option<PublicKey>
(ifNone
, token is unused; ifSome(user_id)
, record the consuming user). Advanced: could (should?) also be a vector of users, just in case we want to allow multiple signups with a token (e.g., we need it if we want several admins with the samemaster_signup_token
)Modify the Signup Endpoint
signup_token
query parameter.signup_token
from query parameters.2.1. If the provided token equals the configured master token, proceed and mark the new user as admin.
3.1. If not master, look up the token in the
signup_tokens
table.3.2. Verify that the token exists, is not expired, and is unused.
3.3. Mark the token as used by storing the consuming user’s public key.
Admin Endpoints for Signup Token Management
POST /admin/generate_signup_token
):JBSW-Y3DP-EHPK-3PXQ-XR6M-7N2F-LM
this).signup_tokens
table and return the token.Advanced: optionally in the future add endpoints for listing and revoking tokens. These would be useful for the Homeserver Dashboard.
Pubky Client
client.signup(... signup_token)
client.gen_signup_token()
that returns a new valid signup token.Optional Signup Tokens
None
instead. This will be tremendously useful, so testing does not become cumbersome. Every single test creates a homeserver, we don't want to always need to signup a admin, generate a token, etc in all testing workflows. We could also make it sotestnet
homeserver are always codeless/unprotected by default.The text was updated successfully, but these errors were encountered: