Skip to main content

Overview

litesaml/saml exposes two wrapper classes that map to the two SAML 2.0 roles:

ClassRoleUse case
ServiceProviderWrapperService Provider (SP)Your app delegates authentication to an IdP
IdentityProviderWrapperIdentity Provider (IdP)Your app authenticates users for other apps

Both wrappers require a MessageHandler instance, which handles HTTP binding encoding/decoding and optional message signing.

Setting up MessageHandler

MessageHandler depends on two PSR-17 interfaces: ResponseFactoryInterface and StreamFactoryInterface. Any PSR-17 compatible package works. The examples throughout this documentation use nyholm/psr7.

composer require nyholm/psr7
use Nyholm\Psr7\Factory\Psr17Factory;
use Litesaml\Support\MessageHandler;

$factory = new Psr17Factory();
$handler = new MessageHandler($factory, $factory);

Instantiate the MessageHandler once and reuse it for the lifetime of your request.

Next steps