title: WCF REST Authentication behavior
body: <p>I want to be able to authenticate a WCF Rest webservice but I'm not really sure how to go about it. It looks like many of the other questions relate to stuff in .net 3.5 WCF (such as WebServiceHost2) which no longer seems to exist.</p>
  
  <p>I am wanting to do message based authentication on the WCF service with custom usernames and passwords. From what I can tell this can be done by the following in regular WCF:</p>
  
  <pre><code>&lt;behaviors&gt;
    &lt;serviceBehaviors&gt;
      &lt;behavior name="PasswordValidator"&gt;
        &lt;serviceCredentials&gt;
          &lt;userNameAuthentication userNamePasswordValidationMode="Custom"
                                  customUserNamePasswordValidatorType="MyNamespace.PasswordValidator, MyNamespace"/&gt;
        &lt;/serviceCredentials&gt;
      &lt;/behavior&gt;
    &lt;/serviceBehaviors&gt;
  &lt;/behaviors&gt;
  </code></pre>
  
  <p>however as I am using Rest I cant get this web.config based behaviour config going. I somehow need to do this in my serviceRoute.</p>
  
  <pre><code>RouteTable.Routes.Add(new ServiceRoute("", new WebServiceHostFactory(), typeof(HelloService)));
  </code></pre>
  
  <p>does anyone know how to do this or have any good tutorials on Message Based security with Rest and WCF 4.0? </p>