2016-03-15 198 views
8

我正在为其中一个php web应用程序实施基于SAML的SSO。我使用谷歌作为IDP。我已经使用了Laravel 5 - Saml2插件,并按照其文档中给出的步骤进行配置。我还使用在步骤here以及在saml2_settings.php中配置了entityId和acs url的步骤,在Google管理控制台中添加了此应用作为SAML应用。但是我无法配置x509cert证书。当我打的登录网址,用户被重定向到谷歌的认证但是当我输入凭据它不回来的应用程序,并给予下列错误:基于SAML的SSO与Laravel

  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' => '', 
), 

有人可以帮我吗。

回答

3

'sp' => array(

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

您正在使用谷歌作为IdP所以,为什么你在sp部分使用谷歌公共证书?

如果您打算签署由SP发送的SAML消息,那么您需要在那里放置您自己的证书/专用密钥。您可以使用此工具生成的自签名证书:https://www.samltool.com/self_signed_certs.php

如果您对一些设置字段疑惑,审查Lavarel SAML插件的文档,同时也检讨documentation of php-saml,该插件使用SAML工具包。

为了调试发生了什么,我也建议你使用浏览器扩展来记录您的SAML消息,例如使用SAML Tracer 和审查会告诉你关于一个可能的错误响应的状态。

+0

Smartin,看起来你对Laravel 5很了解SAML2。你能帮我解决这个问题吗? http://stackoverflow.com/questions/42396868/laravel-5-integrate-with-saml-2-with-existing-idp – ihue