2014-12-03 2 views
0

Я пытаюсь использовать Identity Server с ASP.NET (.NET 4.5.1, проект MVC) с использованием WIF и WS-Federation. Версия WSO2IS 5.0.0Отсутствует ограничение аудитории Отсутствует ответ SAML 2

Отказ от ответственности: Я новичок в WSO2IS и ASP.NET (не с самим .NET) и со всей информацией, но, возможно, я пропустил что-то основное.

Проблема в том, что ограничение аудитории отсутствует в ответе SAML 2. В противном случае все выглядит отлично.

В консоли управления идентификационным сервером -> поставщики услуг -> [мой поставщик услуг] -> входящая аутентификация -> Настройка веб-единой системы SAML2 -> [мой эмитент] -> edit -> включить ограничение аудитории, и мой ASP .NET URL веб-приложение в списке

Но это ответ мое приложение ASP.NET получает (ограничение аудитории отсутствует):

<wst:RequestSecurityTokenResponseCollection xmlns:wst=\"http://docs.oasis-open.org/ws-sx/ws-trust/200512\"> 
<wst:RequestSecurityTokenResponse> 
    <wst:TokenType>http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1</wst:TokenType> 
    <wst:RequestedAttachedReference> 
     <wsse:SecurityTokenReference xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"> 
      <wsse:KeyIdentifier ValueType=\"http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.0#SAMLAssertionID\">_8b7d9425958558c7742bb0cb8e8213e9</wsse:KeyIdentifier> 
     </wsse:SecurityTokenReference> 
    </wst:RequestedAttachedReference> 
    <wst:RequestedUnattachedReference> 
     <wsse:SecurityTokenReference xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\"> 
      <wsse:KeyIdentifier ValueType=\"http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.0#SAMLAssertionID\">_8b7d9425958558c7742bb0cb8e8213e9</wsse:KeyIdentifier> 
     </wsse:SecurityTokenReference> 
    </wst:RequestedUnattachedReference> 
    <wst:Lifetime> 
     <wsu:Created xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">2014-12-02T11:55:13.190Z</wsu:Created> 
     <wsu:Expires xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">2014-12-02T12:00:13.190Z</wsu:Expires> 
    </wst:Lifetime> 
    <wst:RequestedSecurityToken> 
     <Assertion xmlns=\"urn:oasis:names:tc:SAML:1.0:assertion\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:samlp=\"urn:oasis:names:tc:SAML:1.0:protocol\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\" AssertionID=\"_8b7d9425958558c7742bb0cb8e8213e9\" IssueInstant=\"2014-12-02T11:55:13.190Z\" Issuer=\"localhost\" MajorVersion=\"1\" MinorVersion=\"1\"> 
      <Conditions NotBefore=\"2014-12-02T11:55:13.190Z\" NotOnOrAfter=\"2014-12-02T12:00:13.190Z\"></Conditions> 
      <AuthenticationStatement AuthenticationInstant=\"2014-12-02T11:55:13.190Z\" AuthenticationMethod=\"urn:oasis:names:tc:SAML:1.0:am:password\"> 
      <Subject> 
       <NameIdentifier Format=\"urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress\">admin</NameIdentifier> 
       <SubjectConfirmation> 
        <ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:bearer</ConfirmationMethod> 
       </SubjectConfirmation> 
      </Subject> 
      </AuthenticationStatement> 
      <ds:Signature xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\"> 
       <ds:SignedInfo> 
        <ds:CanonicalizationMethod Algorithm=\"http://www.w3.org/2001/10/xml-exc-c14n#\"></ds:CanonicalizationMethod> 
        <ds:SignatureMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#rsa-sha1\"></ds:SignatureMethod> 
        <ds:Reference URI=\"#_8b7d9425958558c7742bb0cb8e8213e9\"> 
         <ds:Transforms> 
          <ds:Transform Algorithm=\"http://www.w3.org/2000/09/xmldsig#enveloped-signature\"></ds:Transform> 
          <ds:Transform Algorithm=\"http://www.w3.org/2001/10/xml-exc-c14n#\"> 
           <ec:InclusiveNamespaces xmlns:ec=\"http://www.w3.org/2001/10/xml-exc-c14n#\" PrefixList=\"code ds kind rw saml samlp typens #default xsd xsi\"></ec:InclusiveNamespaces> 
          </ds:Transform> 
         </ds:Transforms> 
         <ds:DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"></ds:DigestMethod> 
         <ds:DigestValue>cqn2im7M8olMyPuO8BDhQvFlcU8=</ds:DigestValue> 
        </ds:Reference> 
       </ds:SignedInfo> 
       <ds:SignatureValue>jO/kPk+APtOc/gBUsBcLaM4VIbBGe/l2zKAkqjWxfHhkAOx0aduAEt6CssAeY9PrDB/93hxghNPJvn/VAkHKaCLD4/Dt7CwotZHz0l3UABZZiYoMzrZJmO5eOPjA5MAO52Q9vQ+gqLk/iLZCBskgubPmMswi7eufH8jSZES2/ZY=</ds:SignatureValue> 
       <ds:KeyInfo> 
        <ds:X509Data> 
         <ds:X509Certificate>MIICNTCCAZ6gAwIBAgIES343gjANBgkqhkiG9w0BAQUFADBVMQswCQYDVQQGEwJVUzELMAkGA1UECAwCQ0ExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxDTALBgNVBAoMBFdTTzIxEjAQBgNVBAMMCWxvY2FsaG9zdDAeFw0xMDAyMTkwNzAyMjZaFw0zNTAyMTMwNzAyMjZaMFUxCzAJBgNVBAYTAlVTMQswCQYDVQQIDAJDQTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzENMAsGA1UECgwEV1NPMjESMBAGA1UEAwwJbG9jYWxob3N0MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCUp/oV1vWc8/TkQSiAvTousMzOM4asB2iltr2QKozni5aVFu818MpOLZIr8LMnTzWllJvvaA5RAAdpbECb+48FjbBe0hseUdN5HpwvnH/DW8ZccGvk53I6Orq7hLCv1ZHtuOCokghz/ATrhyPq+QktMfXnRS4HrKGJTzxaCcU7OQIDAQABoxIwEDAOBgNVHQ8BAf8EBAMCBPAwDQYJKoZIhvcNAQEFBQADgYEAW5wPR7cr1LAdq+IrR44iQlRG5ITCZXY9hI0PygLP2rHANh+PYfTmxbuOnykNGyhM6FjFLbW2uZHQTY1jMrPprjOrmyK5sjJRO4d1DeGHT/YnIjs9JogRKv4XHECwLtIVdAbIdWHEtVZJyMSktcyysFcvuhPQK8Qc/E/Wq8uHSCo=</ds:X509Certificate> 
        </ds:X509Data> 
       </ds:KeyInfo> 
      </ds:Signature> 
     </Assertion> 
    </wst:RequestedSecurityToken> 
</wst:RequestSecurityTokenResponse> 

Моя одна догадка версия SAML, возможно, неправильно но я не вижу настройки для т.

Также в меню Сервис -> SAML Response Builder я получаю это:

<?xml version="1.0" encoding="UTF-8"?> 
<saml2p:Response Destination="https://localhost/SSOTestMVC" ID="cieicenceonlnooiogijcipfohekehdpdhmefpgk" IssueInstant="2014-12-02T12:40:35.411Z" Version="2.0" xmlns:saml2p="urn:oasis:names:tc:SAML:2.0:protocol"> 
    <saml2:Issuer Format="urn:oasis:names:tc:SAML:2.0:nameid-format:entity" xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion">localhost</saml2:Issuer> 
    <saml2p:Status> 
     <saml2p:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success"/> 
    </saml2p:Status> 
    <saml2:Assertion ID="jfmphpmhlnedheigcgefihafkehcjlmpminchpgg" IssueInstant="2014-12-02T12:40:35.438Z" Version="2.0" xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion"> 
     <saml2:Issuer Format="urn:oasis:names:tc:SAML:2.0:nameid-format:entity">localhost</saml2:Issuer> 
     <saml2:Subject> 
      <saml2:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress">admin</saml2:NameID> 
      <saml2:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer"> 
       <saml2:SubjectConfirmationData NotOnOrAfter="2014-12-02T12:45:35.411Z" Recipient="https://localhost/SSOTestMVC"/> 
      </saml2:SubjectConfirmation> 
     </saml2:Subject> 
     <saml2:Conditions NotBefore="2014-12-02T12:40:35.438Z" NotOnOrAfter="2014-12-02T12:45:35.411Z"> 
      <saml2:AudienceRestriction> 
       <saml2:Audience>localhost</saml2:Audience> 
       <saml2:Audience>https://localhost/SSOTestMVC</saml2:Audience> 
       <saml2:Audience>https://localhost/SSOTestMVC/</saml2:Audience> 
      </saml2:AudienceRestriction> 
     </saml2:Conditions> 
     <saml2:AuthnStatement AuthnInstant="2014-12-02T12:40:35.447Z"> 
      <saml2:AuthnContext> 
       <saml2:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:Password</saml2:AuthnContextClassRef> 
      </saml2:AuthnContext> 
     </saml2:AuthnStatement> 
    </saml2:Assertion> 
</saml2p:Response> 

Зритель правильно, что я добавил к списку.

А вот Мей web.config для справки:

<?xml version="1.0"?> 
<!-- 
    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"/> 
    </configSections> 
    <system.diagnostics> 
     <sources> 
      <source name="System.IdentityModel" switchValue="Verbose"> 
       <listeners> 
        <add name="xml" type="System.Diagnostics.XmlWriterTraceListener" initializeData="C:\logs\WIF.xml" /> 
       </listeners> 
      </source> 
     </sources> 
     <trace autoflush="true" /> 
    </system.diagnostics> 
    <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"/> 
     <add key="FederationMetadataLocation" value="https://localhost/startersts/FederationMetadata/2007-06/FederationMetadata.xml"/> 
    </appSettings> 
    <!-- 
    For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367. 

    The following attributes can be set on the <httpRuntime> tag. 
     <system.Web> 
     <httpRuntime targetFramework="4.5.1" /> 
     </system.Web> 
    --> 

    <system.webServer> 
     <modules> 
      <add name="WSFederationAuthenticationModule" type="System.IdentityModel.Services.WSFederationAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="managedHandler" /> 
      <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> 

    <system.web> 
    <compilation debug="true" targetFramework="4.5.1"/> 
    <!--<httpRuntime targetFramework="4.5" requestValidationType="SampleRequestValidator"/>--> 
    <authorization> 
     <deny users="?"/> 
    </authorization> 
    <authentication mode="None"/> 
    <httpRuntime requestValidationMode="2.0" /> 
    <pages validateRequest="false" /> 
    </system.web> 

    <location path="FederationMetadata"> 
    <system.web> 
     <authorization> 
     <allow users="*"/> 
     </authorization> 
    </system.web> 
    </location> 
    <runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <dependentAssembly> 
     <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed"/> 
     <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"/> 
     </dependentAssembly> 
     <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="1.0.0.0-1.5.2.14234" newVersion="1.5.2.14234"/> 
     </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.0.0" newVersion="5.2.0.0"/> 
     </dependentAssembly> 
    </assemblyBinding> 
    </runtime> 
    <system.identityModel> 
    <identityConfiguration> 
     <audienceUris> 
     <add value="https://localhost/SSOTestMVC"/> 
     </audienceUris> 
     <issuerNameRegistry type="System.IdentityModel.Tokens.ConfigurationBasedIssuerNameRegistry, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 
     <trustedIssuers> 
      <add thumbprint="6bf8e136eb36d4a56ea05c7ae4b9a45b63bf975d" name="localhost"/> 
     </trustedIssuers> 
     </issuerNameRegistry> 
     <certificateValidation certificateValidationMode="None"/> 
    </identityConfiguration> 
    </system.identityModel> 
    <system.identityModel.services> 
    <federationConfiguration> 
     <cookieHandler requireSsl="false"/> 
     <wsFederation passiveRedirectEnabled="true" issuer="https://localhost:9443/passivests" realm="https://localhost/SSOTestMVC" requireHttps="true" reply="https://localhost/SSOTestMVC"/> 
    </federationConfiguration> 
    </system.identityModel.services> 
</configuration> 

Я искал для установки версии SAML в web.config подозревая, что может быть проблемой, но нет результата.

ответ

0

Во-первых, я хочу подчеркнуть, что Identity Server поддерживает следующие два профиля.

  1. SAML2 SSO Профиль веб-браузера. (Используются SAML2) Более подробная информация от here
  2. Профиль WS-Federation (Passive STS). (SAML Assertion)

Обычно ASP.NET по умолчанию поддерживает 2 профиля. Поэтому вы интегрируете с помощью пассивной STS. Кажется, в вашей конфигурации вы установили url в пассивную конечную точку STS https://localhost:9443/passivests. Если вы используете профиль SAML2, обычно вам необходимо установить его на https://localhost:9443/samlsso

Поэтому конфигурация, выполненная вами в WSO2IS, недействительна. Они связаны с профилем SSO SAML2. Для пассивных STS вы можете найти конфигурации под WS-Federation (Passive) Configuration

Однако в пассивной STS есть bug, что Identity Server не добавляет аудиторию в утверждение SAML.

Однако, Вы можете избежать проверки аудитории, установив web.config <audienceUris mode="Never" />

+0

Так вы говорите, что первый метод не поддерживается в ASP.NET? – naeron84

+0

Как я знаю, это не по умолчанию с WIF. Но есть некоторые способы сделать это.На самом деле я не очень хорошо знаком с ASP.NET. Вы видели статью о пассивных STS и WSO2IS http://wso2.com/library/articles/2011/12/configuring-wso2-identity-server-passive-sts-aspnet-client/ – Asela

+0

Да, я использовал это для создания вещей с ASP.NET. Также он несколько устарел: настройки находятся в другом месте в версии 5, а пример проекта не работает с .NET 4.5. Но я решил это и установил mode = "Never". пассивный STS полностью удовлетворительный, но, насколько я понимаю, если ограничение аудитории не установлено, это может быть проблемой безопасности. – naeron84

Смежные вопросы