Skip to content

mon/AuthMonitor: provide command to rotate the key for a user credential#58121

Merged
batrick merged 4 commits intoceph:mainfrom
batrick:i66509
Jun 23, 2024
Merged

mon/AuthMonitor: provide command to rotate the key for a user credential#58121
batrick merged 4 commits intoceph:mainfrom
batrick:i66509

Conversation

@batrick
Copy link
Member

@batrick batrick commented Jun 18, 2024

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows
  • jenkins test rook e2e

@batrick batrick force-pushed the i66509 branch 2 times, most recently from 6a4ef0e to be4b9ef Compare June 18, 2024 19:39
@batrick
Copy link
Member Author

batrick commented Jun 19, 2024

jenkins test make check

@batrick
Copy link
Member Author

batrick commented Jun 19, 2024

jenkins test api

@batrick
Copy link
Member Author

batrick commented Jun 20, 2024

jenkins test make check

ceph auth get-or-create client.admin2 mon 'allow *'
ceph auth get client.admin2 >> keyring1
env CEPH_KEYRING=keyring1 ceph -n client.admin2 auth get client.admin2 >> keyring2
diff -au keyring1 keyring2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK.

diff -au keyring1 keyring2
# rotate itself
env CEPH_KEYRING=keyring1 ceph -n client.admin2 auth rotate client.admin2 >> keyring3
expect_false diff -au keyring1 keyring3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, secret should be different...

# rotate itself
env CEPH_KEYRING=keyring1 ceph -n client.admin2 auth rotate client.admin2 >> keyring3
expect_false diff -au keyring1 keyring3
expect_false env CEPH_KEYRING=keyring1 ceph -n client.admin2 auth get client.admin2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... so we shouldn't be able to operate using the old one.

expect_true env CEPH_KEYRING=keyring3 ceph -n client.admin2 auth get client.admin2
expect_true ceph auth get client.admin2 >> keyring4
expect_true diff -au keyring3 keyring4
rm keyring[1234]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would love to see a check ensuring the only thing that got changed is the secret itself; particularly that the caps are untouched.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

diff --git a/qa/workunits/cephtool/test.sh b/qa/workunits/cephtool/test.sh
index d024ce6912d4..266f133c6037 100755
--- a/qa/workunits/cephtool/test.sh
+++ b/qa/workunits/cephtool/test.sh
@@ -613,14 +613,20 @@ function test_auth()
   ceph auth get-or-create client.admin2 mon 'allow *'
   ceph auth get client.admin2 >> keyring1
   env CEPH_KEYRING=keyring1 ceph -n client.admin2 auth get client.admin2 >> keyring2
-  diff -au keyring1 keyring2
+  # they are the same:
+  expect_true diff -au keyring1 keyring2
   # rotate itself
   env CEPH_KEYRING=keyring1 ceph -n client.admin2 auth rotate client.admin2 >> keyring3
-  expect_false diff -au keyring1 keyring3
+  # only the key has changed:
+  diff -au keyring1 keyring3 | grep -E '^[-+][^-+]' | expect_false grep -v key
+  # the key in keyring1 no longer works:
   expect_false env CEPH_KEYRING=keyring1 ceph -n client.admin2 auth get client.admin2
+  # the key in keyring3 should work:
   expect_true env CEPH_KEYRING=keyring3 ceph -n client.admin2 auth get client.admin2
+  # now verify the key from `auth get` matches what rotate produced:
   expect_true ceph auth get client.admin2 >> keyring4
   expect_true diff -au keyring3 keyring4
+  expect_true ceph auth rm client.admin2
   rm keyring[1234]
 
   # (almost) interactive mode

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Thank you!

batrick added 4 commits June 20, 2024 21:31
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 <pdonnell@redhat.com>
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
expect_true env CEPH_KEYRING=keyring3 ceph -n client.admin2 auth get client.admin2
expect_true ceph auth get client.admin2 >> keyring4
expect_true diff -au keyring3 keyring4
rm keyring[1234]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Thank you!

@batrick
Copy link
Member Author

batrick commented Jun 22, 2024

This PR is under test in https://tracker.ceph.com/issues/66609.

@batrick
Copy link
Member Author

batrick commented Jun 23, 2024

parth-gr added a commit to parth-gr/rook that referenced this pull request Jun 26, 2025
Ceph has a new ceph auth rotate command currently
present in ceph:main. More: ceph/ceph#58121

Add a cephclient api support to rotate the
cephx keys genrated by cephclient

Signed-off-by: parth-gr <partharora1010@gmail.com>
parth-gr added a commit to parth-gr/rook that referenced this pull request Jun 30, 2025
Ceph has a new ceph auth rotate command currently
present in ceph:main. More: ceph/ceph#58121

Add a cephclient api support to rotate the
cephx keys genrated by cephclient

Signed-off-by: parth-gr <partharora1010@gmail.com>
parth-gr added a commit to parth-gr/rook that referenced this pull request Jun 30, 2025
Ceph has a new ceph auth rotate command currently
present in ceph:main. More: ceph/ceph#58121
Add a cephclient api support to rotate the
cephx keys genrated by cephclient

Signed-off-by: parth-gr <partharora1010@gmail.com>
parth-gr added a commit to parth-gr/rook that referenced this pull request Jul 1, 2025
Ceph has a new ceph auth rotate command currently
present in ceph:main. More: ceph/ceph#58121
Add a cephclient api support to rotate the
cephx keys genrated by cephclient

Signed-off-by: parth-gr <partharora1010@gmail.com>
parth-gr added a commit to parth-gr/rook that referenced this pull request Jul 1, 2025
Ceph has a new ceph auth rotate command currently
present in ceph:main. More: ceph/ceph#58121
Add a cephclient api support to rotate the
cephx keys genrated by cephclient

Signed-off-by: parth-gr <partharora1010@gmail.com>
parth-gr added a commit to parth-gr/rook that referenced this pull request Jul 1, 2025
Ceph has a new ceph auth rotate command currently
present in ceph:main. More: ceph/ceph#58121
Add a cephclient api support to rotate the
cephx keys genrated by cephclient

Signed-off-by: parth-gr <partharora1010@gmail.com>
parth-gr added a commit to parth-gr/rook that referenced this pull request Jul 9, 2025
Ceph has a new ceph auth rotate command currently
present in ceph:main. More: ceph/ceph#58121

Add a new flag `--cephx-key-rotation`  to rotate the
cephx keys genrated by external python script,
If we enable it new ceph user wil be created with
`-rotated` added to the suffix

Signed-off-by: parth-gr <partharora1010@gmail.com>
parth-gr added a commit to parth-gr/rook that referenced this pull request Jul 9, 2025
Ceph has a new ceph auth rotate command currently
present in ceph:main. More: ceph/ceph#58121
Add a new flag `--cephx-key-rotation`  to rotate the
cephx keys genrated by external python script,
If we enable it new ceph user wil be created with
`-rotated` added to the suffix

Signed-off-by: parth-gr <partharora1010@gmail.com>
parth-gr added a commit to parth-gr/rook that referenced this pull request Jul 9, 2025
Ceph has a new ceph auth rotate command currently
present in ceph:main. More: ceph/ceph#58121

Add a new flag `--cephx-key-rotation`  to rotate the
cephx keys genrated by external python script,
If we enable it new ceph user wil be created with
`-rotated` added to the suffix

Signed-off-by: parth-gr <partharora1010@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants