【问题标题】:Add a Kerberos authentication to existing WebService in asp.net c#在 asp.net c# 中向现有 Web 服务添加 Kerberos 身份验证
【发布时间】:2019-11-07 09:44:28
【问题描述】:

有一个现有的 WebService 连接到代理服务器,我需要在其中添加 Kerberos 身份验证策略。

我知道关于 Kerberos 身份验证的现有主题,但是任何人都可以分享一些关于如何在 WebService 上添加 Kerberos 身份验证的代码 sn-ps?

几乎所有 Kerberos 主题都只讨论 Kerberos 身份验证的工作原理。提前致谢。

【问题讨论】:

标签: c# asp.net kerberos


【解决方案1】:

从启用 WSE 3 开始,然后启用该策略。在 web.config 文件中执行此操作

<configSections>
  <section name="microsoft.web.services3" 

    type="Microsoft.Web.Services3.Configuration.WebServicesConfiguration,
         Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, 
         PublicKeyToken=31bf3856ad364e35" />
</configSections>

<system.web>

  <compilation debug="true">
    <assemblies>
      <add assembly="Microsoft.Web.Services3, Version=3.0.0.0,
Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </assemblies>
  </compilation>

  <webServices>
    <soapExtensionImporterTypes>
      <add type="Microsoft.Web.Services3.Description.WseExtensionImporter,
                    Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, 
                    PublicKeyToken=31bf3856ad364e35" />
    </soapExtensionImporterTypes>
    <soapServerProtocolFactory 

      type="Microsoft.Web.Services3.WseProtocolFactory,Microsoft.Web.Services3,
            Version=3.0.0.0,Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
  </webServices>
</system.web>

<microsoft.web.services3>
  <policy fileName="wse3policyCache.config" />
  <tokenIssuer>
    <statefulSecurityContextToken enabled="false" />
  </tokenIssuer>
</microsoft.web.services3>

添加策略文件并配置策略:在你的项目中添加一个配置文件‘FileName.config’,然后添加以下标签:

<policies xmlns="http://schemas.microsoft.com/wse/2005/06/policy">
  <policy name="KerberosService">
    <authorization>
      <allow user="Mawhiba\Akram" />
      <deny role="*" />
    </authorization>
    <kerberosSecurity establishSecurityContext="true"

    renewExpiredSecurityContext="true" requireSignatureConfirmation="false"

    messageProtectionOrder="SignBeforeEncryptAndEncryptSignature"

    requireDerivedKeys="true" ttlInSeconds="300">
      <protection>
        <request 

           signatureOptions="IncludeAddressing, IncludeTimestamp, 
                             IncludeSoapBody" 

           encryptBody="true" />
        <response signatureOptions="IncludeAddressing, IncludeTimestamp, 
                                    IncludeSoapBody" 

                  encryptBody="true" />
        <fault signatureOptions="IncludeAddressing, IncludeTimestamp, 
                                 IncludeSoapBody" 

               encryptBody="false" />
      </protection>
    </kerberosSecurity>
    <requireActionHeader />
  </policy>
</policies>
  1. 在 Web 服务上应用策略:通过在服务类之前添加以下代码:

    [策略(“KerberosService”)]

这要归功于 Akrumooz。

https://www.codeproject.com/Articles/27554/Authentication-in-web-services-using-C-and-Kerbero

查看链接了解更多信息。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多