php 使用saml,php – 使用SimpleSAML作为SP和IDP用于开发环境

我正在尝试使用我的网络应用程序中的SAML进行身份验证.

Backtrace:

1 /app_path/application/lib/simplesamlphp/www/_include.php:37 (SimpleSAML_exception_handler)

0 [builtin] (N/A)

Caused by: Exception: Unable to find the current binding.

Backtrace:

2 /app_path/application/lib/simplesamlphp/lib/SAML2/Binding.php:81 (SAML2_Binding::getCurrentBinding)

1 /app_path/application/lib/simplesamlphp/modules/saml/lib/IdP/SAML2.php:266 (sspmod_saml_IdP_SAML2::receiveAuthnRequest)

0 /app_path/application/lib/simplesamlphp/www/saml2/idp/SSOService.php:19 (N/A)

建立 :

>我的应用程序在本地与主机:trunk.sam.net一起运行

> Simplesaml,SP,作为库包含在应用程序中,可从以下位置访问:trunk.sam.net/simplesaml

> Simplesaml,IdP,在本地安装并运行于:auth.sam.net

这两个simplesaml实际上都使用相同的代码和配置文件(它们共享相同的文档根目录)

配置:

config.php文件

'enable.saml20-idp' => true,

'enable.shib13-idp' => true,

authsources.php

'default-sp-trunk.sam.net' => array(

'saml:SP',

'entityID' => 'http://trunk.sam.net',

'idp' => 'http://auth.sam.net/simplesaml/saml2/idp/metadata.php',

'ssoPortalUrl'=> 'http://auth.sam.net/simplesaml/saml2/idp/SSOService.php',

'bkmapping' => array(

'login' => 'uid',

'eMail' => 'mail'

)

),

'example-userpass' => array(

'exampleauth:UserPass',

'shf:pwd' => array(

'uid' => array('shf'),

'eduPersonAffiliation' => array('mail', 'shf@bk-soft.com')

),

'shl:pwd' => array(

'uid' => array('shl')

),

),

saml20-IDP-hosted.php

$metadata['__DYNAMIC:1__'] = array(

/*

* The hostname for this IdP. This makes it possible to run multiple

* IdPs from the same configuration. '__DEFAULT__' means that this one

* should be used by default.

*/

'host' => '__DEFAULT__',

/*

* The private key and certificate to use when signing responses.

* These are stored in the cert-directory.

*/

'privatekey' => 'server.pem',

'certificate' => 'server.crt',

/*

* The authentication source which should be used to authenticate the

* user. This must match one of the entries in config/authsources.php.

*/

'auth' => 'example-userpass',

/*

* The interoperable SAML 2 profile specifies that attributes should be delivered using the urn:oasis:names:tc:SAML:2.0:attrname-format:uri NameFormat.

* We therefore recommended enabling this in new installations. This can be done by adding the following to the saml20-idp-hosted configuration:

*/

'attributes.NameFormat' => 'urn:oasis:names:tc:SAML:2.0:attrname-format:uri',

'authproc' => array(

// Convert LDAP names to oids.

100 => array('class' => 'core:AttributeMap', 'name2oid'),

),

);

saml20-IDP-remote.php

$metadata['http://auth.sam.net/simplesaml/saml2/idp/metadata.php'] = array (

'entityid' => 'http://auth.sam.net/simplesaml/saml2/idp/metadata.php',

'contacts' =>

array (0 =>

array (

'contactType' => 'technical',

'surName' => 'Administrator',

'emailAddress' => array (0 => 'support@bluekiwi-software.com'),

),

),

'metadata-set' => 'saml20-idp-remote',

'SingleSignOnService' => array (0 => array (

'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',

'Location' => 'http://auth.sam.net/simplesaml/saml2/idp/SSOService.php',

),

),

'SingleLogoutService' =>

array ( 0 => array (

'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',

'Location' => 'http://auth.sam.net/simplesaml/saml2/idp/SingleLogoutService.php',

),

),

'ArtifactResolutionService' =>

array (

),

'keys' =>

array (0 => array (

'encryption' => false,

'signing' => true,

'type' => 'X509Certificate',

'X509Certificate' => 'MIICgTCCAeoCCQCbOlrWDdX7FTANBgkqhkiG9w0BAQUFADCBhDELMAkGA1UEBhMCTk8xGDAWBgNVBAgTD0FuZHJlYXMgU29sYmVyZzEMMAoGA1UEBxMDRm9vMRAwDgYDVQQKEwdVTklORVRUMRgwFgYDVQQDEw9mZWlkZS5lcmxhbmcubm8xITAfBgkqhkiG9w0BCQEWEmFuZHJlYXNAdW5pbmV0dC5ubzAeFw0wNzA2MTUxMjAxMzVaFw0wNzA4MTQxMjAxMzVaMIGEMQswCQYDVQQGEwJOTzEYMBYGA1UECBMPQW5kcmVhcyBTb2xiZXJnMQwwCgYDVQQHEwNGb28xEDAOBgNVBAoTB1VOSU5FVFQxGDAWBgNVBAMTD2ZlaWRlLmVybGFuZy5ubzEhMB8GCSqGSIb3DQEJARYSYW5kcmVhc0B1bmluZXR0Lm5vMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDivbhR7P516x/S3BqKxupQe0LONoliupiBOesCO3SHbDrl3+q9IbfnfmE04rNuMcPsIxB161TdDpIesLCn7c8aPHISKOtPlAeTZSnb8QAu7aRjZq3+PbrP5uW3TcfCGPtKTytHOge/OlJbo078dVhXQ14d1EDwXJW1rRXuUt4C8QIDAQABMA0GCSqGSIb3DQEBBQUAA4GBACDVfp86HObqY+e8BUoWQ9+VMQx1ASDohBjwOsg2WykUqRXF+dLfcUH9dWR63CtZIKFDbStNomPnQz7nbK+onygwBspVEbnHuUihZq3ZUdmumQqCw4Uvs/1Uvq3orOo/WJVhTyvLgFVK2QarQ4/67OZfHd7R+POBXhophSMv1ZOo',

),

1 =>

array (

'encryption' => true,

'signing' => false,

'type' => 'X509Certificate',

'X509Certificate' => 'MIICgTCCAeoCCQCbOlrWDdX7FTANBgkqhkiG9w0BAQUFADCBhDELMAkGA1UEBhMCTk8xGDAWBgNVBAgTD0FuZHJlYXMgU29sYmVyZzEMMAoGA1UEBxMDRm9vMRAwDgYDVQQKEwdVTklORVRUMRgwFgYDVQQDEw9mZWlkZS5lcmxhbmcubm8xITAfBgkqhkiG9w0BCQEWEmFuZHJlYXNAdW5pbmV0dC5ubzAeFw0wNzA2MTUxMjAxMzVaFw0wNzA4MTQxMjAxMzVaMIGEMQswCQYDVQQGEwJOTzEYMBYGA1UECBMPQW5kcmVhcyBTb2xiZXJnMQwwCgYDVQQHEwNGb28xEDAOBgNVBAoTB1VOSU5FVFQxGDAWBgNVBAMTD2ZlaWRlLmVybGFuZy5ubzEhMB8GCSqGSIb3DQEJARYSYW5kcmVhc0B1bmluZXR0Lm5vMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDivbhR7P516x/S3BqKxupQe0LONoliupiBOesCO3SHbDrl3+q9IbfnfmE04rNuMcPsIxB161TdDpIesLCn7c8aPHISKOtPlAeTZSnb8QAu7aRjZq3+PbrP5uW3TcfCGPtKTytHOge/OlJbo078dVhXQ14d1EDwXJW1rRXuUt4C8QIDAQABMA0GCSqGSIb3DQEBBQUAA4GBACDVfp86HObqY+e8BUoWQ9+VMQx1ASDohBjwOsg2WykUqRXF+dLfcUH9dWR63CtZIKFDbStNomPnQz7nbK+onygwBspVEbnHuUihZq3ZUdmumQqCw4Uvs/1Uvq3orOo/WJVhTyvLgFVK2QarQ4/67OZfHd7R+POBXhophSMv1ZOo',

),

),

);

saml20-SP-remote.php

$metadata['http://trunk.sam.net'] = array (

'AssertionConsumerService' => 'http://trunk.sam.net/simplesaml/module.php/saml/sp/saml2-acs.php/default-sp-trunk.sam.net',

'SingleLogoutService' => 'http://trunk.sam.net/simplesaml/module.php/saml/sp/saml2-logout.php/default-sp-trunk.sam.net',

);

谁能指出我做错了什么?

我错过了配置条目/文件吗?

我应该使用单独的simplesaml安装吗?

谢谢你的建议

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
SAML 2.0 的 SPIDP 之间的通信需要使用证书进行加密和签名。以下是配置 SPIDP 证书以及双向认证代码的示例: 1. 配置 SP 证书 SP 需要拥有一个证书用于加密和签名 SAML 请求和响应。将此证书放在 SP 的配置文件中,以便 SP 可以使用它与 IDP 通信。以下是示例代码: ```php $settings = array( 'sp' => array( 'entityId' => 'https://sp.example.com/metadata', 'assertionConsumerService' => array( 'url' => 'https://sp.example.com/acs', 'binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST', ), 'NameIDFormat' => 'urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified', 'privateKey' => 'file://path/to/sp-private-key.pem', 'x509cert' => 'file://path/to/sp-certificate.pem', ), ); ``` 2. 配置 IDP 证书 IDP 需要拥有一个证书用于加密和签名 SAML 请求和响应。将此证书放在 IDP 的配置文件中,以便 IDP 可以使用它与 SP 通信。以下是示例代码: ```php $settings = array( 'idp' => array( 'entityId' => 'https://idp.example.com/metadata', 'singleSignOnService' => array( 'url' => 'https://idp.example.com/sso', 'binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect', ), 'singleLogoutService' => array( 'url' => 'https://idp.example.com/slo', 'binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect', ), 'x509cert' => 'file://path/to/idp-certificate.pem', ), ); ``` 3. 配置双向认证 在某些情况下,SPIDP 可能需要进行双向认证,以确保通信的双方都是预期的实体。以下是示例代码: ```php $settings = array( 'security' => array( 'authnRequestsSigned' => true, 'wantAssertionsSigned' => true, 'signMetadata' => true, 'signatureAlgorithm' => 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256', 'digestAlgorithm' => 'http://www.w3.org/2001/04/xmlenc#sha256', 'requestedAuthnContext' => array( 'Comparison' => 'exact', 'AuthnContextClassRef' => 'urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport', ), 'signatureKey' => 'file://path/to/private-key.pem', 'x509cert' => 'file://path/to/certificate.pem', 'validateAuthnContext' => true, 'wantNameIdEncrypted' => true, 'wantAssertionsEncrypted' => true, 'wantXMLValidation' => true, ), ); ``` 以上是示例代码,具体配置需根据实际情况进行调整。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值