基于SAML的Laravel单点登录(SSO)

10
我正在为一个PHP Web应用实现基于SAML的SSO。我使用Google作为IDP。我使用Laravel 5 - Saml2插件,并按照其文档中给出的步骤进行配置。我还按照此处所述的步骤将此应用添加到Google管理控制台作为SAML应用程序,并在saml2_settings.php中配置了entityId和ACS URL。但是,我无法配置x509cert证书。当我点击登录URL时,用户被重定向到Google进行身份验证,但是当我输入凭据时,它不会返回应用程序,并显示以下错误:
  1. That’s an error.

Error: app_not_configured_for_user

Service is not configured for this user.

以下是我的saml2_settings文件:
'sp' => array(

    // Specifies constraints on the name identifier to be used to
    // represent the requested subject.
    // Take a look on lib/Saml2/Constants.php to see the NameIdFormat supported
    'NameIDFormat' => 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent',

    // Usually x509cert and privateKey of the SP are provided by files placed at
    // the certs folder. But we can also provide them with the following parameters
    'x509cert' => 'I ADDED x509certs here which I downloaded from google',
    'privateKey' => '',

    //LARAVEL - You don't need to change anything else on the sp
    // Identifier of the SP entity  (must be a URI)
    'entityId' => 'snipeit', //LARAVEL: This would be set to saml_metadata route
    // Specifies info about where and how the <AuthnResponse> message MUST be
    // returned to the requester, in this case our SP.
    'assertionConsumerService' => array(
        // URL Location where the <Response> from the IdP will be returned
        'url' => 'http://dev.sb.com/snipeit/public/account/profile', //LARAVEL: This would be set to saml_acs route
        //SAML protocol binding to be used when returning the <Response>
        //message.  Onelogin Toolkit supports for this endpoint the
        //HTTP-Redirect binding only
        'binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST',
    ),
    // Specifies info about where and how the <Logout Response> message MUST be
    // returned to the requester, in this case our SP.
    'singleLogoutService' => array(
        // URL Location where the <Response> from the IdP will be returned
        'url' => '', //LARAVEL: This would be set to saml_sls route
        // SAML protocol binding to be used when returning the <Response>
        // message.  Onelogin Toolkit supports for this endpoint the
        // HTTP-Redirect binding only
        'binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
    ),
),

// Identity Provider Data that we want connect with our SP
'idp' => array(
    // Identifier of the IdP entity  (must be a URI)
    'entityId' => '',
    // SSO endpoint info of the IdP. (Authentication Request protocol)
    'singleSignOnService' => array(
        // URL Target of the IdP where the SP will send the Authentication Request Message
        'url' => $idp_host,
        // SAML protocol binding to be used when returning the <Response>
        // message.  Onelogin Toolkit supports for this endpoint the
        // HTTP-POST binding only
        'binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
    ),
    // SLO endpoint info of the IdP.
    'singleLogoutService' => array(
        // URL Location of the IdP where the SP will send the SLO Request
        'url' => $idp_host . '/saml2/idp/SingleLogoutService.php',
        // SAML protocol binding to be used when returning the <Response>
        // message.  Onelogin Toolkit supports for this endpoint the
        // HTTP-Redirect binding only
        'binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
    ),
    // Public x509 certificate of the IdP
    'x509cert' => 'SAME CERTIFICATES I ADDED HERE AS WELL',        /*
     *  Instead of use the whole x509cert you can use a fingerprint
     *  (openssl x509 -noout -fingerprint -in "idp.crt" to generate it)
     */
    // 'certFingerprint' => '',
),

有人能帮我吗?

1个回答

9

'sp' => array(

'x509cert' => 'I ADDED x509certs here which I downloaded from google',
'privateKey' => '',

您正在使用Google作为IdP,那么为什么在sp部分要使用Google的公共证书?

如果您计划签名SP发送的SAML消息,则需要放置您自己的证书/私钥。 您可以使用此工具生成自签名证书: https://www.samltool.com/self_signed_certs.php

如果您对某些设置字段有疑问,请查阅Lavarel SAML插件的文档,但也请查看php-saml的文档,该插件使用了它。

为了调试发生了什么,我还建议您使用浏览器扩展来记录您的SAML消息,例如使用SAML Tracer ,并检查响应的状态,这将通知您可能的错误。


Smartin,看起来你对Laravel 5中的SAML2很了解。你能帮我解决这个问题吗?https://dev59.com/0Z_ha4cB1Zd3GeqPx2X- - code-8

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接