2016-03-15 203 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