-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathrealms-all.php
34 lines (26 loc) · 841 Bytes
/
realms-all.php
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
29
30
31
32
33
34
<?php
declare(strict_types=1);
use Fschmtt\Keycloak\Keycloak;
require_once __DIR__ . '/../vendor/autoload.php';
$keycloak = new Keycloak(
baseUrl: $_SERVER['KEYCLOAK_BASE_URL'] ?? 'http://keycloak:8080',
username: 'admin',
password: 'admin',
);
$realms = $keycloak->realms()->all();
foreach ($realms as $realm) {
echo sprintf(
'Realm "%s" %s registrations%s',
$realm->getRealm(),
$realm->getRegistrationAllowed() ? 'allows' : 'forbids',
PHP_EOL,
);
echo sprintf(
'Realm "%s" has the following %d default groups: %s%s',
$realm->getRealm(),
$realm->getDefaultGroups() ? count($realm->getDefaultGroups()) : 0,
$realm->getDefaultGroups() ? implode(',', $realm->getDefaultGroups()) : '',
PHP_EOL,
);
echo sprintf('---%s', PHP_EOL);
}