【发布时间】:2020-05-26 00:13:21
【问题描述】:
我遇到了一个问题。我正在将 laravel 站点从 4.2 更新到 6.12,这主要是一个手动项目,我偶然发现了 laravel、AWS 和 SimpleSamlphp 的问题。当您将负载均衡器连接到 AWS 时,很难在 AWS 的一台服务器上拥有两个网站。
在 SimpleSamlphp 中,您需要将包的一部分暴露在互联网上。但是在 Laravel 中,如果不通过框架过滤它们,就很难运行原生 PHP 文件/脚本。由于我使用 composer 安装了 SimpleSamlphp,所以所有内容都托管在 vender 目录中。支持作曲家安装的文档很少,我不确定如何将simplesamlphp/simplesamlphp/www/* 公开到互联网。
顺便说一句,我正在努力成为服务提供者。
我无法配置 AWS 以支持第二个网页,Laravel 正在过滤我的路由,SimpleSamlphp 几乎没有关于 PSR 标准以及应该如何配置的文档。
我无法进入 simplesamlphp 的欢迎页面。 我可能缺少发布脚本吗?
我尝试将simplesamlphp/www/* 放入public/ 目录并使用我在 2013 年堆栈溢出帖子中找到的以下内容。
Route::get("/", function() {
ob_start();
require("www/module.php");
return ob_get_clean();
});
Route::get("/", function() {
ob_start();
require("www/index.php");
return ob_get_clean();
});
但它不起作用。 由于这是一次升级,从技术上讲,我应该能够获取元数据、配置,并且通过一些新的证书能够让它工作。但我被阻止暴露这些网页。 现在我陷入了身份验证循环,因为我无法收到 ACS 呼叫。至少这是我最好的猜测。
这是我的元数据,我不排除我弄错了。 saml20-idp-remote.php
<?php
$metadata['CLIENTCONFIG'] = array (
'metadata-set' => 'saml20-idp-remote',
'entityid' => 'CLIENTCONFIG',
'AssertionConsumerService' => 'http://myServer.com/acs_response',
'SingleSignOnService' =>
array (
0 =>
array (
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST',
'Location' => 'https://www.destination.com/',
),
'SingleLogoutService' => '',
'certificate' => 'x509.crt',
'certFingerprint'=>'OP:K7:91:89:9G:AB:0Y:JF:2V:F9:90:2V:6O:5C:41:9D:PL:FG:45:34',
'NameIDFormat' => 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient',
)
);
?>
authsources.php:
<?php
$config = [
/* This is the name of this authentication source, and will be used to access it later. */
'admin' => array(
// The default is to use core:AdminPassword, but it can be replaced with
// any authentication source.
'core:AdminPassword',
),
'CLIENTCONFIG' => array(
'saml:SP',
'idp'=>'CLIENTCONFIG',
'acs.Bindings' => array(
'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST',
'urn:oasis:names:tc:SAML:1.0:profiles:browser-post',
),
'ForceAuthn' => TRUE,
'entityID' => 'CLIENTCONFIG',
'saml:idp' => 'CLIENTCONFIG',
'discoURL' => null,
'privatekey' => 'saml.pem',
'certificate' => 'saml.crt',
'redirect.sign' => TRUE,
'redirect.validate' => TRUE,
'OrganizationName' => array(
'en' => 'TheCompanyIWorkFor',
),
'OrganizationURL'=>'www.TheCompanyIWorkFor.com',
'sign.authnrequest'=> TRUE,
),
];
现在,当我尝试这就是我的 SAML 检查员 所说的情况时: 如果您注意到我的 ACS 与我输入的 ASC 不匹配。我认为这是默认设置。
<samlp:AuthnRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
ID="_1234567890987654321234567890QWERTYUIOPASDFGHJKL"
Version="2.0"
IssueInstant="2020-02-10T14:36:01Z"
Destination=""
AssertionConsumerServiceURL="http://mywebsite.com/module.php/saml/sp/saml2-acs.php/CLIENTCONFIG"
ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
>
<saml:Issuer>CLIENTCONFIG</saml:Issuer>
<samlp:NameIDPolicy Format="urn:oasis:names:tc:SAML:2.0:nameid-format:transient"
AllowCreate="true"
/>
</samlp:AuthnRequest>
这是我获取登录路径的 UserController 方法:
use SimpleSAML\Auth\Simple;
public function getLogin(){
if(!\Auth::check()) {
$auth = New Simple('CLIENTCONFIG');
dump('getLogin method');
$auth->requireAuth([
'ReturnTo' => 'http://myWebsite/dashboard',
'KeepPost' => FALSE,
]);
\SimpleSAML\Session::getSessionFromRequest()->cleanup();
}
$data=Array();
// I get throw into an infinite loop of request generation.
return view('user.login', $data);
}
我对 SSO 知之甚少,而且我从事这方面的时间太久了! 因此,如果有人可以帮助将其配置为作曲家包,我将不胜感激。 目标是点击 SSO URL,并被重定向到 IDP 进行登录,然后被发回。 这可能是太多的信息,而且它被打乱了,但在这一点上我没有什么可失去的。
不,这不一样:Single sign on using SimpleSamlPhp wrapper on Laravel 这个问题实际上是针对另一个包的。
谢谢!
【问题讨论】:
-
你能检查我的 repo github.com/vipertecpro/simplesamllaravel,我已经尝试了自己的方法来实现 simplesaml,没有现有的包可以帮助我实现它,但我做到了。我面临的主要问题是 simplesaml 不会让你破坏它的结构,你必须使用整个 repo,我们只能操作的是前端重定向。
-
我会的。谢谢你。我解决了这个问题。快来发布答案!
标签: php laravel amazon-web-services laravel-6 simplesamlphp