Skip to content

Commit 2c2dd52

Browse files
committed
Auth: Keep OTP Auth and AppPasswords unless the remote directory provides new ones (fixes #2319)
1 parent 8cee757 commit 2c2dd52

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

crates/directory/src/core/principal.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,8 @@ impl Principal {
308308
let mut has_role = false;
309309
let mut has_member_of = false;
310310
let mut has_quota = false;
311+
let mut has_otp_auth = false;
312+
let mut has_app_password = false;
311313

312314
for item in external.data {
313315
match item {
@@ -323,9 +325,15 @@ impl Principal {
323325
has_role = true;
324326
external_data.insert(item);
325327
}
328+
PrincipalData::OtpAuth(_) => {
329+
has_otp_auth = true;
330+
external_data.insert(item);
331+
}
332+
PrincipalData::AppPassword(_) => {
333+
has_app_password = true;
334+
external_data.insert(item);
335+
}
326336
PrincipalData::Password(_)
327-
| PrincipalData::AppPassword(_)
328-
| PrincipalData::OtpAuth(_)
329337
| PrincipalData::Description(_)
330338
| PrincipalData::PrimaryEmail(_)
331339
| PrincipalData::EmailAlias(_) => {
@@ -352,6 +360,8 @@ impl Principal {
352360
if external_data.remove(&item)
353361
|| match item {
354362
PrincipalData::EmailAlias(_) => true,
363+
PrincipalData::AppPassword(_) => !has_app_password,
364+
PrincipalData::OtpAuth(_) => !has_otp_auth,
355365
PrincipalData::Role(_) => !has_role,
356366
PrincipalData::MemberOf(_) => !has_member_of,
357367
PrincipalData::DiskQuota(_) => !has_quota,

0 commit comments

Comments
 (0)