Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The <code>WebAuthenticationBroker</code> simply keeps browsing until the next requested page is the one specified by the <code>callbackUri</code> parameter. At that point it returns the final URL to you so if you want to get anything back it needs to be encoded in that URL.</p> <p>In the ACS control panel for the relying party you need to specify a return url that is somewhere on your site. For example <code>https://traffictheory.azurewebsites.net/federationcallback</code>. Then create a controller to handle accept a post to that URL. The post will have a form field <code>wresult</code> which is some xml that will contain the token returned from ACS. </p> <p>You can then send the token back to the <code>WebAuthenticationBroker</code> by redirecting to <code>https://traffictheory.azurewebsites.net/federationcallback/end?token={whatever you want to return}</code></p> <p>You would then need to change the usage of the authentication broker to the following:</p> <pre><code>var webAuthenticationResult = await WebAuthenticationBroker.AuthenticateAsync( WebAuthenticationOptions.None, new Uri("https://s-innovations.accesscontrol.windows.net:443/v2/wsfederation?wa=wsignin1.0&amp;wtrealm=http%3a%2f%2ftraffictheory.azurewebsites.net%2f"), new Uri("https://traffictheory.azurewebsites.net/federationcallback/end") ); // The data you returned var token = authenticateResult.ResponseData.Substring(authenticateResult.ResponseData.IndexOf("token=", StringComparison.Ordinal) + 6); </code></pre> <p>My controller for handling the authentication callback post looks like this.</p> <pre><code>public class FederationcallbackController : ApiController { public HttpResponseMessage Post() { var response = this.Request.CreateResponse(HttpStatusCode.Redirect); response.Headers.Add("Location", "/api/federationcallback/end?acsToken=" + ExtractBootstrapToken()); return response; } protected virtual string ExtractBootstrapToken() { return HttpContext.Current.User.BootstrapToken(); } } </code></pre> <p>The <code>BootstrapToken()</code> extenion method is part of the <code>wif.swt</code> NuGet package. By default WIF doesn't save anything to the bootstrap token property you need to enable it by including the <code>saveBootstrapTokens="true"</code> attribute on the <code>&lt;service&gt;</code> element under <code>&lt;microsoft.identityModel&gt;</code> in your web.config. Mine looks like this:</p> <pre><code>&lt;microsoft.identityModel&gt; &lt;service saveBootstrapTokens="true"&gt; &lt;audienceUris&gt; &lt;add value="http://localhost:3949/" /&gt; &lt;/audienceUris&gt; &lt;federatedAuthentication&gt; &lt;wsFederation passiveRedirectEnabled="true" issuer="https://xyz.accesscontrol.windows.net/v2/wsfederation" realm="http://localhost:3949/" reply="http://localhost:3949/" requireHttps="false" /&gt; &lt;cookieHandler requireSsl="false" path="/" /&gt; &lt;/federatedAuthentication&gt; &lt;issuerNameRegistry type="Microsoft.IdentityModel.Swt.SwtIssuerNameRegistry, Wif.Swt"&gt; &lt;trustedIssuers&gt; &lt;add name="https://readify.accesscontrol.windows.net/" thumbprint="{thumbprint}" /&gt; &lt;/trustedIssuers&gt; &lt;/issuerNameRegistry&gt; &lt;securityTokenHandlers&gt; &lt;add type="Microsoft.IdentityModel.Swt.SwtSecurityTokenHandler, Wif.Swt" /&gt; &lt;/securityTokenHandlers&gt; &lt;issuerTokenResolver type="Microsoft.IdentityModel.Swt.SwtIssuerTokenResolver, Wif.Swt" /&gt; &lt;/service&gt; &lt;/microsoft.identityModel&gt; </code></pre>
    singulars
    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.
    3. VO
      singulars
      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