Skip to content

Commit

Permalink
Merge pull request #111 from fschmtt/keycloak-25
Browse files Browse the repository at this point in the history
Add support for Keycloak 25 #110
  • Loading branch information
fschmtt authored Jun 13, 2024
2 parents 308cc8d + 1b3c107 commit 3b909a7
Show file tree
Hide file tree
Showing 10 changed files with 98 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/php-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

strategy:
matrix:
keycloak: [17.0.0, 18.0.0, 19.0.0, 20.0.0, 21.0.0, 22.0.0, 22.0.5, 23.0.0, 24.0.0]
keycloak: [17.0.0, 18.0.0, 19.0.0, 20.0.0, 21.0.0, 22.0.0, 22.0.5, 23.0.0, 24.0.0, 25.0.0]
php: [ 8.1 ]

env:
Expand Down Expand Up @@ -50,6 +50,7 @@ jobs:
uses: iFaxity/wait-on-action@v1
with:
resource: ${{ env.KEYCLOAK_BASE_URL }}
httpTimeout: 30000

- name: Wait some more for Keycloak 24.0.0 zZz
if: ${{ matrix.keycloak == '24.0.0' }}
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# Keycloak Admin REST API Client

PHP client to interact with [Keycloak's Admin REST API](https://www.keycloak.org/docs-api/24.0.0/rest-api/index.html).
PHP client to interact with [Keycloak's Admin REST API](https://www.keycloak.org/docs-api/25.0.0/rest-api/index.html).

Inspired by [keycloak/keycloak-nodejs-admin-client](https://github.com/keycloak/keycloak-nodejs-admin-client).

Expand Down Expand Up @@ -49,7 +49,7 @@ echo sprintf(
will print e.g.

```text
Keycloak 24.0.0 is running on Linux/5.10.25-linuxkit (amd64) with OpenJDK 64-Bit Server VM/11.0.11 since 0 days, 2 hours, 37 minutes, 7 seconds and is currently using 139 MB of 512 MB (28 %) memory.
Keycloak 25.0.0 is running on Linux/5.10.25-linuxkit (amd64) with OpenJDK 64-Bit Server VM/11.0.11 since 0 days, 2 hours, 37 minutes, 7 seconds and is currently using 139 MB of 512 MB (28 %) memory.
```

More examples can be found in the [examples](examples) directory.
Expand Down Expand Up @@ -104,15 +104,15 @@ $myCustomRepresentation = $myCustomResource->myCustomEndpoint();

## Available Resources

### [Attack Detection](https://www.keycloak.org/docs-api/24.0.0/rest-api/index.html#_attack_detection)
### [Attack Detection](https://www.keycloak.org/docs-api/25.0.0/rest-api/index.html#_attack_detection)

| Endpoint | Response | API |
|----------------------------------------------------------------------------|-------------------------|-------------------------------------------------------------------|
| `DELETE /admin/realms/{realm}/attack-detection/brute-force/users` | `n/a` | [AttackDetection::clear()](src/Resource/AttackDetection.php) |
| `GET /admin/realms/{realm}/attack-detection/brute-force/users/{userId}` | [Map](src/Type/Map.php) | [AttackDetection::userStatus()](src/Resource/AttackDetection.php) |
| `DELETE /admin/realms/{realm}/attack-detection/brute-force/users/{userId}` | `n/a` | [AttackDetection::clearUser()](src/Resource/AttackDetection.php) |

### [Clients](https://www.keycloak.org/docs-api/24.0.0/rest-api/index.html#_clients)
### [Clients](https://www.keycloak.org/docs-api/25.0.0/rest-api/index.html#_clients)

| Endpoint | Response | API |
|---------------------------------------------------|---------------------------------------------------------|-----------------------------------------------|
Expand All @@ -121,7 +121,7 @@ $myCustomRepresentation = $myCustomResource->myCustomEndpoint();
| `PUT /admin/realms/{realm}/clients/{client-uuid}` | [Client](src/Representation/Client.php) | [Clients::update()](src/Resource/Clients.php) |
| `POST /admin/realms/{realm}/clients` | [Client](src/Representation/Client.php) | [Clients::import()](src/Resource/Clients.php) |

### [Groups](https://www.keycloak.org/docs-api/24.0.0/rest-api/index.html#_clients)
### [Groups](https://www.keycloak.org/docs-api/25.0.0/rest-api/index.html#_clients)

| Endpoint | Response | API |
|---------------------------------------------------|-------------------------------------------------------|-----------------------------------------------|
Expand All @@ -133,7 +133,7 @@ $myCustomRepresentation = $myCustomResource->myCustomEndpoint();
| `POST /admin/realms/{realm}/groups/{id}/children` | `n/a` | [Groups::create()](src/Resource/Groups.php) |
| `DELETE /admin/realms/{realm}/groups` | `n/a` | [Groups::delete()](src/Resource/Groups.php) |

### [Realms Admin](https://www.keycloak.org/docs-api/24.0.0/rest-api/index.html#_realms_admin)
### [Realms Admin](https://www.keycloak.org/docs-api/25.0.0/rest-api/index.html#_realms_admin)

| Endpoint | Response | API |
|------------------------------------------------|-------------------------------------------------------|--------------------------------------------------------|
Expand All @@ -148,7 +148,7 @@ $myCustomRepresentation = $myCustomResource->myCustomEndpoint();
| `POST /admin/realms/{realm}/clear-realm-cache` | `n/a` | [Realms::clearRealmCache()](src/Resource/Realms.php) |
| `POST /admin/realms/{realm}/clear-user-cache` | `n/a` | [Realms::clearUserCache()](src/Resource/Realms.php) |

### [Users](https://www.keycloak.org/docs-api/24.0.0/rest-api/index.html#_users)
### [Users](https://www.keycloak.org/docs-api/25.0.0/rest-api/index.html#_users)

| Endpoint | Response | API |
|---------------------------------------------------------|-----------------------------------------------------------------|----------------------------------------------------------------|
Expand All @@ -168,7 +168,7 @@ $myCustomRepresentation = $myCustomResource->myCustomEndpoint();
| `PUT /{realm}/users/{id}/execute-actions-email` | `n/a` | [Users::executeActionsEmail()](src/Resource/Users.php) |
| `GET /admin/realms/{realm}/users/{userId}/credentials` | [CredentialCollection](src/Collection/CredentialCollection.php) | [Users::credentials()](src/Resource/Users.php) |

### [Roles](https://www.keycloak.org/docs-api/24.0.0/rest-api/index.html#_roles)
### [Roles](https://www.keycloak.org/docs-api/25.0.0/rest-api/index.html#_roles)

| Endpoint | Response | API |
|-------------------------------------------------|-----------------------------------------------------|-------------------------------------------|
Expand All @@ -177,7 +177,7 @@ $myCustomRepresentation = $myCustomResource->myCustomEndpoint();
| `POST /admin/realms/{realm}/roles` | `n/a` | [Roles::create()](src/Resource/Roles.php) |
| `DELETE /admin/realms/{realm}/roles/{roleName}` | `n/a` | [Roles::delete()](src/Resource/Roles.php) |

### [Root](https://www.keycloak.org/docs-api/24.0.0/rest-api/index.html#_root)
### [Root](https://www.keycloak.org/docs-api/25.0.0/rest-api/index.html#_root)

| Endpoint | Response | API |
|-------------------------|-------------------------------------------------|--------------------------------------------------|
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ services:
working_dir: /app

keycloak:
image: quay.io/keycloak/keycloak:24.0.0
image: quay.io/keycloak/keycloak:25.0.0
command: start-dev
environment:
KEYCLOAK_ADMIN: admin
Expand Down
2 changes: 1 addition & 1 deletion docker/keycloak/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG KEYCLOAK_VERSION=24.0.0
ARG KEYCLOAK_VERSION=25.0.0
FROM quay.io/keycloak/keycloak:${KEYCLOAK_VERSION}

ENTRYPOINT [ "/opt/keycloak/bin/kc.sh", "start-dev" ]
20 changes: 20 additions & 0 deletions src/Collection/OrganizationCollection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace Fschmtt\Keycloak\Collection;

use Fschmtt\Keycloak\Representation\Organization;

/**
* @extends Collection<Organization>
*
* @codeCoverageIgnore
*/
class OrganizationCollection extends Collection
{
public static function getRepresentationClass(): string
{
return Organization::class;
}
}
20 changes: 20 additions & 0 deletions src/Collection/OrganizationDomainCollection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace Fschmtt\Keycloak\Collection;

use Fschmtt\Keycloak\Representation\OrganizationDomain;

/**
* @extends Collection<OrganizationDomain>
*
* @codeCoverageIgnore
*/
class OrganizationDomainCollection extends Collection
{
public static function getRepresentationClass(): string
{
return OrganizationDomain::class;
}
}
25 changes: 25 additions & 0 deletions src/Representation/Organization.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

namespace Fschmtt\Keycloak\Representation;

use Fschmtt\Keycloak\Collection\IdentityProviderCollection;
use Fschmtt\Keycloak\Collection\OrganizationDomainCollection;
use Fschmtt\Keycloak\Collection\UserCollection;
use Fschmtt\Keycloak\Type\Map;

class Organization extends Representation
{
public function __construct(
protected ?string $id = null,
protected ?string $name = null,
protected ?bool $enabled = null,
protected ?string $description = null,
protected ?Map $attributes = null,
protected ?OrganizationDomainCollection $domains = null,
protected ?UserCollection $members = null,
protected ?IdentityProviderCollection $identityProviders = null,
) {
}
}
14 changes: 14 additions & 0 deletions src/Representation/OrganizationDomain.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace Fschmtt\Keycloak\Representation;

class OrganizationDomain extends Representation
{
public function __construct(
protected ?string $name = null,
protected ?bool $verified = null,
) {
}
}
5 changes: 5 additions & 0 deletions src/Representation/Realm.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Fschmtt\Keycloak\Collection\GroupCollection;
use Fschmtt\Keycloak\Collection\IdentityProviderCollection;
use Fschmtt\Keycloak\Collection\IdentityProviderMapperCollection;
use Fschmtt\Keycloak\Collection\OrganizationCollection;
use Fschmtt\Keycloak\Collection\ProtocolMapperCollection;
use Fschmtt\Keycloak\Collection\RequiredActionProviderCollection;
use Fschmtt\Keycloak\Collection\ScopeMappingCollection;
Expand Down Expand Up @@ -355,6 +356,10 @@ public function __construct(
protected ?int $offlineSessionIdleTimeout = null,
protected ?int $offlineSessionMaxLifespan = null,
protected ?bool $offlineSessionMaxLifespanEnabled = null,
#[Since('25.0.0')]
protected ?OrganizationCollection $organizations = null,
#[Since('25.0.0')]
protected ?bool $organizationsEnabled = null,
protected ?string $otpPolicyAlgorithm = null,
#[Since('20.0.0')]
protected ?bool $otpPolicyCodeReusable = null,
Expand Down
1 change: 1 addition & 0 deletions tests/Unit/Http/PropertyFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,6 @@ public static function supportedKeycloakVersions(): Generator
yield ['22.0.0'];
yield ['23.0.0'];
yield ['24.0.0'];
yield ['25.0.0'];
}
}

0 comments on commit 3b909a7

Please sign in to comment.