Client Scopes Manager¶
Client Scope Class¶
The class ClientScope is a
Client Scope Representation.
To use Client Scope Manager, you need to pass the Realm that you will work with.
| Class | File |
|---|---|
KeycloakAdmin\ClientScopes\ClientScope |
src/ClientScopes/ClientScope.php |
List Client Scopes¶
This method returns a collection of client scopes of specific Realm.
Usage¶
public function listClientScopes()
{
$collectionOfClientScopes = $this->admin
->clientScope('my-realm')
->list();
foreach ($collectionOfClientScopes as $scope) {
var_dump($scope->getAttributes());
}
}
Save Client Scope¶
This method returns will save a new Client Scope on specific Realm.
Usage¶
public function createClientScope(string $id, string $name)
{
$myClientScope = [
'id' => $id,
'name' => $name
];
$clientScope = $this->admin->clientScope('my-realm')
->createFromArray($myClientScope)
->save();
}
Show Client Scope¶
This method returns a Client Scope, you need to pass the parameter realmName and must pass the $id. If Client Scope was not found, you will receive an Exception.
Usage¶
public function showClientScope(string $id) : Client
{
return $this->admin->clientScope('my-realm')
->show($id);
}
Update Client Scope¶
This method will update a Client Scope, an instance of Client Scope must be created
before call to update. This expects at least id to can update.
In this Library, you can’t update the client scope id.
Usage¶
public function update(string $id, array $params = []) : Client
{
$data = [
'id' => $id
] + $params;
return $this->admin->clientScope('my-realm')
->createFromArray($data)
->update();
}
Delete Client Scope¶
This method will delete a Client Scope, id must be passed as parameter.
If an error occurs you will receive an Exception otherwise, this
is a void method
Usage¶
public function delete(string $id)
{
try {
$this->admin->clientScope('my-realm')
->delete($id);
} catch (\Exception $e) {
var_dump('cant delete this client, ' . $e->getMessage());
}
}
Protocol Mappers¶
This is a manager for client protocol mappers manager. Check Protocol Mappers Manager. chapter.
public function protocolMapperExample(string $id)
{
$collectionOfProtocolMappers = $this->admin
->clientScope('my-realm')
->protocolMappers($id)
->list();
// do something cool
}