Invalidate the SSH key cache when a user's keys change
Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -76,6 +76,7 @@ public class AccountSecurityImpl extends BaseServiceImplementation implements
|
||||
newKey.setInvalid();
|
||||
}
|
||||
db.accountSshKeys().insert(Collections.singleton(newKey));
|
||||
SshUtil.invalidate(db.accounts().get(me));
|
||||
return newKey;
|
||||
}
|
||||
});
|
||||
@@ -96,6 +97,7 @@ public class AccountSecurityImpl extends BaseServiceImplementation implements
|
||||
final Transaction txn = db.beginTransaction();
|
||||
db.accountSshKeys().delete(k, txn);
|
||||
txn.commit();
|
||||
SshUtil.invalidate(db.accounts().get(me));
|
||||
}
|
||||
|
||||
return VoidResult.INSTANCE;
|
||||
|
@@ -139,8 +139,10 @@ public class SshUtil {
|
||||
|
||||
/** Invalidate all cached keys for the given account. */
|
||||
public static void invalidate(final Account acct) {
|
||||
synchronized (keys) {
|
||||
keys.remove(acct.getPreferredEmail());
|
||||
if (acct != null) {
|
||||
synchronized (keys) {
|
||||
keys.remove(acct.getPreferredEmail());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user