Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding basic HTTP auth to a WCF REST service
    primarykey
    data
    text
    <p>I have a WCF HTTP REST Service and I tie into it with an HTTP client in a different programming language who writes its own custom HTTP. I would like to add WWW-Authenticate basic authentication support to my WCF service.</p> <p>My methods look like this:</p> <pre><code>[WebInvoke(UriTemplate = "widgets", Method = "POST")] public XElement CreateWidget(XElement e) { ... } </code></pre> <p>Is it possible for me to somehow filter incoming HTTP requests so I can check for a valid Basic auth string before it hits each of the REST methods like <code>CreateWidget</code> above? Note: My auth info is stord in my database.</p> <p>Basically I want to check for this in the request headers: <code>Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==</code> and then I can myself parse that string and validate the u/p in the database.</p> <p>The web.config file is as follows:</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;configuration&gt; &lt;connectionStrings&gt; &lt;add name="DatabaseConnectionString" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=Database;Integrated Security=True" providerName="System.Data.SqlClient" /&gt; &lt;/connectionStrings&gt; &lt;system.web&gt; &lt;compilation debug="true" targetFramework="4.0" /&gt; &lt;httpRuntime maxRequestLength="10485760" /&gt; &lt;/system.web&gt; &lt;system.webServer&gt; &lt;modules runAllManagedModulesForAllRequests="true"&gt; &lt;add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /&gt; &lt;/modules&gt; &lt;/system.webServer&gt; &lt;system.serviceModel&gt; &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true" /&gt; &lt;standardEndpoints&gt; &lt;webHttpEndpoint&gt; &lt;standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" maxReceivedMessageSize="1048576" maxBufferSize="1048576" /&gt; &lt;/webHttpEndpoint&gt; &lt;/standardEndpoints&gt; &lt;/system.serviceModel&gt; &lt;/configuration&gt; </code></pre>
    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.
 

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