Skip to content

Commit

Permalink
Merge pull request #107 from MohammadWaleed/develop
Browse files Browse the repository at this point in the history
prepare for 0.36.0
  • Loading branch information
MohammadWaleed authored Apr 3, 2023
2 parents db3e12a + 22ef316 commit 81edfd7
Show file tree
Hide file tree
Showing 4 changed files with 247 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,12 @@ Note: Ids are sent as clientScopeId or clientId and mapperId everything else is
| Get the events provider configuration Returns JSON object with events provider configuration | getEventsConfig | ✔️ |
| Update the events provider Change the events provider and/or its configuration | updateEventsConfig | ✔️ |
| Get user group by path | getGroupByPath | ✔️ |
| GET /{realm}/localization | getLocalizationLocales | ✔️ |
| POST /{realm}/localization/{locale} | updateLocalizationTexts | ✔️ |
| GET /{realm}/localization/{locale} | getLocalizationTexts | ✔️ |
| DELETE /{realm}/localization/{locale} | deleteLocalizationTexts | ✔️ |
| GET /{realm}/localization/{locale}/{key} | getLocalizationText | ✔️ |
| PUT /{realm}/localization/{locale}/{key} | saveLocalizationText | ✔️ |
| Removes all user sessions. (Keycloak throws an exception when this one is called) | logoutAllUsers | ❌ |
| Partial export of existing realm into a JSON file. | partialExportRealm | ✔️ |
| Partial import from a JSON file to an existing realm. | partialImportRealm | ✔️ |
Expand Down
62 changes: 62 additions & 0 deletions src/Admin/Classes/FullTextLocation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

namespace Keycloak\Admin\Classes;

use GuzzleHttp\Command\CommandInterface;
use GuzzleHttp\Command\Guzzle\Parameter;
use GuzzleHttp\Psr7;
use Psr\Http\Message\MessageInterface;
use Psr\Http\Message\RequestInterface;
use GuzzleHttp\Command\Guzzle\RequestLocation\AbstractLocation;

use Psr\Http\Message\StreamInterface;

/**
* Adds a raw text body to a request
*/
class FullTextLocation extends AbstractLocation
{
/**
* @var string Whether or not to add Content-Type header
*/
private $contentType;

/**
* @param string $locationName Name of the location
* @param string $contentType Content-Type header to add to the request.
* Pass an empty string to omit.
*/
public function __construct($locationName = 'fulltext', $contentType = 'text/plain')
{
parent::__construct($locationName);
$this->contentType = $contentType;
}

/**
* @param CommandInterface $command
* @param RequestInterface $request
* @param Parameter $param
*
* @return MessageInterface
*/
public function visit(
CommandInterface $command,
RequestInterface $request,
Parameter $param
) {
$oldValue = $request->getBody()->getContents();

$value = $command[$param->getName()];
$value = $param->filter($value);

if ($oldValue !== '') {
$value = $oldValue.$vaule;
}

if ($this->contentType && !$request->hasHeader('Content-Type')) {
$request = $request->withHeader('Content-Type', $this->contentType);
}

return $request->withBody(Psr7\Utils::streamFor($value));
}
}
11 changes: 10 additions & 1 deletion src/Admin/KeycloakClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use GuzzleHttp\Handler\CurlHandler;
use GuzzleHttp\HandlerStack;
use Keycloak\Admin\Classes\FullBodyLocation;
use Keycloak\Admin\Classes\FullTextLocation;
use Keycloak\Admin\TokenStorages\RuntimeTokenStorage;

/**
Expand Down Expand Up @@ -193,6 +194,13 @@
* @method array getEventsConfig(array $args = array()) { @command Keycloak getEventsConfig }
* @method array updateEventsConfig(array $args = array()) { @command Keycloak updateEventsConfig }
* @method array getGroupByPath(array $args = array()) { @command Keycloak getGroupByPath }
* @method array getLocalizationLocales(array $args = array()) { @command Keycloak getLocalizationLocales }
* @method array getLocalizationTexts(array $args = array()) { @command Keycloak getLocalizationTexts }
* @method array updateLocalizationTexts(array $args = array()) { @command Keycloak updateLocalizationTexts }
* @method array deleteLocalizationTexts(array $args = array()) { @command Keycloak deleteLocalizationTexts }
* @method array getLocalizationText(array $args = array()) { @command Keycloak getLocalizationText }
* @method array saveLocalizationText(array $args = array()) { @command Keycloak saveLocalizationText }
* @method array deleteLocalizationText(array $args = array()) { @command Keycloak deleteLocalizationText }
* @method array logoutAllUsers(array $args = array()) { @command Keycloak logoutAllUsers }
* @method array partialExportRealm(array $args = array()) { @command Keycloak partialExportRealm }
* @method array partialImportRealm(array $args = array()) { @command Keycloak partialImportRealm }
Expand Down Expand Up @@ -339,7 +347,8 @@ public static function factory($config = array())
new Client($config),
$description,
new Serializer($description, [
"fullBody" => new FullBodyLocation()
"fullBody" => new FullBodyLocation(),
"fullText" => new FullTextLocation(),
]),
function ($response) {
$responseBody = $response->getBody()->getContents();
Expand Down
169 changes: 169 additions & 0 deletions src/Admin/Resources/keycloak-1_0.php
Original file line number Diff line number Diff line change
Expand Up @@ -3652,6 +3652,175 @@
)
),

'getLocalizationLocales' => array(
'uri' => 'admin/realms/{realm}/localization',
'description' => 'Get localization locales for realm',
'httpMethod' => 'GET',
'parameters' => array(
'realm' => array(
'location' => 'uri',
'description' => 'The Realm name',
'type' => 'string',
'required' => true,
),
)
),

'getLocalizationTexts' => array(
'uri' => 'admin/realms/{realm}/localization/{locale}',
'description' => 'Get localization texts for a realm locale',
'httpMethod' => 'GET',
'parameters' => array(
'realm' => array(
'location' => 'uri',
'description' => 'The Realm name',
'type' => 'string',
'required' => true,
),
'locale' => array(
'location' => 'uri',
'description' => 'The locale name',
'type' => 'string',
'required' => true,
),
'useRealmDefaultLocaleFallback' => array(
'location' => 'query',
'description' => 'Fallback to realm default locale',
'type' => 'string',
'required' => false,
),
)
),

'updateLocalizationTexts' => array(
'uri' => 'admin/realms/{realm}/localization/{locale}',
'description' => 'Update localization texts for a realm locale',
'httpMethod' => 'POST',
'parameters' => array(
'realm' => array(
'location' => 'uri',
'description' => 'The Realm name',
'type' => 'string',
'required' => true,
),
'locale' => array(
'location' => 'uri',
'description' => 'The locale name',
'type' => 'string',
'required' => true,
),
'localizationTexts' => array(
'location' => 'fullBody',
'description' => 'Map of text values for the locale',
'required' => true
),
)
),

'deleteLocalizationTexts' => array(
'uri' => 'admin/realms/{realm}/localization/{locale}',
'description' => 'Update localization texts for a realm locale',
'httpMethod' => 'DELETE',
'parameters' => array(
'realm' => array(
'location' => 'uri',
'description' => 'The Realm name',
'type' => 'string',
'required' => true,
),
'locale' => array(
'location' => 'uri',
'description' => 'The locale name',
'type' => 'string',
'required' => true,
),
)
),

'getLocalizationText' => array(
'uri' => 'admin/realms/{realm}/localization/{locale}/{key}',
'description' => 'Get a localization text for a realm locale',
'httpMethod' => 'GET',
'parameters' => array(
'realm' => array(
'location' => 'uri',
'description' => 'The Realm name',
'type' => 'string',
'required' => true,
),
'locale' => array(
'location' => 'uri',
'description' => 'The locale name',
'type' => 'string',
'required' => true,
),
'key' => array(
'location' => 'uri',
'description' => 'The text key name',
'type' => 'string',
'required' => true,
),
)
),

'saveLocalizationText' => array(
'uri' => 'admin/realms/{realm}/localization/{locale}/{key}',
'description' => 'Set a localization text for a realm locale',
'httpMethod' => 'PUT',
'parameters' => array(
'realm' => array(
'location' => 'uri',
'description' => 'The Realm name',
'type' => 'string',
'required' => true,
),
'locale' => array(
'location' => 'uri',
'description' => 'The locale name',
'type' => 'string',
'required' => true,
),
'key' => array(
'location' => 'uri',
'description' => 'The text key name',
'type' => 'string',
'required' => true,
),
'text' => array(
'location' => 'fullText',
'description' => 'The text value',
'type' => 'string',
'required' => true,
),
)
),

'deleteLocalizationText' => array(
'uri' => 'admin/realms/{realm}/localization/{locale}/{key}',
'description' => 'Delete a localization text for a realm locale',
'httpMethod' => 'DELETE',
'parameters' => array(
'realm' => array(
'location' => 'uri',
'description' => 'The Realm name',
'type' => 'string',
'required' => true,
),
'locale' => array(
'location' => 'uri',
'description' => 'The locale name',
'type' => 'string',
'required' => true,
),
'key' => array(
'location' => 'uri',
'description' => 'The text key name',
'type' => 'string',
'required' => true,
),
)
),

'logoutAllUsers' => array(
'uri' => 'admin/realms/{realm}/logout-all',
'description' => 'Removes all user sessions.',
Expand Down

0 comments on commit 81edfd7

Please sign in to comment.