asp.net 是否设置AttributeConsumingService索引?

yhived7q  于 2022-12-24  发布在  .NET
关注(0)|答案(1)|浏览(133)

我正在使用带有Saml2AuthenticationModule和Sustainsys.Saml2.HttpModule的可持续系统SAML2连接IDP
因为我想返回元数据,所以我需要将AttributeConsumingService索引从0(默认值)设置为1。试图找到更改它的方法,但没有成功。有人知道如何更改吗?

<AttributeConsumingService index="0" isDefault="true">
            <ServiceName xml:lang="en">SP</ServiceName>
            <RequestedAttribute isRequired="true" Name=...
    ...
sczxawaw

sczxawaw1#

您可以在Startup.cs中配置该值

.AddSaml2("IDP", "IDP", opt =>
{
    opt.SPOptions = new Sustainsys.Saml2.Configuration.SPOptions
    {
        EntityId = new EntityId(ipdUrl),
        ReturnUrl = new Uri(webSiteUrl),
        ModulePath = string.Format("/saml2/{0}", "idp"), 
        AuthenticateRequestSigningBehavior = SigningBehavior.Always,
        MinIncomingSigningAlgorithm = "http://www.w3.org/2000/09/xmldsig#rsa-sha1"
    };

    RequestedAttribute requestedAttributeEmail = new RequestedAttribute("email");
    requestedAttributeEmail.FriendlyName = "Email";
    requestedAttributeEmail.NameFormat = RequestedAttribute.AttributeNameFormatBasic;
    requestedAttributeEmail.IsRequired = false;

    AttributeConsumingService attributeConsumingService = new AttributeConsumingService();

    attributeConsumingService.RequestedAttributes.Add(requestedAttributeEmail);

    attributeConsumingService.ServiceNames.Add(new LocalizedName("Required attributes", "en"));
    attributeConsumingService.IsRequired = true;
    attributeConsumingService.Index = 1;
    attributeConsumingService.IsDefault = true;

    opt.SPOptions.AttributeConsumingServices.Add(attributeConsumingService);    
});

相关问题