Skip to content

Commit

Permalink
fix(Bundle): fixes in namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
Samir Comprés committed Aug 26, 2020
1 parent 0a483a9 commit 6a01fbd
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 124 deletions.
4 changes: 2 additions & 2 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder('idci_keycloak_security');
$treeBuilder = new TreeBuilder('nti_keycloak_security');
if (method_exists($treeBuilder, 'getRootNode')) {
$rootNode = $treeBuilder->getRootNode();
} else {
$rootNode = $treeBuilder->root('idci_keycloak_security');
$rootNode = $treeBuilder->root('nti_keycloak_security');
}

$rootNode
Expand Down
69 changes: 0 additions & 69 deletions DependencyInjection/IDCIKeycloakSecurityExtension.php

This file was deleted.

12 changes: 6 additions & 6 deletions DependencyInjection/KeycloakSecurityExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public function load(array $configs, ContainerBuilder $container)
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yaml');

$container->setParameter('idci_keycloak_security.config', $config);
$container->setParameter('idci_keycloak_security.default_target_path', $config['default_target_path']);
$container->setParameter('idci_keycloak_security.ssl_verification', $config['ssl_verification']);
$container->setParameter('nti_keycloak_security.config', $config);
$container->setParameter('nti_keycloak_security.default_target_path', $config['default_target_path']);
$container->setParameter('nti_keycloak_security.ssl_verification', $config['ssl_verification']);
}

public function prepend(ContainerBuilder $container)
Expand All @@ -29,7 +29,7 @@ public function prepend(ContainerBuilder $container)

if (!isset($bundles['KnpUOAuth2ClientBundle'])) {
throw new \LogicException(
'You must install knpuniversity/oauth2-client-bundle in order to use IDCIKeycloakSecurityBundle'
'You must install knpuniversity/oauth2-client-bundle in order to use KeycloakSecurityBundle'
);
}

Expand All @@ -48,7 +48,7 @@ protected function generateKeycloakAuthConfiguration(array $config)
'provider_class' => 'NTI\KeycloakSecurityBundle\Provider\Keycloak',
'client_id' => $config['client_id'],
'client_secret' => $config['client_secret'],
'redirect_route' => 'idci_security_auth_connect_check_keycloak',
'redirect_route' => 'nti_security_auth_connect_check_keycloak',
'redirect_params' => [],
'provider_options' => [
'auth_server_private_url' => isset($config['server_private_url']) ? $config['server_private_url'] : null,
Expand All @@ -64,6 +64,6 @@ protected function generateKeycloakAuthConfiguration(array $config)

public function getAlias()
{
return 'idci_keycloak_security';
return 'nti_keycloak_security';
}
}
2 changes: 1 addition & 1 deletion EventListener/ExceptionListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function onKernelException(GetResponseForExceptionEvent $event)
if ($exception instanceof IdentityProviderException) {
$event->setResponse(new RedirectResponse(
$this->urlGenerator->generate(
'idci_security_auth_connect_keycloak',
'nti_security_auth_connect_keycloak',
[],
UrlGeneratorInterface::ABSOLUTE_URL
)
Expand Down
20 changes: 0 additions & 20 deletions IDCIKeycloakSecurityBundle.php

This file was deleted.

28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
IDCI Keycloak Security Bundle
NTI Keycloak Security Bundle
=============================

This Symfony bundle is an alternative solution to FOSUserBundle, working with keycloak.
Expand All @@ -8,7 +8,7 @@ This Symfony bundle is an alternative solution to FOSUserBundle, working with ke
With composer:

```
$ composer require idci/keycloak-security-bundle
$ composer require nti/keycloak-security-bundle
```

## Configuration
Expand All @@ -22,8 +22,8 @@ If you want to set up keycloak locally you can download it [here](https://www.ke
In case of you already have keycloak running locally on your machine or is running remotely but without proxy, here is the default configuration you should use:

```yaml
# config/packages/idci_keycloak_security.yaml
idci_keycloak_security:
# config/packages/nti_keycloak_security.yaml
nti_keycloak_security:
server_url: 'http://localhost:8080/auth' # your accessible keycloak url
# server_url: 'http://keycloak.example.com/auth' # example with public url
realm: 'MyRealm'
Expand All @@ -39,8 +39,8 @@ If you want to use keycloak in docker you can base your stack on this [sample](.
Here is a stack example configuration for docker swarm:
```yaml
# config/packages/idci_keycloak_security.yaml
idci_keycloak_security:
# config/packages/nti_keycloak_security.yaml
nti_keycloak_security:
server_public_url: 'http://keycloak.docker/auth' # your keycloak url accessible via your navigator
server_private_url: 'http://keycloak:8080/auth' # your keycloak container reference in the network
realm: 'MyRealm'
Expand All @@ -56,9 +56,9 @@ Make sure that your php container in the container is attached to a network with
Create a new file in ```config/routes/``` to load pre configured bundle routes.

```yaml
# config/routes/idci_keycloak_security.yaml
IDCIKeycloakSecurityBundle:
resource: "@IDCIKeycloakSecurityBundle/Resources/config/routing.yaml"
# config/routes/nti_keycloak_security.yaml
KeycloakSecurityBundle:
resource: "@KeycloakSecurityBundle/Resources/config/routing.yaml"
prefix: /
```

Expand All @@ -71,7 +71,7 @@ Here is a simple configuration that restrict access to ```/admin/*``` routes onl
```yaml
# config/packages/security.yaml
imports:
- { resource: '@IDCIKeycloakSecurityBundle/Resources/config/security.yaml' } # import our security provider
- { resource: '@KeycloakSecurityBundle/Resources/config/security.yaml' } # import our security provider
security:
Expand All @@ -87,17 +87,17 @@ security:
secured_area:
pattern: ^/admin
guard:
provider: idci_keycloak_security_provider
provider: nti_keycloak_security_provider
authenticators:
- IDCI\Bundle\KeycloakSecurityBundle\Security\Authenticator\KeycloakAuthenticator
- NTI\KeycloakSecurityBundle\Security\Authenticator\KeycloakAuthenticator
# Bearer token authentication
api:
pattern: ^/api
guard:
provider: idci_keycloak_bearer_security_provider
provider: nti_keycloak_bearer_security_provider
authenticators:
- IDCI\Bundle\KeycloakSecurityBundle\Security\Authenticator\KeycloakBearerAuthenticator
- NTI\KeycloakSecurityBundle\Security\Authenticator\KeycloakBearerAuthenticator
role_hierarchy:
ROLE_ADMIN: ROLE_USER
Expand Down
6 changes: 3 additions & 3 deletions Resources/config/routing.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
idci_security_auth_connect_keycloak:
nti_security_auth_connect_keycloak:
path: /auth/connect/keycloak
controller: NTI\KeycloakSecurityBundle\Controller\KeycloakController::connectAction

idci_security_auth_connect_check_keycloak:
nti_security_auth_connect_check_keycloak:
path: /auth/connect-check/keycloak
controller: NTI\KeycloakSecurityBundle\Controller\KeycloakController::connectCheckAction

idci_security_auth_logout:
nti_security_auth_logout:
path: /auth/logout
controller: NTI\KeycloakSecurityBundle\Controller\KeycloakController::logoutAction
4 changes: 2 additions & 2 deletions Resources/config/security.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
security:
providers:
idci_keycloak_security_provider:
nti_keycloak_security_provider:
id: NTI\KeycloakSecurityBundle\Security\User\KeycloakUserProvider
idci_keycloak_bearer_security_provider:
nti_keycloak_bearer_security_provider:
id: NTI\KeycloakSecurityBundle\Security\User\KeycloakBearerUserProvider
6 changes: 3 additions & 3 deletions Resources/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ services:
NTI\KeycloakSecurityBundle\Controller\KeycloakController:
public: true
bind:
$defaultTargetPath: '%idci_keycloak_security.default_target_path%'
$defaultTargetPath: '%nti_keycloak_security.default_target_path%'
tags: ['controller.service_arguments']

NTI\KeycloakSecurityBundle\Security\Authenticator\KeycloakAuthenticator:

NTI\KeycloakSecurityBundle\Security\User\KeycloakUserProvider:
tags:
- { name: idci_keycloak_security.user_provider, alias: oauth }
- { name: nti_keycloak_security.user_provider, alias: oauth }

NTI\KeycloakSecurityBundle\Security\User\KeycloakBearerUserProvider:
arguments:
$sslVerification: '%idci_keycloak_security.ssl_verification%'
$sslVerification: '%nti_keycloak_security.ssl_verification%'

NTI\KeycloakSecurityBundle\EventListener\ExceptionListener:
tags:
Expand Down
4 changes: 2 additions & 2 deletions Security/Authenticator/KeycloakAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __construct(ClientRegistry $clientRegistry, UrlGeneratorInterfac

public function supports(Request $request)
{
return 'idci_security_auth_connect_check_keycloak' === $request->attributes->get('_route');
return 'nti_security_auth_connect_check_keycloak' === $request->attributes->get('_route');
}

public function getCredentials(Request $request): ?AccessToken
Expand Down Expand Up @@ -67,7 +67,7 @@ public function onAuthenticationFailure(Request $request, AuthenticationExceptio
public function start(Request $request, AuthenticationException $authException = null): RedirectResponse
{
return new RedirectResponse(
$this->urlGenerator->generate('idci_security_auth_connect_keycloak'),
$this->urlGenerator->generate('nti_security_auth_connect_keycloak'),
Response::HTTP_TEMPORARY_REDIRECT
);
}
Expand Down
8 changes: 6 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
],
"authors": [
{
"name": "Benjamin Boudier",
"email": "[email protected]"
"name": "Samir Comprés",
"email": "[email protected]"
},
{
"name": "Yansell Rivas",
"email": "[email protected]"
}
],
"require": {
Expand Down

0 comments on commit 6a01fbd

Please sign in to comment.