---
title: "Developer Guide"
manual: "Netresearch SAML Auth"
version: "main"
source: "Developer/Index.rst"
rendered: "2026-10-01T05:49:07+00:00"
---

# Developer Guide {#developer}

This section provides information for developers who want to extend or
customize the SAML authentication functionality.

-   [PSR-14 Events](Events.html#psr-14-events)

## Architecture Overview {#architecture-overview}

The extension uses the following key components:

### AuthenticationService {#authenticationservice}

The `AuthenticationService` class extends TYPO3's authentication service
and handles:

-   SAML response validation
-   User lookup and creation
-   Authentication status management

Location: `Classes/Sv/AuthenticationService.php`

### SamlService {#samlservice}

The `SamlService` class provides the interface to the onelogin/php-saml
library:

-   SAML configuration management
-   SSO redirect handling
-   Response parsing

Location: `Classes/Service/SamlService.php`

### SettingsRepository {#settingsrepository}

The `SettingsRepository` provides access to SAML configuration records:

-   Auto-discovery by host
-   Settings retrieval

Location: `Classes/Domain/Repository/SettingsRepository.php`

### Middleware {#middleware}

The `RelayStateMiddleware` handles post-authentication redirects:

-   Deep link support
-   Logout redirect handling

Location: `Classes/Middleware/RelayStateMiddleware.php`

## Dependency Injection {#dependency-injection}

All services are registered in the DI container and can be injected into
your own classes:

```php
use Netresearch\NrSamlAuth\Service\SamlService;

class MyController
{
    public function __construct(
        private readonly SamlService $samlService
    ) {}
}
```

## Extending User Creation {#extending-user-creation}

To customize user creation, listen to the PSR-14 events documented in the
[Events](Events.html#events) section.

Example: Adding custom user attributes from SAML response:

```php
use Netresearch\NrSamlAuth\Event\BeforeUserCreationEvent;

class CustomUserAttributeListener
{
    public function __invoke(BeforeUserCreationEvent $event): void
    {
        $attributes = $event->getSamlAttributes();
        $userData = $event->getUserData();

        // Add custom attribute mapping
        $userData['custom_field'] = $attributes['customAttribute'][0] ?? '';

        $event->setUserData($userData);
    }
}
```
