简体   繁体   English

Laravel 基于 SAML 的 SSO

[英]SAML based SSO with Laravel

I'm implementing SAML based SSO for one of the php web application.我正在为 php web 应用程序之一实现基于 SAML 的 SSO。 I'm using google as IDP.我使用谷歌作为 IDP。 I've used Laravel 5 - Saml2 plugin and configured as per the steps given into it's documentation.我使用过Laravel 5 - Saml2插件并按照文档中给出的步骤进行配置。 I also added this app in google admin console as SAML app using the steps given here and configured entityId and acs url in saml2_settings.php.我还使用此处给出的步骤在 google 管理控制台中将此应用程序添加为 SAML 应用程序,并在 saml2_settings.php 中配置了 entityId 和 acs url。 However I'm not able to configure the x509cert certificates.但是我无法配置 x509cert 证书。 When I hit login url, user is being redirected to google for authentication however when I enters credentials it does not comes back to application and giving following error:当我点击登录 url 时,用户被重定向到 google 进行身份验证,但是当我输入凭据时,它不会返回到应用程序并出现以下错误:

  1. That's an error.那是一个错误。

Error: app_not_configured_for_user错误:app_not_configured_for_user

Service is not configured for this user.没有为该用户配置服务。

Following is my saml2_settings file:以下是我的 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' => '',
),

Can someone please help me.有人可以帮助我。

'sp' => array( 'sp' => 数组(

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

You are using Google as IdP so, why are you using google public cert on the sp section?您使用 Google 作为 IdP,那么为什么要在 sp 部分使用 Google 公共证书?

If you plan to sign the SAML messages sent by the SP, then you need to place there your own cert/private key.如果您打算对 SP 发送的 SAML 消息进行签名,那么您需要将您自己的证书/私钥放在那里。 You can generate self-signed certificates with this tool: https://www.samltool.com/self_signed_certs.php您可以使用此工具生成自签名证书: https : //www.samltool.com/self_signed_certs.php

If you have doubts about some settings fields, review the documentation of the Lavarel SAML plugin, but also review the documentation of php-saml , the SAML toolkit that the plugin uses.如果您对某些设置字段有疑问,请查看 Lavarel SAML 插件的文档,同时查看插件使用的 SAML 工具包php-saml文档

In order to debug what is happening, I also recommend you to use a browser extension to record your SAML Messages, use for example SAML Tracer and review the Status of the responses that will inform you about a possible error.为了调试正在发生的事情,我还建议您使用浏览器扩展来记录您的 SAML 消息,例如使用SAML Tracer并查看将通知您可能的错误的响应状态。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM