Skip to content

Commit d57326f

Browse files
committed
mon/AuthMonitor: add ceph auth rotate command
Add command to rotate the permanent key of an entity. This avoids the need to delete / recreate the key when it is compromised, lost, or just scheduled for rotation. Fixes: https://tracker.ceph.com/issues/66509 Signed-off-by: Patrick Donnelly <[email protected]>
1 parent 98c986f commit d57326f

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

src/mon/AuthMonitor.cc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,7 @@ bool AuthMonitor::preprocess_command(MonOpRequestRef op)
858858
string prefix;
859859
cmd_getval(cmdmap, "prefix", prefix);
860860
if (prefix == "auth add" ||
861+
prefix == "auth rotate" ||
861862
prefix == "auth del" ||
862863
prefix == "auth rm" ||
863864
prefix == "auth get-or-create" ||
@@ -1825,6 +1826,32 @@ bool AuthMonitor::prepare_command(MonOpRequestRef op)
18251826
wait_for_commit(op, new Monitor::C_Command(mon, op, 0, rs,
18261827
get_last_committed() + 1));
18271828
return true;
1829+
} else if (prefix == "auth rotate") {
1830+
if (entity_name.empty()) {
1831+
ss << "bad entity name";
1832+
err = -EINVAL;
1833+
goto done;
1834+
}
1835+
1836+
EntityAuth entity_auth;
1837+
if (!mon.key_server.get_auth(entity, entity_auth)) {
1838+
ss << "entity does not exist";
1839+
err = -ENOENT;
1840+
goto done;
1841+
}
1842+
1843+
entity_auth.key.create(g_ceph_context, CEPH_CRYPTO_AES);
1844+
1845+
KeyServerData::Incremental auth_inc;
1846+
auth_inc.op = KeyServerData::AUTH_INC_ADD;
1847+
auth_inc.name = entity;
1848+
auth_inc.auth = entity_auth;
1849+
push_cephx_inc(auth_inc);
1850+
1851+
_encode_auth(entity, entity_auth, rdata, f.get());
1852+
wait_for_commit(op, new Monitor::C_Command(mon, op, 0, rs, rdata,
1853+
get_last_committed() + 1));
1854+
return true;
18281855
}
18291856
done:
18301857
rdata.append(ds);

src/mon/MonCommands.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ COMMAND("auth add "
163163
"add auth info for <entity> from input file, or random key if no "
164164
"input is given, and/or any caps specified in the command",
165165
"auth", "rwx")
166+
COMMAND("auth rotate "
167+
"name=entity,type=CephString",
168+
"rotate entity key",
169+
"auth", "rwx")
166170
COMMAND("auth get-or-create-key "
167171
"name=entity,type=CephString "
168172
"name=caps,type=CephString,n=N,req=false",

0 commit comments

Comments
 (0)