1

我目前正在使用名为 Kentor.AuthServices 的 SAML2 的 .NET 4.5 实现(参见 github 上的项目)。我正在尝试从我的网站 [MySite] 转到 [BenefitsSiteForSingleSignon]。

我希望发送超过 2 个属性,1 个称为语言,可以是 en-us、en-ca 或 fr-ca,1 个称为 employee_number,它将是一个 6 位数字。

但是,我被困在这一点上,我已经修改了应用程序的 MVC 实现中的 web.config(使用来自 github 的 SampleApplicationMVC),我可以让它向提供者 [BenefitsSiteForSingleSignon] 发送 SAML 请求(对不起,如果我使用不正确的 SAML 术语),但我被困在如何填写员工编号字段和语言字段的问题上。

我已经按照说明修改了 web.config 文件,如下所示,如果有人对此帮助有经验,将不胜感激。

总之,我需要使用 Kentor.AuthServices for .NET 从我的公司网站访问并单点登录到另一个正在提取 SAML2 请求的外部网站。我需要提供字段语言和员工编号,发行人 ID 是 [MySite]。谢谢!

-Web.Config 开始-

<?xml version="1.0" encoding="utf-8"?>
    <!--
      For more information on how to configure your ASP.NET application, please visit
      http://go.microsoft.com/fwlink/?LinkId=301880
      -->
    <configuration>
      <configSections>
        <section name="system.identityModel" type="System.IdentityModel.Configuration.SystemIdentityModelSection, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <section name="system.identityModel.services" type="System.IdentityModel.Services.Configuration.SystemIdentityModelServicesSection, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <section name="kentor.authServices" type="Kentor.AuthServices.Configuration.KentorAuthServicesSection, Kentor.AuthServices" />
        <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
      </configSections>
      <appSettings>
        <add key="webpages:Version" value="3.0.0.0" />
        <add key="webpages:Enabled" value="false" />
        <add key="ClientValidationEnabled" value="true" />
        <add key="UnobtrusiveJavaScriptEnabled" value="true" />
      </appSettings>
      <system.web>
        <compilation debug="true" targetFramework="4.5" />
        <httpRuntime targetFramework="4.5" />
        <authentication mode="Forms">
          <forms loginUrl="~/AuthServices/SignIn" />
        </authentication>
      </system.web>
      <system.webServer>
        <modules>
          <add name="SessionAuthenticationModule" type="System.IdentityModel.Services.SessionAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="managedHandler" />
        </modules>
      </system.webServer>
      <kentor.authServices entityId="[MySite]" returnUrl="[MySite]">
        <metadata cacheDuration="0:15:00">
          <organization name="Kentor IT AB" displayName="Kentor" url="http://www.kentor.se" language="sv" />
          <contactPerson type="Other" email="info@kentor.se" />
          <requestedAttributes>
            <add friendlyName="employee_number" name="urn:employee_number" nameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri" isRequired="true" />
           <add friendlyName="language" name="urn:language" nameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri" isRequired="true" />
          </requestedAttributes>
        </metadata>
        <identityProviders>
                <add entityId="http://stubidp.kentor.se/Metadata" destinationUri="http://stubidp.kentor.se/" allowUnsolicitedAuthnResponse="true" binding="HttpRedirect">
            <signingCertificate fileName="~/App_Data/Kentor.AuthServices.StubIdp.pfx" />
          </add>
          <add entityId="[BenefitsSiteForSingleSignon]" destinationUri="[BenefitsSiteForSingleSignon]" allowUnsolicitedAuthnResponse="true" binding="HttpRedirect">
            <signingCertificate fileName="~/App_Data/BenefitsSiteSSO.cer" />
          </add>
        </identityProviders>
        <!--<federations>
          <add metadataUrl="http://localhost:52071/Federation" allowUnsolicitedAuthnResponse="true" />
        </federations>-->
      </kentor.authServices>
      <system.identityModel />
      <system.identityModel.services>
        <federationConfiguration>
          <cookieHandler requireSsl="false" />
        </federationConfiguration>
      </system.identityModel.services>
      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-5.2.2.0" newVersion="5.2.2.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
      <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
          <parameters>
            <parameter value="v11.0" />
          </parameters>
        </defaultConnectionFactory>
        <providers>
          <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
        </providers>
      </entityFramework>
    </configuration>
4

2 回答 2

4

在 SAML 术语中,[MySite] 是 Idp(身份提供者),[BenefitsSiteForSingleSignOn] 是 SP(服务提供者)。Kentor.AuthServices 主要是一个 SP 实现;不幸的是,这不是您所需要的。

但是,创建和发送未经请求的 Saml2Response 所需的组件在 AuthServices 中可用。之所以称为主动请求,是因为 Idp 向 SP 发送了响应,而 SP 从未请求过它。要使 [MySite] 作为身份提供者工作并发送未经请求的响应,您应该查看 Kentor.AuthServices 源中的 stubidp。它创建并发送 Saml2Responses。

在此,您将ClaimsIdentity使用用户 ID 和附加信息(语言、员工编号等)创建一个自定义声明。然后,您可以Saml2Response基于该身份创建一个并在 a 的帮助下将其发送SamlRedirectBinding到 [BenefitsSiteForSingleSignOn]。

于 2014-10-31T14:37:18.190 回答
0

非常有用的信息;另请注意,kentor 样本的设计如下:

  1. HttpModule 示例:用于模块和 kentor 配置理解(模块实现也被 MVC 中间件使用)

  2. MVC 示例:用于 MVC 中间件和 kentor 配置理解

  3. Owin 示例:用于理解 kentor 中间件

  4. IdentityServer 示例:每个人都想要这个 hotcake(使用 kentor 中间件)

  5. 以上都是 SP 发起的所以 KentorStub 示例:用于理解 idp 发起(它使用 MVC 中间件(而 MVC 中间件使用 httpmodule))

当您运行 1、2、3、4 个样本时,您会从中获得 SP 元数据(SPSSODescriptor),localhost:52071/AuthServices 但运行 5 会从同一链接获得 IDP 元数据,即localhost:52071/AuthServices

于 2017-12-18T18:49:01.323 回答