9 – How can I get the list of user permissions through rest API?

This function will return the permissions that have been assigned to a specific user :

use  DrupaluserEntityUser;

function getUserPermissions(User $user) {

$user_roles = $user->getRoles();
$roles_permissions = user_role_permissions($user_roles);

$permissions_array = array();
foreach ($roles_permissions as $role_key => $permissions) {
  foreach ($permissions as $permission) {
    $array() = $permission;
  }

return $permissionsarray;
}


to get the permissions of any user just use the user id ex:

$user = DrupaluserEntityUser::load(123);
$user_permissions = getUserPermissions($user);

Or to get permissions of current user just use:

$user = Drupal::currentUser();
$current_user_permissions =getUserPermissions($user);

Then just inject the result into the RestResource response:

   $response = (
       'current_userpermissons' => $current_user_permissions
     );
   return new ResourceResponse($response);