我正在尝试在我的项目中使用 passport-saml 进行身份验证。到目前为止,我能够使用 passport.generateServiceProviderMetadata(decryptionCert) 来生成以下 metadata.xml:
<EntityDescriptor xmlns="urn:oasis:names:tc:SAML:2.0:metadata" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" entityID="passport-saml" ID="passport_saml">
<SPSSODescriptor protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol">
<KeyDescriptor use="encryption">
<ds:KeyInfo>
<ds:X509Data>
<ds:X509Certificate>MIICizCCAfQCCQCY8tKaMc0BMjANBgkqh...</ds:X509Certificate>
</ds:X509Data>
</ds:KeyInfo>
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc"/>
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc"/>
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc"/>
</KeyDescriptor>
<SingleLogoutService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="www.mywebsite.com/logout/callback"/>
<NameIDFormat>urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress</NameIDFormat>
<AssertionConsumerService index="1" isDefault="true" Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="www.mywebsite.com/login/callback"/>
</SPSSODescriptor>
</EntityDescriptor>
SamlStrategy 配置:
{
callbackUrl: 'www.mywebsite.com/login/callback',
entryPoint: 'https://openidp.feide.no/simplesaml/saml2/idp/SSOService.php',
decryptionPvk: 'MIICizCCAfQCCQCY8tKaMc0BMjANBgkqh...',
issuer: 'passport-saml',
logoutCallbackUrl: 'www.mywebsite.com/logout/callback'
}
为了满足 IDP 的要求,我需要进行一些更改:
- 将 AuthnRequestsSigned="false" 和 WantAssertionsSigned="true" 添加到 SPSSODescriptor 标记
- 将 KeyDescriptor 更改为使用“签名”而不是“加密”并删除 EncryptionMethod 标记
- 对 SingleLogoutService 使用 SOAP 绑定而不是 HTTP-POST
这是我想要实现的 metadata.xml:
<EntityDescriptor xmlns="urn:oasis:names:tc:SAML:2.0:metadata" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" entityID="passport-saml" ID="passport_saml">
<SPSSODescriptor AuthnRequestsSigned="false" WantAssertionsSigned="true" protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol">
<KeyDescriptor use="signing">
<ds:KeyInfo>
<ds:X509Data>
<ds:X509Certificate>MIICizCCAfQCCQCY8tKaMc0BMjANBgkqh...</ds:X509Certificate>
</ds:X509Data>
</ds:KeyInfo>
</KeyDescriptor>
<SingleLogoutService Binding="urn:oasis:names:tc:SAML:2.0:bindings:SOAP" Location="www.mywebsite.com/logout/callback"/>
<NameIDFormat>urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress</NameIDFormat>
<AssertionConsumerService index="1" isDefault="true" Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="www.mywebsite.com/login/callback"/>
</SPSSODescriptor>
</EntityDescriptor>
有没有办法配置护照以生成上述元数据?还是我应该手动创建它?任何帮助或建议将不胜感激!