【问题标题】:Exposing/Configuring SimpleSamlphp's web route on laravel 6.12在 laravel 6.12 上公开/配置 SimpleSamlphp 的网络路由
【发布时间】: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


【解决方案1】:

这里有几个问题。 主要是我无法访问 simplesamlphp 的内置网页。

在我的本地环境中,laravel 不会让我脱离框架。 但我发现我可以在我的 AWS 开发服务器上使用 www/ 来到达那里。

因为它是使用 composer 安装的,所以我不得不使用这个链接并调整我的 baseurlpath。 http://example.com/www/module.php/core/frontpage_welcome.php 我无法强调访问 simplesaml 后端网页的重要性。这为您提供了完成项目所需的所有工具。 如果您无法访问它,请尝试在 URL 的 module.php 部分之前添加 www

我的元数据也有问题 这个:

<?php
$metadata['CLIENTCONFIG'] = array (
    'metadata-set' => 'saml20-idp-remote',
    'entityid' => 'CLIENTCONFIG',
    'AssertionConsumerService' => 'http://mysite/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',
    )
);
?>

应该是:

<?php
$metadata['CLIENTCONFIG'] = array (
    'metadata-set' => 'saml20-idp-remote',
    'entityid' => 'CLIENTCONFIG',
    'AssertionConsumerService' => 'http://mysite/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',
);
?>

我在数组中有最后一个块,它不应该在那里。 再次尝试访问该网页。

我还必须设置我的'baseurlpath' =&gt; 'http://example.com/www' 在我这样做之后,生成的所有路径都包括 www,我不需要将它们注入我的 URL 来访问它。

故事的寓意,尽一切可能到达www/module.php/core/frontpage_welcome.php 世界将从那里打开,包括创建元数据的工具。 (并且 example.com 应该是您正在处理的网站。不是联合服务器。只是为了澄清。)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-29
    • 1970-01-01
    • 2018-08-01
    • 2018-03-25
    • 2021-09-30
    • 2021-10-31
    相关资源
    最近更新 更多