how can I get a list of all of the permissions a user has? if I have the current user object, how can i get a list of all of the permissions he has in drupal 8 custom module ?  I dont want to check for one particular permission which would be $current_user->hasPermission("permission_name").

I want to get the entire list of his permissions.

thanks
Can you try the following snippet:

$user = \Drupal::currentUser();
$user_roles = $user-&gt;getRoles();
$roles_permissions = user_role_permissions($user_roles);


This will give you permissions grouped by roles.
But most likely you want them in one array.

Therefore you can use this

$final_array = array();
foreach ($roles_permissions as $role_key =&gt; $permissions) {
  foreach ($permissions as $permission) {
    $final_array[] = $permission;
  }
}


In case you want to load different user than the currently logged-in user, you can use

$some_user = \Drupal\user\Entity\User::load(123);


Where 123 stands for the user id.
For more information:

https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21Entity.php/function/Entity%3A%3Aload/8.2.x

Best regards,

Oleg