Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 86e523d94e | |||
| b4b78b0ab5 | |||
| 50a560b6f4 | |||
| 4a69b5d9fe | |||
| 3aedf851ef | |||
| 338850c5ce | |||
|
|
ae1a996ace |
@@ -5,21 +5,25 @@ namespace ABEL\Bundle\keycloakBearerOnlyAdapterBundle\DependencyInjection;
|
|||||||
|
|
||||||
use Symfony\Component\Config\FileLocator;
|
use Symfony\Component\Config\FileLocator;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
use Symfony\Component\DependencyInjection\Extension\Extension;
|
||||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
|
||||||
|
|
||||||
class ABELkeycloakBearerOnlyAdapterExtension extends Extension
|
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 = new PhpFileLoader(
|
||||||
$loader->load('services.xml');
|
$container,
|
||||||
|
new FileLocator(__DIR__ . '/../Resources/config')
|
||||||
|
);
|
||||||
|
$loader->load('services.php');
|
||||||
|
|
||||||
$configuration = $this->getConfiguration($configs, $container);
|
$configuration = $this->getConfiguration($configs, $container);
|
||||||
$config = $this->processConfiguration($configuration, $configs);
|
$config = $this->processConfiguration($configuration, $configs);
|
||||||
|
|
||||||
$definition = $container->getDefinition('abel_keycloak_bearer_only_adapter.keycloak_bearer_user_provider');
|
$definition = $container->getDefinition('abel_keycloak_bearer_only_adapter.keycloak_bearer_user_provider');
|
||||||
|
|
||||||
$definition->replaceArgument(0, $config['issuer']);
|
$definition->replaceArgument(0, $config['issuer']);
|
||||||
$definition->replaceArgument(1, $config['realm']);
|
$definition->replaceArgument(1, $config['realm']);
|
||||||
$definition->replaceArgument(2, $config['client_id']);
|
$definition->replaceArgument(2, $config['client_id']);
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use Symfony\Component\Config\Definition\ConfigurationInterface;
|
|||||||
class Configuration implements ConfigurationInterface
|
class Configuration implements ConfigurationInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
public function getConfigTreeBuilder()
|
public function getConfigTreeBuilder(): TreeBuilder
|
||||||
{
|
{
|
||||||
$treeBuilder = new TreeBuilder("abel_keycloak_bearer_only_adapter");
|
$treeBuilder = new TreeBuilder("abel_keycloak_bearer_only_adapter");
|
||||||
|
|
||||||
|
|||||||
25
Resources/config/services.php
Normal file
25
Resources/config/services.php
Normal 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'
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -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>
|
|
||||||
@@ -258,8 +258,11 @@ class KeycloakBearerUser implements UserInterface
|
|||||||
*
|
*
|
||||||
* This is important if, at any given point, sensitive information like
|
* This is important if, at any given point, sensitive information like
|
||||||
* the plain-text password is stored on this object.
|
* the plain-text password is stored on this object.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function eraseCredentials()
|
#[\Deprecated]
|
||||||
|
public function eraseCredentials(): void
|
||||||
{
|
{
|
||||||
// TODO: Implement eraseCredentials() method.
|
// TODO: Implement eraseCredentials() method.
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ class KeycloakBearerUserProvider implements UserProviderInterface{
|
|||||||
* @param string $class
|
* @param string $class
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function supportsClass(string $class)
|
public function supportsClass(string $class): bool
|
||||||
{
|
{
|
||||||
return KeycloakBearerUser::class === $class || is_subclass_of($class, KeycloakBearerUser::class);
|
return KeycloakBearerUser::class === $class || is_subclass_of($class, KeycloakBearerUser::class);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,22 @@
|
|||||||
{
|
{
|
||||||
"name": "abel/keycloak-bearer-only-adapter-bundle",
|
"name": "tothbt/keycloak-adapter-bundle",
|
||||||
"description": "Keycloak security adapter for bearer only clients",
|
"description": "Keycloak security adapter for bearer only clients",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"type": "symfony-bundle",
|
"type": "symfony-bundle",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "Abdellah Elmakhroubi",
|
"name": "Richard Toth",
|
||||||
"email": "abdellah.elmakhroubi@gmail.com"
|
"email": "info@totbt.com"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"minimum-stability": "stable",
|
"minimum-stability": "stable",
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.2.5",
|
"php": ">=8.3",
|
||||||
"symfony/config": "^6.0",
|
"symfony/config": "^6.0 || ^7.0",
|
||||||
"symfony/dependency-injection": "^6.0",
|
"symfony/dependency-injection": "^6.0 || ^7.0",
|
||||||
"symfony/http-kernel": "^6.0",
|
"symfony/http-kernel": "^6.0 || ^7.0",
|
||||||
"symfony/security-bundle": "^6.0",
|
"symfony/security-bundle": "^6.0 || ^7.0",
|
||||||
"guzzlehttp/guzzle": "^6.3",
|
"guzzlehttp/guzzle": "^7",
|
||||||
"ext-json": "*"
|
"ext-json": "*"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
|||||||
Reference in New Issue
Block a user