如何在php中反序列化SAML请求-无法安装LightSAML

如何在php中反序列化SAML请求-无法安装LightSAML,php,laravel,saml,Php,Laravel,Saml,我正在尝试将LightSAML安装到Laravel应用程序中,以对HTTP POST请求执行一些非常基本的反序列化,但出现错误: Your requirements could not be resolved to an installable set of packages. Problem 1 - Conclusion: don't install lightsaml/lightsaml 1.3.6 ..... Installation failed, reverting ./c

我正在尝试将LightSAML安装到Laravel应用程序中,以对HTTP POST请求执行一些非常基本的反序列化,但出现错误:

 Your requirements could not be resolved to an installable set of packages.

 Problem 1
 - Conclusion: don't install lightsaml/lightsaml 1.3.6
 .....

Installation failed, reverting ./composer.json to its original content.
它看起来确实有点老了,所以我根本不确定它是否能工作——如果不能,有人能提出更简单的方法来反序列化和访问SAML请求的各个属性吗


我也看到了,但是它看起来比我需要的做得更多-我不需要使用SAML来完成实际的身份验证部分,我只需要接受SAML http post并将该数据用于我自己的定制身份验证令牌创建。

我认为解决方案是错误的:您的需求无法解析为一组可安装的包。我猜在你的LIB里一定是和LightSaml有冲突。只是不相容

可能在/Users/user/.composer或其他地方有一个composer.lock文件妨碍了更新

尝试以下步骤:

进入全局编写器文件夹C:\Users\your\u name\AppData\Roaming\composer 编辑了composer.json,添加到require:your_package:number.* 在命令行中:编写器全局更新。 正如您所写,解决方案可能会添加:

"repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/frostieDE/lightSAML"
    }
],

祝你好运

很抱歉,我不得不将此添加到composer并进行更新:

"repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/frostieDE/lightSAML"
    }
],

如果只是对发送到端点的SAMLResponse数据进行解码,那么只要不加密,就可以轻松实现

SAMLResponse是base64编码的,因此您只需对其进行解码。在接收数据的控制器方法中,您将执行以下操作:

// Decode the data into the original XML document
$xmlPayload = base64_decode($request->get('SAMLResponse'));
string(34) "saml2:Attribute[@firstName] -> Ray"
string(37) "saml2:Attribute[@lastName] -> Charles"
string(48) "saml2:Attribute[@email] -> ray.charles@music.com"
string(48) "saml2:Attribute[@login] -> ray.charles@music.com"
string(44) "saml2:Attribute[@id] -> 11uboeg2g0bKNxyk01z7"
现在,需要对刚刚解码的XML数据进行解析。鉴于文档很小,使用DOMDocument就足够了:

// Load the XML document
$doc = new DOMDocument();
$doc->loadXML($xmlPayload);

// Traverse User elements
foreach ($doc->getElementsByTagName('Attribute') as $attribute) {
    var_dump($attribute->nodeName.'[@'.$attribute->getAttribute('Name').'] -> '.$attribute->nodeValue);
}
这将输出如下内容:

// Decode the data into the original XML document
$xmlPayload = base64_decode($request->get('SAMLResponse'));
string(34) "saml2:Attribute[@firstName] -> Ray"
string(37) "saml2:Attribute[@lastName] -> Charles"
string(48) "saml2:Attribute[@email] -> ray.charles@music.com"
string(48) "saml2:Attribute[@login] -> ray.charles@music.com"
string(44) "saml2:Attribute[@id] -> 11uboeg2g0bKNxyk01z7"
这只是一个例子,因为属性可能会根据单点登录IdP的设置而改变


我使用Okta的有效载荷进行了测试。

您找到解决方案了吗?