Fix Directory: Invalidate caches when group memberships change on an external directory.
This commit is contained in:
@@ -11,6 +11,7 @@ If you are upgrading from v0.16.x, replace the binary (or run `docker pull`). If
|
|||||||
## Changed
|
## Changed
|
||||||
|
|
||||||
## Fixed
|
## Fixed
|
||||||
|
- Directory: Invalidate caches when group memberships change on an external directory.
|
||||||
- Log viewer: All events show as `INFO`.
|
- Log viewer: All events show as `INFO`.
|
||||||
|
|
||||||
## [0.16.2] - 2026-04-28
|
## [0.16.2] - 2026-04-28
|
||||||
|
|||||||
@@ -840,6 +840,9 @@ fn hash_account(account: &Account) -> u64 {
|
|||||||
credential.expires_at.hash(&mut s);
|
credential.expires_at.hash(&mut s);
|
||||||
hash_credential_permissions(&mut s, &credential.permissions);
|
hash_credential_permissions(&mut s, &credential.permissions);
|
||||||
}
|
}
|
||||||
|
for group_id in account.member_group_ids.iter() {
|
||||||
|
group_id.hash(&mut s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Account::Group(account) => {
|
Account::Group(account) => {
|
||||||
account.member_tenant_id.hash(&mut s);
|
account.member_tenant_id.hash(&mut s);
|
||||||
|
|||||||
33
crates/common/src/cache/directory.rs
vendored
33
crates/common/src/cache/directory.rs
vendored
@@ -4,7 +4,9 @@
|
|||||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
|
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use crate::{Server, auth::DomainCache, ipc::BroadcastEvent};
|
use crate::{
|
||||||
|
Server, auth::DomainCache, cache::invalidate::CacheInvalidationBuilder, ipc::BroadcastEvent,
|
||||||
|
};
|
||||||
use registry::{
|
use registry::{
|
||||||
schema::{
|
schema::{
|
||||||
prelude::{Object, ObjectType},
|
prelude::{Object, ObjectType},
|
||||||
@@ -126,10 +128,18 @@ impl Server {
|
|||||||
.await
|
.await
|
||||||
.caused_by(trc::location!())?
|
.caused_by(trc::location!())?
|
||||||
{
|
{
|
||||||
RegistryWriteResult::Success(id) => Ok(AccountWithId {
|
RegistryWriteResult::Success(id) => {
|
||||||
id: id.document_id(),
|
let mut invalidator = CacheInvalidationBuilder::default();
|
||||||
account: updated_account.into(),
|
invalidator.process_update(id, ¤t_account, &updated_account);
|
||||||
}),
|
self.invalidate_caches(invalidator)
|
||||||
|
.await
|
||||||
|
.caused_by(trc::location!())?;
|
||||||
|
|
||||||
|
Ok(AccountWithId {
|
||||||
|
id: id.document_id(),
|
||||||
|
account: updated_account.into(),
|
||||||
|
})
|
||||||
|
}
|
||||||
failure => Err(trc::AuthEvent::Error
|
failure => Err(trc::AuthEvent::Error
|
||||||
.into_err()
|
.into_err()
|
||||||
.caused_by(trc::location!())
|
.caused_by(trc::location!())
|
||||||
@@ -287,17 +297,26 @@ impl Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if has_changes {
|
if has_changes {
|
||||||
|
let updated_account = Object::from(Account::Group(updated_account));
|
||||||
match self
|
match self
|
||||||
.registry()
|
.registry()
|
||||||
.write(RegistryWrite::update(
|
.write(RegistryWrite::update(
|
||||||
Id::from(account_id),
|
Id::from(account_id),
|
||||||
&Object::from(Account::Group(updated_account)),
|
&updated_account,
|
||||||
¤t_account,
|
¤t_account,
|
||||||
))
|
))
|
||||||
.await
|
.await
|
||||||
.caused_by(trc::location!())?
|
.caused_by(trc::location!())?
|
||||||
{
|
{
|
||||||
RegistryWriteResult::Success(id) => Ok(id.document_id()),
|
RegistryWriteResult::Success(id) => {
|
||||||
|
let mut invalidator = CacheInvalidationBuilder::default();
|
||||||
|
invalidator.process_update(id, ¤t_account, &updated_account);
|
||||||
|
self.invalidate_caches(invalidator)
|
||||||
|
.await
|
||||||
|
.caused_by(trc::location!())?;
|
||||||
|
|
||||||
|
Ok(id.document_id())
|
||||||
|
}
|
||||||
failure => Err(trc::AuthEvent::Error
|
failure => Err(trc::AuthEvent::Error
|
||||||
.into_err()
|
.into_err()
|
||||||
.caused_by(trc::location!())
|
.caused_by(trc::location!())
|
||||||
|
|||||||
Reference in New Issue
Block a user