Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Lightsaml Laravel Package

aerialship/lightsaml

SAML 2.0 toolkit for Laravel/PHP to add SSO and identity federation to your apps. Provides helpers for SAML authentication flows, metadata, and certificate handling, making it easier to integrate with common IdPs and SPs.

View on GitHub
Deep Wiki
Context7

METADATA

Metadata building

Use aerialship:lightsaml:sp:meta:build command for simple cases

$ed = new EntityDescriptor();
$sp = new SpSsoDescriptor();
$ed->addItem($sp);

// KeyDescriptor
$certificate = new X509Certificate();
$certificate->loadFromFile($certificatePath);
$keyDescriptor = new KeyDescriptor('signing', $certificate);
$ed->addItem($keyDescriptor);

// SingleLogoutService
$s = new SingleLogoutService();
$s->setLocation($url);
$s->setBinding($this->resolveBinding($binding));
$sp->addService($s);

// AssertionConsumerService
$s = new AssertionConsumerService($binding1, $url, 0);
$sp->addService($s);
$s = new AssertionConsumerService($binding2, $url, 1);
$sp->addService($s);

Saving metadata to xml

$ed = new Model\Metadata\EntityDescriptor();
// ...
$context = new Meta\SerializationContext();
$ed->getXml($context->getDocument(), $context);
file_put_contents($context->getDocument()->saveXML(), $xml);

Loading metadata from xml

$doc = new \DOMDocument();
$doc->load('sp.xml');
$ed = new EntityDescriptor();
$ed->loadFromXml($doc->firstChild);

AUTHN REQUEST

$spMeta = new Meta\SpMeta();
$spMeta->setNameIdFormat(NameIDPolicy::PERSISTENT);
$spED = getEntityDescriptorSP();
$idpED = getEntityDescriptorIDP();

$builder = new Meta\AuthnRequestBuilder($spED, $idpED, $spMeta);
$request = $builder->build();

SENDING MESSAGE

HTTP Redirect

$binding = new Binding\HttpRedirect();
$bindingResponse = $binding->send($message);
$bindingResponse->render();

HTTP POST

$binding = new Binding\HttpPost();
$bindingResponse = $binding->send($message);
$bindingResponse->render();

RECEIVING MESSAGE

$request = new Binding\Request();
$request->setQueryString($_SERVER['QUERY_STRING']);
$request->setGet($_GET);
$request->getPost($_POST);
$request->setRequestMethod($_SERVER['REQUEST_METHOD']);

$detector = new BindingDetector();
$binding = $detector->instantiate($this->bindingDetector->getBinding($bindingRequest));

$message = $binding->receive($bindingRequest);
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
xiloryx/log-collector
a21ns1g4ts/filament-stripe
la-php/laravel-admin
artisan-build/community-prompts
vleroy/smart
ayles-software/laravel-australian-public-holidays
cboxdk/laravel-id-spatie
cboxdk/laravel-id-billing
cboxdk/laravel-id-billing-bridge
simple-as-fuck/php-performance-log
hsluv/hsluv
seampact/codegen
seampact/hooks
seampact/ir
mehedimi/laravel-amp-mail
happones/laravel-vue-i18n-generator
jwerd/inertia-table
siberfx/flysystem-wasabi
hollyit/token-replace
ippanelcom/laravel-sdk