Installation
composer require aldaflux/ids-sante-bundle:dev-master
Ensure your project uses Symfony 4.0+ and Doctrine Collections.
Enable the Bundle
Add to config/bundles.php:
return [
// ...
Aldaflux\IdsSanteBundle\AldafluxIdsSanteBundle::class => ['all' => true],
];
Configure the Bundle
Create config/packages/aldaflux_ids_sante.yaml:
aldaflux_ids_sante:
application_name: "YourAppName"
active: true
prefixe: "03" # Default prefix for IDS integration
user:
class: "App\Entity\User" # Replace with your User entity
soap:
wsdl:
log: "http://api.idshost.priv/log.wsdl" # Replace with your WSDL URL
Set Up Routes
Add to config/routes/ids_routes.yaml:
ids_routes:
resource: "@AldafluxIdsSanteBundle/Resources/config/routing/routes.yml"
First Use Case: Test Login
Access /ids/checkpasswordservice/test to verify the bundle is working. This endpoint is useful for debugging authentication flows.
User Entity Integration
Ensure your User entity implements the required methods (e.g., findOneByUsername). Example:
// src/Entity/User.php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: "App\Repository\UserRepository")]
class User
{
// ...
public function findOneByUsername(string $username): ?User
{
return $this->getDoctrine()->getRepository(User::class)->findOneBy(['username' => $username]);
}
}
SOAP Service Integration
The bundle uses SOAP for communication with ids.host. Extend or override the SOAP client logic in:
// src/Service/IdsSoapService.php (custom implementation)
use Aldaflux\IdsSanteBundle\Service\IdsSoapService as BaseIdsSoapService;
class IdsSoapService extends BaseIdsSoapService
{
public function __construct(\SoapClient $client, array $options)
{
parent::__construct($client, $options);
// Custom logic here
}
}
Bind the service in services.yaml:
services:
Aldaflux\IdsSanteBundle\Service\IdsSoapService: '@app.service.ids_soap'
app.service.ids_soap:
class: App\Service\IdsSoapService
arguments:
- '@soap.client'
- { /* options */ }
Logging and Debugging
Use the /ids/logs endpoint (restricted to ROLE_ADMIN) to inspect authentication logs. Extend the logger if needed:
// src/Service/IdsLogger.php
use Aldaflux\IdsSanteBundle\Service\IdsLogger as BaseIdsLogger;
class IdsLogger extends BaseIdsLogger
{
public function logEvent(string $event, array $data): void
{
// Custom logging logic (e.g., send to external service)
parent::logEvent($event, $data);
}
}
Password Validation
Use the IdsPasswordService to validate user credentials against ids.host:
use Aldaflux\IdsSanteBundle\Service\IdsPasswordService;
$passwordService = $container->get(IdsPasswordService::class);
$isValid = $passwordService->validatePassword($username, $password);
Proxy Configuration (Dev Only) Enable proxy for local development:
# config/packages/aldaflux_ids_sante.yaml
when@dev:
aldaflux_ids_sante:
proxy:
enabled: true
ip: '%env(IDS_PROXY_IP)%'
Event Listeners
Subscribe to IDS events (e.g., login failures) in services.yaml:
services:
app.listener.ids_auth_failure:
class: App\EventListener\IdsAuthFailureListener
tags:
- { name: kernel.event_listener, event: ids.auth.failure, method: onAuthFailure }
SOAP WSDL URL
wsdl.log URL in aldaflux_ids_sante.yaml is correct and accessible. Test with:
curl http://api.idshost.priv/log.wsdl
SoapFault exception. Handle it gracefully:
try {
$client = new \SoapClient($wsdlUrl);
} catch (\SoapFault $fault) {
throw new \RuntimeException('IDS SOAP service unavailable. Check WSDL URL.');
}
User Entity Compatibility
User entity has a findOneByUsername method. If not, override the IdsUserProvider:
// src/Service/IdsUserProvider.php
use Aldaflux\IdsSanteBundle\Service\IdsUserProvider as BaseIdsUserProvider;
class IdsUserProvider extends BaseIdsUserProvider
{
public function findUserByUsername(string $username): ?User
{
return $this->userRepository->findBy(['email' => $username]); // Custom logic
}
}
Security Restrictions
/ids/logs endpoint requires ROLE_ADMIN. Ensure your security.yaml is configured:
security:
access_control:
- { path: '^/ids/logs', roles: ROLE_ADMIN }
$user->addRole('ROLE_ADMIN');
Dev Proxy Quirks
IDS_PROXY_ENABLED) is dev-only. Ensure it’s disabled in production:
# .env
IDS_PROXY_ENABLED=false
IDS_PROXY_IP to your local proxy IP (e.g., 127.0.0.1).Enable SOAP Debugging
Add to aldaflux_ids_sante.yaml:
soap:
debug: true # Enable SOAP client debugging
Check logs for SOAP request/response details.
Test the Password Service
Use the /ids/checkpasswordservice/test endpoint to verify SOAP connectivity:
curl -X POST http://your-app/ids/checkpasswordservice/test
Expected response: {"success": true} if the service is reachable.
Override Bundle Templates
The bundle uses Twig templates in Resources/views/. Override them in your project:
templates/
bundles/
AldafluxIdsSante/
base.html.twig # Override base template
Environment-Specific Config Use Symfony’s parameter system for environment-specific settings:
# config/packages/aldaflux_ids_sante.yaml
aldaflux_ids_sante:
soap:
wsdl:
log: '%env(IDS_WSDL_LOG_URL)%'
Set in .env:
IDS_WSDL_LOG_URL=https://prod.idshost.priv/log.wsdl
Custom SOAP Client Replace the default SOAP client by binding your own service:
services:
soap.client:
class: \SoapClient
arguments:
- '%env(IDS_WSDL_URL)%'
- { trace: true, exceptions: true }
Event Dispatching
The bundle dispatches events like ids.auth.success and ids.auth.failure. Listen to them:
services:
app.listener.ids_auth:
class: App\EventListener\IdsAuthListener
tags:
- { name: kernel.event_listener, event: ids.auth.success, method: onAuthSuccess }
Logging Customization
Extend the IdsLogger to add custom logging (e.g., to a SIEM):
class CustomIdsLogger extends IdsLogger
{
public function logEvent(string $event, array $data): void
{
// Send to external logging service
$this->externalLogger->log($event, $data);
parent::logEvent($event, $data); // Fallback to default
}
}
4
How can I help you explore Laravel packages today?