Investigative tasks (e.g. searching for users as server admin)

This page requires that you have root access to the machines where kubernetes runs on, or have kubernetes permissions allowing you to port-forward arbitrary pods and services.

If you have the backoffice pod installed, see also the backoffice README.

If you don’t have backoffice, see below for some options:

Manually searching for users in cassandra

Terminal one:

kubectl port-forward svc/brig 9999:8080

Terminal two: Search for your user by email:

EMAIL=user@example.com
curl -v -G localhost:9999/i/users --data-urlencode email=$EMAIL; echo
# or, for nicer formatting
curl -v -G localhost:9999/i/users --data-urlencode email=$EMAIL | json_pp

You can also search by handle (unique username) or by phone:

HANDLE=user123
curl -v -G localhost:9999/i/users --data-urlencode handles=$HANDLE; echo

PHONE=+490000000000000 # phone numbers must have the +country prefix and no spaces
curl -v -G localhost:9999/i/users --data-urlencode phone=$PHONE; echo

Which should give you output like:

[
   {
      "managed_by" : "wire",
      "assets" : [
         {
            "key" : "3-2-a749af8d-a17b-4445-b360-46c93fc41bc6",
            "size" : "preview",
            "type" : "image"
         },
         {
            "size" : "complete",
            "type" : "image",
            "key" : "3-2-6cac6b57-9972-4aba-acbb-f078bc538b54"
         }
      ],
      "picture" : [],
      "accent_id" : 0,
      "status" : "active",
      "name" : "somename",
      "email" : "user@example.com",
      "id" : "9122e5de-b4fb-40fa-99ad-1b5d7d07bae5",
      "locale" : "en",
      "handle" : "user123"
   }
]

The interesting part is the id (in the example case 9122e5de-b4fb-40fa-99ad-1b5d7d07bae5):

Deleting a user which is not a team user

The following will completely delete a user, its conversations, assets, etc. The only thing remaining will be an entry in cassandra indicating that this user existed in the past (only the UUID remains, all other attributes like name etc are purged)

You can now delete that user by double-checking that the user you wish to delete is really the correct user:

# replace the id with the id of the user you want to delete
curl -v localhost:9999/i/users/9122e5de-b4fb-40fa-99ad-1b5d7d07bae5 -XDELETE

Afterwards, the previous command (to search for a user in cassandra) should return an empty list ([]).

When done, on terminal 1, ctrl+c to cancel the port-forwarding.

How to manually delete a user from elasticsearch only

Warning

This is NOT RECOMMENDED. Be sure you know what you’re doing. This only deletes the user from elasticsearch, but not from cassandra. Any change of e.g. the username or displayname of that user means this user will re-appear in the elasticsearch database. Instead, either fully delete a user: Deleting a user which is not a team user or make use of the internal GET/PUT /i/searchable endpoint on brig to make this user prefix-unsearchable.

If, despite the warning, you wish to continue?

First, ssh to an elasticsearch instance.

Next, check that the user exists:

UUID=...
curl -s "http://localhost:9200/directory/user/$UUID" | json_pp

That should return a "found": true, like this:

{
   "_type" : "user",
   "_version" : 1575998428262000,
   "_id" : "b3e9e445-fb02-47f3-bac0-63f5f680d258",
   "found" : true,
   "_index" : "directory",
   "_source" : {
      "normalized" : "Mr Test",
      "handle" : "test12345",
      "id" : "b3e9e445-fb02-47f3-bac0-63f5f680d258",
      "name" : "Mr Test",
      "accent_id" : 1
   }
}

Then delete it:

UUID=...
curl -s -XDELETE "http://localhost:9200/directory/user/$UUID" | json_pp