simplesamlphp/xml-security
Secure, extensible XML signature and encryption library for PHP (xmldsig/xmlenc). Built on simplesamlphp/xml-common, it helps you sign/verify and encrypt/decrypt XML objects via high-level interfaces, with lower-level APIs available when needed.
Use Case Alignment:
simplesamlphp/xml-security package (v2.0.0) remains a niche dependency for XML security operations within the SimpleSAMLphp ecosystem. Its core purpose—XML Digital Signatures, Encryption, and Canonicalization—aligns with SAML/WS-Federation/XAdES workflows, but not with Laravel’s native use cases.onelogin/php-saml or shibboleth/php-saml for SAML, while native PHP (ext-dom, ext-xml) or libraries like Extenso/XMLSecurity may suffice for general XML needs.Key Features (Updated):
<saml:Assertion> conforms to SAML 2.0 XSD). This could help catch malformed payloads early but adds complexity.Direct Laravel Integration:
XmlSecurityService).Schema facade (if applicable).$validator = new \simplesaml\xmlsecurity\XMLSecurityDSig();
if (!$validator->validateXsdTypes($samlXml, 'saml-schema-provider.xsd')) {
throw new \Exception('Invalid SAML XSD types');
}
Indirect Use Cases:
storage/app/schemas/.SchemaValidator service to bridge the gap.DOMDocument::schemaValidate().| Risk Area | Severity (Updated) | Mitigation Strategy |
|---|---|---|
| XSD Schema Dependency | High | Ensure all required XSDs (e.g., SAML 2.0) are available and version-controlled. |
| Type-Safety Overhead | Medium | Test with malformed XML to confirm error handling aligns with Laravel’s exception system. |
| PHP Version Compatibility | Medium | Verify v2.0.0 supports Laravel’s PHP version (e.g., 8.1+). |
| Security Overhead | Medium | Strict type-checking could expose schema-related vulnerabilities (e.g., XXE). Use Laravel’s allow_url_fopen settings carefully. |
| Maintenance Burden | Low | SimpleSAMLphp’s ecosystem remains niche; monitor for future breaking changes. |
XMLSecurityException) to users or logs?DOMDocument with schemaValidate() or a dedicated XSD library (e.g., rubix/ml)?Laravel Compatibility:
composer.json for php requirement.ext-dom, ext-openssl, ext-xml. Enable these in php.ini or Laravel’s .env:
EXTENSIONS=dom,openssl,xml
storage/app/schemas/ and reference them dynamically:
$schemaPath = storage_path('app/schemas/saml-schema-provider.xsd');
Architectural Placement (Updated):
XmlSecurityService to include XSD validation:
namespace App\Services;
use simplesaml\xmlsecurity\XMLSecurityDSig;
class XmlSecurityService {
public function validateSamlWithSchema(string $xml, string $schemaPath): bool {
$validator = new XMLSecurityDSig();
return $validator->validateXsdTypes($xml, $schemaPath) &&
$validator->verifySignature($xml, config('saml.cert_path'));
}
}
FormRequest to validate XML payloads before processing:
public function rules() {
return [
'saml_xml' => ['required', function ($attribute, $value, $fail) {
$service = app(XmlSecurityService::class);
if (!$service->validateSamlWithSchema($value, storage_path('app/schemas/saml.xsd'))) {
$fail('Invalid SAML XML or signature.');
}
}],
];
}
composer require simplesamlphp/xml-security:^2.0
validateXsdTypes() method.saml-schema-provider.xsd from OASIS.XmlSecurityService with XSD validation.composer why-not to avoid conflicts.composer.json if schema validation behavior is critical:
"simplesamlphp/xml-security": "^2.0"
try {
$validator->validateXsdTypes($xml, $
How can I help you explore Laravel packages today?