Merge pull request 'keycloak/delete-unverified-accounts.md: Delete temp files in the end' () from keycloak-temp-file-del into main

Reviewed-on: 
Reviewed-by: teutat3s <teutat3s@noreply.git.pub.solar>
This commit is contained in:
Akshay Mankar 2025-02-01 12:56:58 +00:00
commit 6c0d41024e
Signed by: pub.solar gitea
GPG key ID: F0332B04B7054873

View file

@ -12,7 +12,7 @@ Run following after SSH'ing to `nachtigall`.
Credentials for the following command are in keepass. Create a keycloak
config/credentials file at `/tmp/kcadm.config`:
```
```bash
sudo --user keycloak kcadm.sh config credentials \
--config /tmp/kcadm.config \
--server https://auth.pub.solar \
@ -22,7 +22,7 @@ sudo --user keycloak kcadm.sh config credentials \
Get list of accounts without a verified email address:
```
```bash
sudo --user keycloak kcadm.sh get \
--config /tmp/kcadm.config \
users \
@ -35,7 +35,7 @@ Review list of accounts, especially check `createdTimestamp` if any accounts
were created in the past 2 days. If so, delete those from the
`/tmp/keycloak-unverified-accounts` file.
```
```bash
createdTimestamps=( $( nix run nixpkgs#jq -- -r '.[].createdTimestamp' < /tmp/keycloak-unverified-accounts ) )
# timestamps are in nanoseconds since epoch, so we need to strip the last three digits
@ -46,17 +46,17 @@ vim /tmp/keycloak-unverified-accounts
Check how many accounts are going to be deleted:
```
```bash
jq -r '.[].id' < /tmp/keycloak-unverified-accounts | wc -l
```
```
```bash
jq -r '.[].id' < /tmp/keycloak-unverified-accounts > /tmp/keycloak-unverified-account-ids
```
Final check before deletion (dry-run):
```
```bash
for id in $(cat /tmp/keycloak-unverified-account-ids)
do
echo sudo --user keycloak kcadm.sh delete \
@ -68,7 +68,7 @@ for id in $(cat /tmp/keycloak-unverified-account-ids)
THIS WILL DELETE ACCOUNTS:
```
```bash
for id in $(cat /tmp/keycloak-unverified-account-ids)
do
sudo --user keycloak kcadm.sh delete \
@ -77,3 +77,9 @@ for id in $(cat /tmp/keycloak-unverified-account-ids)
--realm pub.solar
done
```
Delete the temp files:
```bash
sudo rm /tmp/kcadm.config /tmp/keycloak-unverified-accounts /tmp/keycloak-unverified-account-ids
```