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();
|
newKey.setInvalid();
|
||||||
}
|
}
|
||||||
db.accountSshKeys().insert(Collections.singleton(newKey));
|
db.accountSshKeys().insert(Collections.singleton(newKey));
|
||||||
|
SshUtil.invalidate(db.accounts().get(me));
|
||||||
return newKey;
|
return newKey;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -96,6 +97,7 @@ public class AccountSecurityImpl extends BaseServiceImplementation implements
|
|||||||
final Transaction txn = db.beginTransaction();
|
final Transaction txn = db.beginTransaction();
|
||||||
db.accountSshKeys().delete(k, txn);
|
db.accountSshKeys().delete(k, txn);
|
||||||
txn.commit();
|
txn.commit();
|
||||||
|
SshUtil.invalidate(db.accounts().get(me));
|
||||||
}
|
}
|
||||||
|
|
||||||
return VoidResult.INSTANCE;
|
return VoidResult.INSTANCE;
|
||||||
|
@@ -139,8 +139,10 @@ public class SshUtil {
|
|||||||
|
|
||||||
/** Invalidate all cached keys for the given account. */
|
/** Invalidate all cached keys for the given account. */
|
||||||
public static void invalidate(final Account acct) {
|
public static void invalidate(final Account acct) {
|
||||||
synchronized (keys) {
|
if (acct != null) {
|
||||||
keys.remove(acct.getPreferredEmail());
|
synchronized (keys) {
|
||||||
|
keys.remove(acct.getPreferredEmail());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user