forked from fschmtt/keycloak-rest-api-client-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrealms-all.php
More file actions
34 lines (26 loc) · 910 Bytes
/
Copy pathrealms-all.php
File metadata and controls
34 lines (26 loc) · 910 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
29
30
31
32
33
34
<?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();
$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);
}