Skip to content

Commit 8a002dc

Browse files
committed
Always generate a new auth token
1 parent 29e39a7 commit 8a002dc

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/securejoin.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use crate::qr::check_qr;
2323
use crate::securejoin::bob::JoinerProgress;
2424
use crate::sync::Sync::*;
2525
use crate::token;
26+
use crate::tools::create_id;
2627
use crate::tools::time;
2728

2829
mod bob;
@@ -76,10 +77,21 @@ pub async fn get_securejoin_qr(context: &Context, group: Option<ChatId>) -> Resu
7677
let sync_token = token::lookup(context, Namespace::InviteNumber, grpid)
7778
.await?
7879
.is_none();
79-
// invitenumber will be used to allow starting the handshake,
80-
// auth will be used to verify the fingerprint
80+
// Invite number is used to request the inviter key.
8181
let invitenumber = token::lookup_or_new(context, Namespace::InviteNumber, grpid).await?;
82-
let auth = token::lookup_or_new(context, Namespace::Auth, grpid).await?;
82+
83+
// Auth token is used to verify the key-contact
84+
// if the token is not old
85+
// and add the contact to the group
86+
// if there is an associated group ID.
87+
//
88+
// We always generate a new auth token
89+
// because auth tokens "expire"
90+
// and can only be used to join groups
91+
// without verification afterwards.
92+
let auth = create_id();
93+
token::save(context, Namespace::Auth, grpid, &auth).await?;
94+
8395
let self_addr = context.get_primary_self_addr().await?;
8496
let self_name = context
8597
.get_config(Config::Displayname)

0 commit comments

Comments
 (0)