15 Commits

Author SHA1 Message Date
86e523d94e add missing use 2026-04-30 18:52:52 +02:00
b4b78b0ab5 use php config instead of deprecated xml 2026-04-30 18:51:21 +02:00
50a560b6f4 do not use internal class 2026-04-30 18:35:06 +02:00
4a69b5d9fe fix: symfony 7.4 comp fixes 2026-04-30 13:30:04 +02:00
3aedf851ef feat!: symfony7 compatibility 2026-04-30 13:05:21 +02:00
338850c5ce fix deprecation of eraseCredentials function return type 2026-01-04 21:05:16 +01:00
Richard Toth
ae1a996ace update composer.json (guzzle update) 2025-12-19 13:40:59 +01:00
El. Abdellah
43399b443e Update README.md 2023-02-20 14:28:39 +01:00
El. Abdellah
727ade1a19 Merge pull request #11 from tricsusz/master
remove deprecated Serializable interface
2023-02-20 14:23:42 +01:00
88ec7d7bb1 remove deprecated Serializable interface 2023-02-20 14:04:43 +01:00
El. Abdellah
8c8ceb1279 Update README.md 2022-04-21 02:34:37 +02:00
El. Abdellah
f11d97ced0 Merge pull request #8 from tricsusz/master
remove /auth from Keycloak URL
2022-04-21 02:14:14 +02:00
fc2d81b9ad remove /auth from Keycloak URL 2022-04-19 19:11:39 +02:00
El. Abdellah
87909a1c15 Update README.md 2022-03-06 19:36:11 +01:00
El. Abdellah
f254ab52ac Merge pull request #6 from el-abdel/develop
Add compatibility with Symfony V6
2022-03-06 19:34:25 +01:00
8 changed files with 59 additions and 47 deletions

View File

@@ -5,21 +5,25 @@ namespace ABEL\Bundle\keycloakBearerOnlyAdapterBundle\DependencyInjection;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
class ABELkeycloakBearerOnlyAdapterExtension extends Extension
{
public function load(array $configs, ContainerBuilder $container)
public function load(array $configs, ContainerBuilder $container): void
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.xml');
$loader = new PhpFileLoader(
$container,
new FileLocator(__DIR__ . '/../Resources/config')
);
$loader->load('services.php');
$configuration = $this->getConfiguration($configs, $container);
$config = $this->processConfiguration($configuration, $configs);
$definition = $container->getDefinition('abel_keycloak_bearer_only_adapter.keycloak_bearer_user_provider');
$definition->replaceArgument(0, $config['issuer']);
$definition->replaceArgument(1, $config['realm']);
$definition->replaceArgument(2, $config['client_id']);

View File

@@ -10,7 +10,7 @@ use Symfony\Component\Config\Definition\ConfigurationInterface;
class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder("abel_keycloak_bearer_only_adapter");

View File

@@ -56,6 +56,11 @@ OAUTH_KEYCLOAK_CLIENT_SECRET=my_bearer_client_secret
###< Abel_keycloak_bearer_only_adapter ###
...
```
> Since Keycloak 17 the default distribution is now powered by **Quarkus**, while the legacy **WildFly** powered distribution will still be around until June 2022 <br>
> The new distribution introduces a number of breaking changes, including: <br>
> - `/auth` removed from the default context path <br>
> ⚠️ **If you are using a legacy version make sure to include /auth in OAUTH_KEYCLOAK_ISSUER** <br>
> Example: `keycloak:8080/auth`
In case of using Keycloak with Docker locally replace **issuer** value with your keycloak container reference in the network
@@ -103,3 +108,4 @@ To configure keycloak to work with this bundle, [here](./Resources/docs/keycloak
| V1.0.1 | >=4.0.0 <5.0.0 |
| V1.1.* (uses old authentication systeme with guard) | >=5.0.0 <6.0.0 |
| V1.2.* (uses new authentication systeme) | >=5.3.0 <6.0.0 |
| V1.3.* | >=6.0.0 <7.0.0 |

View File

@@ -0,0 +1,25 @@
<?php
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use ABEL\Bundle\keycloakBearerOnlyAdapterBundle\Security\User\KeycloakBearerUserProvider;
return static function (ContainerConfigurator $configurator): void {
$services = $configurator->services();
$services
->defaults()
->autowire()
->autoconfigure();
$services->load('ABEL\\Bundle\\keycloakBearerOnlyAdapterBundle\\', '../../*')
->exclude('../../{Entity,Migrations,Tests}');
// empty args → will be replaced later
$services->set('abel_keycloak_bearer_only_adapter.keycloak_bearer_user_provider', KeycloakBearerUserProvider::class)
->args([null, null, null, null, null]);
$services->alias(
KeycloakBearerUserProvider::class,
'abel_keycloak_bearer_only_adapter.keycloak_bearer_user_provider'
);
};

View File

@@ -1,26 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services
https://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<!-- Default configuration for services in *this* file -->
<defaults autowire="true" autoconfigure="true"/>
<!-- makes classes available to be used as services -->
<!-- this creates a service per class whose id is the fully-qualified class name -->
<prototype namespace="ABEL\Bundle\keycloakBearerOnlyAdapterBundle\" resource="../../*" exclude="../../{Entity,Migrations,Tests}"/>
<service id="abel_keycloak_bearer_only_adapter.keycloak_bearer_user_provider" class="ABEL\Bundle\keycloakBearerOnlyAdapterBundle\Security\User\KeycloakBearerUserProvider">
<argument/>
<argument/>
<argument/>
<argument/>
<argument/>
</service>
<service id="ABEL\Bundle\keycloakBearerOnlyAdapterBundle\Security\User\KeycloakBearerUserProvider" alias="abel_keycloak_bearer_only_adapter.keycloak_bearer_user_provider" />
</services>
</container>

View File

@@ -6,7 +6,7 @@ namespace ABEL\Bundle\keycloakBearerOnlyAdapterBundle\Security\User;
use Symfony\Component\Security\Core\User\UserInterface;
class KeycloakBearerUser implements UserInterface, \Serializable
class KeycloakBearerUser implements UserInterface
{
/**
* @var string
@@ -258,8 +258,11 @@ class KeycloakBearerUser implements UserInterface, \Serializable
*
* This is important if, at any given point, sensitive information like
* the plain-text password is stored on this object.
*
* @return void
*/
public function eraseCredentials()
#[\Deprecated]
public function eraseCredentials(): void
{
// TODO: Implement eraseCredentials() method.
}
@@ -270,7 +273,7 @@ class KeycloakBearerUser implements UserInterface, \Serializable
* @return string the string representation of the object or null
* @since 5.1.0
*/
public function serialize()
public function __serialize()
{
return serialize(array(
$this->sub,
@@ -293,7 +296,7 @@ class KeycloakBearerUser implements UserInterface, \Serializable
* @return void
* @since 5.1.0
*/
public function unserialize($serialized)
public function __unserialize($serialized)
{
list (
$this->sub,

View File

@@ -83,7 +83,7 @@ class KeycloakBearerUserProvider implements UserProviderInterface{
* @param string $class
* @return bool
*/
public function supportsClass(string $class)
public function supportsClass(string $class): bool
{
return KeycloakBearerUser::class === $class || is_subclass_of($class, KeycloakBearerUser::class);
}
@@ -100,7 +100,7 @@ class KeycloakBearerUserProvider implements UserProviderInterface{
'base_uri' => $this->issuer,
]);
$response = $client->post('/auth/realms/'.$this->realm.'/protocol/openid-connect/token/introspect', [
$response = $client->post('/realms/'.$this->realm.'/protocol/openid-connect/token/introspect', [
'auth' => [$this->client_id, $this->client_secret],
'form_params' => [
'token' => $accessToken,

View File

@@ -1,22 +1,22 @@
{
"name": "abel/keycloak-bearer-only-adapter-bundle",
"name": "tothbt/keycloak-adapter-bundle",
"description": "Keycloak security adapter for bearer only clients",
"license": "MIT",
"type": "symfony-bundle",
"authors": [
{
"name": "Abdellah Elmakhroubi",
"email": "abdellah.elmakhroubi@gmail.com"
"name": "Richard Toth",
"email": "info@totbt.com"
}
],
"minimum-stability": "stable",
"require": {
"php": ">=7.2.5",
"symfony/config": "^6.0",
"symfony/dependency-injection": "^6.0",
"symfony/http-kernel": "^6.0",
"symfony/security-bundle": "^6.0",
"guzzlehttp/guzzle": "^6.3",
"php": ">=8.3",
"symfony/config": "^6.0 || ^7.0",
"symfony/dependency-injection": "^6.0 || ^7.0",
"symfony/http-kernel": "^6.0 || ^7.0",
"symfony/security-bundle": "^6.0 || ^7.0",
"guzzlehttp/guzzle": "^7",
"ext-json": "*"
},
"autoload": {