Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Soo, dedication will bring one to a solution. Although I initially thought that this can't be done, it's apparent that it actually can. I'll put the solution here, as maybe there are other people who find it useful.</p> <p>First of all, WCF REST services are using <code>webHttpBinding</code>, which according to MS documentation does not support the Windows Identity Foundation and claims handling in the pipeline. Actually it does. Not in the WCF pipeline, but as the IIS module in web authentication flow.</p> <p>First, you need to add the following modules to Web.config file.</p> <pre><code>&lt;system.webServer&gt; &lt;modules runManagedModulesForAllRequests="true"&gt; &lt;add name="WSFederationAuthenticationModule" type="System.IdentityModel.Services.WSFederationAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" preCondition="managedHandler" /&gt; &lt;add name="SessionAuthenticationModule" type="System.IdentityModel.Services.SessionAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" preCondition="managedHandler" /&gt; &lt;/modules&gt; &lt;/system.webServer&gt; </code></pre> <p>There's a caveat tho. You need still the <code>&lt;configSections&gt;</code> from my original posting. The problem is that you need, in VisualStudio, to mark the <code>System.IdentyModel*</code> assemblies as <strong>CopyLocal</strong> items (in the properties window). Otherwise you'll get some cryptic exception that assembly cannot be loaded for the configuration section. NB! It only happens if you are loading these two modules and doesn't happen when those modules are not getting loaded. Didn't have any will to investigate that thing further, perhaps someone knows better what's the cause there.</p> <p>Next if for any reason you plan to use the SWT token handling sample from MS WIF code, there are a couple of bugs that need to be fixed, otherwise the token parsing just won't happen or you will get invalid signatures out of the token verification.</p> <p><strong>SimpleWebToken.cs</strong> you need to fix the SwtBaseTime as it is initialized incorrectly and the security token creation fails afterwards:</p> <p>From public static DateTime SwtBaseTime = new DateTime( 1970, 1, 1, 0, 0, 0, 0 ); // per SWT psec To</p> <pre><code>public static DateTime SwtBaseTime = new DateTime( 1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc ); // per SWT psec </code></pre> <p><strong>SimpleWebTokenHandler.cs</strong> you need to fix the casing of the following values:</p> <p>From</p> <pre><code>const string BinarySecurityToken = "binarySecurityToken"; const string ValueType = "valueType"; </code></pre> <p>To</p> <pre><code>const string BinarySecurityToken = "BinarySecurityToken"; const string ValueType = "ValueType"; </code></pre> <p><strong>CustomIssuerTokenResolver.cs</strong> you need to fix the key that is created as it's initalized with a UTF8 bytes, but it should actually get initialized with decoded Base64 bytes:</p> <p>From</p> <pre><code>key = new InMemorySymmetricSecurityKey(UTF8Encoding.UTF8.FromBase64String(base64Key)); </code></pre> <p>To</p> <pre><code>key = new InMemorySymmetricSecurityKey(System.Convert.FromBase64String(base64Key)); </code></pre> <p>After you've fixed all this, everything sits in place. The authenticators and authorizators are getting called and voilà, suddenly you have a WCF Service exposed as REST endpoint and all the claims etc. are also working.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload