Browse Source

touch .refresh_ssh_keys when keys need refreshing

tags/v0.1.6
Jonathan Cobb 4 years ago
parent
commit
1e3de575ce
1 changed files with 11 additions and 9 deletions
  1. +11
    -9
      bubble-server/src/main/java/bubble/dao/account/AccountSshKeyDAO.java

+ 11
- 9
bubble-server/src/main/java/bubble/dao/account/AccountSshKeyDAO.java View File

@@ -6,6 +6,10 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;


import java.io.File;

import static bubble.ApiConstants.HOME_DIR;
import static org.cobbzilla.util.io.FileUtil.touch;
import static org.cobbzilla.util.security.RsaKeyPair.isValidSshPublicKey; import static org.cobbzilla.util.security.RsaKeyPair.isValidSshPublicKey;
import static org.cobbzilla.util.security.ShaUtil.sha256_hex; import static org.cobbzilla.util.security.ShaUtil.sha256_hex;
import static org.cobbzilla.wizard.resources.ResourceUtil.invalidEx; import static org.cobbzilla.wizard.resources.ResourceUtil.invalidEx;
@@ -50,26 +54,24 @@ public class AccountSshKeyDAO extends AccountOwnedEntityDAO<AccountSshKey> {
} }


@Override public AccountSshKey postCreate(AccountSshKey key, Object context) { @Override public AccountSshKey postCreate(AccountSshKey key, Object context) {
if (key.installSshKey()) {
// poke SSH key manager, refresh installed keys
}
if (key.installSshKey()) refreshInstalledKeys();
return super.postCreate(key, context); return super.postCreate(key, context);
} }


@Override public AccountSshKey postUpdate(AccountSshKey key, Object context) { @Override public AccountSshKey postUpdate(AccountSshKey key, Object context) {
final Account owner = accountDAO.findByUuid(key.getAccount()); final Account owner = accountDAO.findByUuid(key.getAccount());
if (owner.admin()) {
// poke SSH key manager, refresh installed keys
}
if (owner.admin()) refreshInstalledKeys();
return super.postUpdate(key, context); return super.postUpdate(key, context);
} }


@Override public void delete(String uuid) { @Override public void delete(String uuid) {
final AccountSshKey key = findByUuid(uuid); final AccountSshKey key = findByUuid(uuid);
super.delete(uuid); super.delete(uuid);
if (key.installSshKey()) {
// poke SSH key manager, refresh installed keys
}
if (key.installSshKey()) refreshInstalledKeys();
} }


// refresh_bubble_ssh_keys_monitor.sh watches this file (in ansible bubble role)
private static final File REFRESH_SSH_KEYS_FILE = new File(HOME_DIR, ".refresh_ssh_keys");
private void refreshInstalledKeys() { touch(REFRESH_SSH_KEYS_FILE); }

} }

Loading…
Cancel
Save