Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm using Forms authentication with WIF. The forms auth module redirects unauthorized requests to the correct controller and stores the originally requested URL in the <code>ReturnUrl</code> parameter, so I worked around this bug by overriding the <code>GetReturnUrlFromResponse</code> method.</p> <pre><code>/// &lt;summary&gt; /// Provides a workaround for a bug in the standard authentication module. /// &lt;/summary&gt; /// &lt;remarks&gt; /// This class corrects WIF error ID3206 "A SignInResponse message may only /// redirect within the current web application..." /// WSFAM produces the error when the ReturnUrl is the root of the web application, /// but doesn't have a trailing slash. For instance, "/app" is considered incorrect /// by WSFAM whereas "/app/" is correct. /// &lt;/remarks&gt; public class FixedWsFederationAuthenticationModule : System.IdentityModel.Services.WSFederationAuthenticationModule { /// &lt;summary&gt; /// Extracts the URL of the page that was originally requested from /// the sign-in response. /// &lt;/summary&gt; /// &lt;returns&gt; /// The URL of the page that was originally requested by the client. /// This is the URL (at the relying party) to which the client should /// be redirected following successful sign-in. /// &lt;/returns&gt; /// &lt;param name="request"&gt; /// The HTTP request that contains a form POST, which contains the /// WS-Federation sign-in response message. /// &lt;/param&gt; protected override string GetReturnUrlFromResponse(HttpRequestBase request) { string returnUrl = base.GetReturnUrlFromResponse(request); // First Check if the request url doesn't end with a "/" if (!string.IsNullOrEmpty(returnUrl) &amp;&amp; !returnUrl.EndsWith("/")) { // Compare if (return Url +"/") is equal to the Realm path, // so only root access is corrected. // /AppName plus "/" is equal to /AppName/ // This is to avoid MVC urls. if (string.Compare( returnUrl + "/", new Uri(Realm).LocalPath, StringComparison.InvariantCultureIgnoreCase) == 0) { // Add the trailing slash. returnUrl += "/"; } } return returnUrl; } } </code></pre> <p>To make use of this class, you need to register it in the web.config. Add this element to the <code>system.webServer/modules</code> section, changing the appropriate parts:</p> <pre><code>&lt;add name="WSFederationAuthenticationModule" type="YOUR_NAMESPACE.FixedWsFederationAuthenticationModule, YOUR_ASSEMBLY" preCondition="managedHandler" /&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. This table or related slice is empty.
    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