-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathusers-all.php
More file actions
28 lines (19 loc) · 755 Bytes
/
Copy pathusers-all.php
File metadata and controls
28 lines (19 loc) · 755 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
declare(strict_types=1);
use Fschmtt\Keycloak\Builder;
use Fschmtt\Keycloak\OAuth\GrantType;
require_once __DIR__ . '/../vendor/autoload.php';
$keycloak = (new Builder())
->withBaseUrl($_SERVER['KEYCLOAK_BASE_URL'] ?? 'http://keycloak:8080')
->withGrantType(GrantType::password('admin', 'admin'))
->build();
$realm = 'master';
$users = $keycloak->users()->all($realm);
echo sprintf('Realm "%s" has the following users:%s', $realm, PHP_EOL);
foreach ($users as $user) {
echo sprintf('-> User "%s"%s', $user->getUsername(), PHP_EOL);
echo sprintf('--> Required actions:%s', PHP_EOL);
foreach ($user->getRequiredActions() ?? [] as $requiredAction) {
echo sprintf('---> %s%s', $requiredAction, PHP_EOL);
}
}